当前位置: 首页>>代码示例>>Python>>正文


Python AtomSet.sort方法代码示例

本文整理汇总了Python中MolKit.molecule.AtomSet.sort方法的典型用法代码示例。如果您正苦于以下问题:Python AtomSet.sort方法的具体用法?Python AtomSet.sort怎么用?Python AtomSet.sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MolKit.molecule.AtomSet的用法示例。


在下文中一共展示了AtomSet.sort方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: detectPiInteractions

# 需要导入模块: from MolKit.molecule import AtomSet [as 别名]
# 或者: from MolKit.molecule.AtomSet import sort [as 别名]
 def detectPiInteractions(self, tolerance=0.95, debug=False, use_all_cycles=False):
     if debug: print "in detectPiInteractions"
     self.results['pi_pi'] = []        #stacked rings...?
     self.results['t_shaped'] = []     #one ring perpendicular to the other
     self.results['cation_pi'] = []    #
     self.results['pi_cation'] = []    #
     self.results['macro_cations'] = []#
     self.results['lig_cations'] = []  #
     #at this point have self.results
     if not len(self.results['lig_close_atoms']):
         return
     lig_atoms = self.results['lig_close_atoms'].parent.uniq().atoms
     macro_res = self.results['macro_close_atoms'].parent.uniq()
     if not len(macro_res):
         return
     macro_atoms = macro_res.atoms
     l_rf = RingFinder()
     #Ligand
     l_rf.findRings2(lig_atoms, lig_atoms.bonds[0])
     #rf.rings is list of dictionaries, one per ring, with keys 'bonds' and 'atoms'
     if debug: print "LIG: len(l_rf.rings)=", len(l_rf.rings)
     if not len(l_rf.rings):
         if debug: print "no lig rings found by l_rf!"
         return
     acbs = self.aromatic_cycle_bond_selector
     #acbs = AromaticCycleBondSelector()
     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)
         macro_cations = macro_cations.get(lambda x: x.element!='H')
         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:
                     z[val] = [key]
             if len(z):
                 self.results['pi_cation'] = (z.items())
             else:
                 self.results['pi_cation'] = []
     #check the distance between the rings and the macro_cations
     self.results['lig_cations'] = self.getCations(lig_atoms)
     lig_cations = self.results['lig_cations'] 
     #remove hydrogens
     lig_cations = lig_cations.get(lambda x: x.element!='H')
     #Macromolecule
     m_rf = RingFinder()
     m_rf.findRings2(macro_res.atoms, macro_res.atoms.bonds[0])
     #rf.rings is list of dictionaries, one per ring, with keys 'bonds' and 'atoms'
     if debug: print "MACRO: len(m_rf.rings)=", len(m_rf.rings)
     if not len(m_rf.rings):
         if debug: print "no macro rings found by m_rf!"
         return
     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):
         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
#.........这里部分代码省略.........
开发者ID:8848,项目名称:Pymol-script-repo,代码行数:103,代码来源:InteractionDetector.py


注:本文中的MolKit.molecule.AtomSet.sort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。