Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
arom_bnds = acbs.select(ring_bnds)
if len(arom_bnds)>4:
macro_rings.append(arom_bnds)
if debug: print "len(macro_arom_rings)=", len(macro_rings)
self.results['macro_rings'] = macro_rings
self.results['macro_ring_atoms'] = AtomSet()
#only check for pi-cation if macro_rings exist
if len(macro_rings):
lig_cations = self.results['lig_cations'] = self.getCations(lig_atoms)
macro_ring_atoms = AtomSet()
u = {}
for r in macro_rings:
for a in BondSet(r).getAtoms(): #new method of bondSets
u[a] = 1
if len(u):
macro_ring_atoms = AtomSet(u.keys())
macro_ring_atoms.sort()
self.results['macro_ring_atoms'] = macro_ring_atoms
if len(lig_cations):
if debug: print "check distances from macro_rings to lig_cations here"
pairDict3 = self.distanceSelector.select(macro_ring_atoms,lig_cations)
z = {}
for x in pairDict3.items():
#lig cations->macro rings
z.setdefault(x[1].tolist()[0], []).append(x[0])
if len(z):
self.results['cation_pi'] = (z.items())
else:
self.results['cation_pi'] = []
#macro_pi_atoms = AtomSet(pairDict3.keys())
#l_cations = AtomSet()
#for v in pairDict3.values():
def buildCloseContactAtoms(self, percentCutoff):
pairDict = self.distanceSelector.select(self.lig_atoms,
self.macro_atoms, percentCutoff=percentCutoff)
self.pairDict = pairDict
#reset here
lig_close_ats = AtomSet()
macro_close_ats = AtomSet()
closeAtoms = AtomSet() #both sets
cdict = {}
for k,v in pairDict.items():
if len(v):
cdict[k] = 1
for at in v:
if at not in macro_close_ats:
cdict[at] = 1
closeAtoms = AtomSet(cdict.keys())
#macro_close_ats = closeAtoms.get(lambda x: x.top==self.macro)
#lig_close_ats = closeAtoms.get(lambda x: x.top==self.lig)
lig_close_ats = closeAtoms.get(lambda x: x in self.lig_atoms)
macro_close_ats = closeAtoms.get(lambda x: x in self.macro_atoms)
rdict = self.results
rdict['lig_close_atoms'] = lig_close_ats
rdict['lig_close_res'] = lig_close_ats.parent.uniq()
rdict['lig_close_carbons'] = lig_close_ats.get(lambda x: x.element=='C')
rdict['lig_close_non_hb'] = lig_close_ats - rdict['lig_hb_atoms']
rdict['macro_close_atoms'] = macro_close_ats
rdict['macro_close_res'] = ResidueSet(macro_close_ats.parent.uniq())
rdict['macro_close_carbons'] = macro_close_ats.get(lambda x: x.element=='C')
rdict['macro_close_non_hb'] = macro_close_ats - rdict['macro_hb_atoms']
#deprecate this
rdict['macro_close_only'] = macro_close_ats - rdict['macro_hb_atoms']
self.results = d = {}
h_pairDict = self.hydrogen_bond_builder.build(self.lig_atoms, self.macro_atoms)
self.h_pairDict = h_pairDict
#keys should be from lig, values from macro
#sometimes are not...@@check this@@
h_results = {}
for k, v in h_pairDict.items():
h_results[k] = 1
for at in v:
h_results[at] = 1
all_hb_ats = AtomSet(h_results.keys()) #all
macro_hb_ats = d['macro_hb_atoms'] = all_hb_ats.get(lambda x: x.top==self.macro)
# process lig
lig_hb_res = d['lig_hb_res'] = ResidueSet()
lig_hb_sidechains = d['lig_hb_sidechains'] = AtomSet()
lig_gly_atoms = AtomSet()
lig_hb_ats = d['lig_hb_atoms'] = all_hb_ats.get(lambda x: x in self.lig_atoms)
if len(lig_hb_ats):
d['lig_hb_res'] = lig_hb_res = lig_hb_ats.parent.uniq()
d['lig_hb_sidechains'] = lig_hb_sidechains = lig_hb_res.atoms.get('sidechain')
#to visualize hbonding involving GLY residues which have no side chains, show backbone atoms
lig_gly_res = d['lig_hb_gly_res'] = lig_hb_res.get(lambda x: x.type=='GLY')
if len(lig_gly_res):
lig_gly_atoms = lig_gly_res.atoms
# build extended set of hbonding_atoms_to_show as lines, just in case
lig_hbas = AtomSet(lig_hb_sidechains + lig_gly_atoms + lig_hb_ats) #all from lig
extraAts = AtomSet()
for at in lig_hbas:
for b in at.bonds:
at2 = b.atom1
if at2==at:
at2 = b.atom2
lig_rings = []
for r in l_rf.rings:
ring_bnds = r['bonds']
if use_all_cycles:
lig_rings.append(ring_bnds)
else:
arom_bnds = acbs.select(ring_bnds)
if len(arom_bnds)>4:
lig_rings.append(arom_bnds)
if debug: print "LIG: len(lig_arom_rings)=", len(lig_rings)
self.results['lig_rings'] = lig_rings
self.results['lig_ring_atoms'] = AtomSet()
#only check for pi-cation if lig_rings exist
if len(lig_rings):
macro_cations = self.results['macro_cations'] = self.getCations(macro_atoms)
lig_ring_atoms = AtomSet()
u = {}
for r in lig_rings:
for a in BondSet(r).getAtoms():
u[a] = 1
if len(u):
lig_ring_atoms = AtomSet(u.keys())
lig_ring_atoms.sort()
self.results['lig_ring_atoms'] = lig_ring_atoms
if len(macro_cations):
if debug: print "check distances from lig_rings to macro_cations here"
#macro cations->lig rings
pairDict2 = self.distanceSelector.select(lig_ring_atoms,macro_cations)
z = {}
for key,v in pairDict2.items():
val = v.tolist()[0]
if val in macro_cations:
def buildCloseContactAtoms(self, percentCutoff):
pairDict = self.distanceSelector.select(self.lig_atoms,
self.macro_atoms, percentCutoff=percentCutoff)
self.pairDict = pairDict
#reset here
lig_close_ats = AtomSet()
macro_close_ats = AtomSet()
closeAtoms = AtomSet() #both sets
cdict = {}
for k,v in pairDict.items():
if len(v):
cdict[k] = 1
for at in v:
if at not in macro_close_ats:
cdict[at] = 1
closeAtoms = AtomSet(cdict.keys())
#macro_close_ats = closeAtoms.get(lambda x: x.top==self.macro)
#lig_close_ats = closeAtoms.get(lambda x: x.top==self.lig)
lig_close_ats = closeAtoms.get(lambda x: x in self.lig_atoms)
macro_close_ats = closeAtoms.get(lambda x: x in self.macro_atoms)
rdict = self.results
rdict['lig_close_atoms'] = lig_close_ats
def buildCloseContactAtoms(self, percentCutoff):
pairDict = self.distanceSelector.select(self.lig_atoms,
self.macro_atoms, percentCutoff=percentCutoff)
self.pairDict = pairDict
#reset here
lig_close_ats = AtomSet()
macro_close_ats = AtomSet()
closeAtoms = AtomSet() #both sets
cdict = {}
for k,v in pairDict.items():
if len(v):
cdict[k] = 1
for at in v:
if at not in macro_close_ats:
cdict[at] = 1
closeAtoms = AtomSet(cdict.keys())
#macro_close_ats = closeAtoms.get(lambda x: x.top==self.macro)
#lig_close_ats = closeAtoms.get(lambda x: x.top==self.lig)
lig_close_ats = closeAtoms.get(lambda x: x in self.lig_atoms)
macro_close_ats = closeAtoms.get(lambda x: x in self.macro_atoms)
rdict = self.results
rdict['lig_close_atoms'] = lig_close_ats
rdict['lig_close_res'] = lig_close_ats.parent.uniq()
if len(macro_hb_ats):
macro_hb_res = macro_hb_ats.parent.uniq()
#4. display sidechains of hbonding residues as sticksNballs
macro_hb_sidechains = d['macro_hb_sidechains'] = macro_hb_res.atoms.get('sidechain')
macro_hb_gly_res = d['macro_hb_gly_res'] = macro_hb_res.get(lambda x: x.type=='GLY')
macro_hb_gly_res = ResidueSet()
macro_hb_gly_atoms = AtomSet()
if len(macro_hb_gly_res):
macro_hb_gly_atoms = macro_hb_gly_res.atoms
d['macro_hb_gly_atoms'] = macro_hb_gly_atoms
# build extended set of hbonding_atoms_to_show as lines
macro_hbas = d['macro_hbas'] = AtomSet()
if len(macro_hb_ats):
macro_hbas = d['macro_hbas'] = AtomSet(macro_hb_sidechains + macro_hb_gly_atoms + macro_hb_ats) #all from macro
#add atoms bonded to hb atoms to make lines displayed more reasonable
extraAts = AtomSet()
for at in macro_hbas:
for b in at.bonds:
at2 = b.atom1
if at2==at:
at2 = b.atom2
#add it to the atomset
if at2 not in macro_hbas:
extraAts.append(at2)
if len(macro_hbas):
for at in extraAts:
macro_hbas.append(at)
d['hbas_macro'] = macro_hbas
macro_rings = []
for r in m_rf.rings:
ring_bnds = r['bonds']
if use_all_cycles:
macro_rings.append(ring_bnds)
else:
arom_bnds = acbs.select(ring_bnds)
if len(arom_bnds)>4:
macro_rings.append(arom_bnds)
if debug: print "len(macro_arom_rings)=", len(macro_rings)
self.results['macro_rings'] = macro_rings
self.results['macro_ring_atoms'] = AtomSet()
#only check for pi-cation if macro_rings exist
if len(macro_rings):
lig_cations = self.results['lig_cations'] = self.getCations(lig_atoms)
macro_ring_atoms = AtomSet()
u = {}
for r in macro_rings:
for a in BondSet(r).getAtoms(): #new method of bondSets
u[a] = 1
if len(u):
macro_ring_atoms = AtomSet(u.keys())
macro_ring_atoms.sort()
self.results['macro_ring_atoms'] = macro_ring_atoms
if len(lig_cations):
if debug: print "check distances from macro_rings to lig_cations here"
pairDict3 = self.distanceSelector.select(macro_ring_atoms,lig_cations)
z = {}
for x in pairDict3.items():
#lig cations->macro rings
z.setdefault(x[1].tolist()[0], []).append(x[0])
if len(z):