Exemplo n.º 1
0
 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']
Exemplo n.º 2
0
 def dictToResidues(self, pairDict):
     """ 
     The input, 'pairDict',  is a dictionary with atoms as keys and lists of atoms close to each key atom as values.  This method converts these keys and values to residue sets. The first returned value is a unique ResidueSet of the 'control' or 'key' atoms used for the distance selection and the second a unique ResidueSet of parents of atoms close to the keys
     """ 
     if not len(pairDict):
         return ResidueSet(), ResidueSet()
     from MolKit.molecule import AtomSet
     #parents of keys
     key_parents = AtomSet(pairDict.keys()).parent.uniq()
     key_parents.sort()
     #parents of values
     #build unique list of close atoms
     ats = {}
     for k in pairDict.keys():
         for rec_at in pairDict[k]:
             ats[rec_at] = 1
     close_ats = AtomSet(ats.keys())
     close_parents = close_ats.parent.uniq()
     close_parents.sort()
     return key_parents, close_parents
 def buildContiguousCloseResidueSequences(self):
     #7. attempt to show ribbon for contiguous residues in macromolecule
     rdict = self.results
     res = rdict['macro_close_res']
     chs = res.parent.uniq()
     ss_res = ResidueSet()
     last_ind = 0
     chain1 = 1
     #output = 0
     for c in chs:
         num_res = len(c.residues)
         if num_res <3:
             continue
         rr = res.get(lambda x: x.parent==c)
         rr.sort()
         chain1 = 0
         current_seq = ResidueSet() # contiguous residues
         current_set = ResidueSet() # all pieces in this chain
         skipped_set = ResidueSet() # hole in current contiguous piece
         if len(rr)>3:  #?? min num residues for ss:at least 3??
             #reset all
             first = c.residues.index(rr[0])
             last = c.residues.index(rr[-1])
             for r in c.residues[first:last+1]:
                 if r==c.residues[-1]:
                     if r in rr: 
                         if len(current_seq)>3:
                             current_seq.append(r)
                     if len(current_seq)>4:
                         ss_res.extend(current_seq)
                 if r not in rr:  #process hole
                     skipped_set.append(r)   # one hole ok
                     if len(skipped_set)>=2: # found second hole -> end seq
                         if len(current_seq)>4:
                             if not len(current_set):
                                 current_set = current_seq[:]
                                 current_set.sort()
                             else:
                                 current_set.extend(current_seq)
                                 current_set.sort()
                             if not len(ss_res):
                                 ss_res = current_set[:]
                             else:
                                 ss_res.extend(current_set)
                         skipped_set = ResidueSet()
                         current_seq = ResidueSet()
                 else:
                     #reset skipped_set
                     if len(skipped_set)<=1 and len(current_seq)>=1: #save RR_R 
                         current_seq.extend(skipped_set) #save hole if there is one
                         current_seq.append(r) #save this residue
                     else:  #just save it
                         current_seq.append(r)
                     skipped_set= ResidueSet()
         if len(current_seq)>4:
             for r in current_seq:
                 if r not in ss_res:
                     ss_res.append(r)
         if len(current_set)>4:
             for r in current_set:
                 if r not in ss_res:
                     ss_res.append(r)
     rdict['ss_res'] = ss_res
 def buildHydrogenBonds(self):
     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
             #add it to the atomset
             if at2 not in lig_hbas:
                 extraAts.append(at2)
     if len(lig_hbas):
         for at in extraAts:
             lig_hbas.append(at)
     d['lig_hbas'] = lig_hbas
     # process macro
     macro_hb_res =  ResidueSet()
     d['macro_hb_res'] = macro_hb_res
     d['macro_hb_sidechains'] = AtomSet()
     d['macro_hb_gly_res'] = ResidueSet()
     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
Exemplo n.º 5
0
 def buildHydrogenBonds(self):
     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
             #add it to the atomset
             if at2 not in lig_hbas:
                 extraAts.append(at2)
     if len(lig_hbas):
         for at in extraAts:
             lig_hbas.append(at)
     d['lig_hbas'] = lig_hbas
     # process macro
     macro_hb_res =  ResidueSet()
     d['macro_hb_res'] = macro_hb_res
     d['macro_hb_sidechains'] = AtomSet()
     d['macro_hb_gly_res'] = ResidueSet()
     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
Exemplo n.º 6
0
 def buildContiguousCloseResidueSequences(self):
     #7. attempt to show ribbon for contiguous residues in macromolecule
     rdict = self.results
     res = rdict['macro_close_res']
     chs = res.parent.uniq()
     ss_res = ResidueSet()
     last_ind = 0
     chain1 = 1
     #output = 0
     for c in chs:
         num_res = len(c.residues)
         if num_res <3:
             continue
         rr = res.get(lambda x: x.parent==c)
         rr.sort()
         chain1 = 0
         current_seq = ResidueSet() # contiguous residues
         current_set = ResidueSet() # all pieces in this chain
         skipped_set = ResidueSet() # hole in current contiguous piece
         if len(rr)>3:  #?? min num residues for ss:at least 3??
             #reset all
             first = c.residues.index(rr[0])
             last = c.residues.index(rr[-1])
             for r in c.residues[first:last+1]:
                 if r==c.residues[-1]:
                     if r in rr: 
                         if len(current_seq)>3:
                             current_seq.append(r)
                     if len(current_seq)>4:
                         ss_res.extend(current_seq)
                 if r not in rr:  #process hole
                     skipped_set.append(r)   # one hole ok
                     if len(skipped_set)>=2: # found second hole -> end seq
                         if len(current_seq)>4:
                             if not len(current_set):
                                 current_set = current_seq[:]
                                 current_set.sort()
                             else:
                                 current_set.extend(current_seq)
                                 current_set.sort()
                             if not len(ss_res):
                                 ss_res = current_set[:]
                             else:
                                 ss_res.extend(current_set)
                         skipped_set = ResidueSet()
                         current_seq = ResidueSet()
                 else:
                     #reset skipped_set
                     if len(skipped_set)<=1 and len(current_seq)>=1: #save RR_R 
                         current_seq.extend(skipped_set) #save hole if there is one
                         current_seq.append(r) #save this residue
                     else:  #just save it
                         current_seq.append(r)
                     skipped_set= ResidueSet()
         if len(current_seq)>4:
             for r in current_seq:
                 if r not in ss_res:
                     ss_res.append(r)
         if len(current_set)>4:
             for r in current_set:
                 if r not in ss_res:
                     ss_res.append(r)
     rdict['ss_res'] = ss_res