• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python molecule.AtomSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createPairs

    def createPairs(self, refnames, mobnames, slice, choice):
        # This is where the atom pairs are created
        # Get the ref atom set
        refAtms = AtomSet([])
        mobAtms = AtomSet([])
        for name in refnames:
            refnod = self.refNodes[name]
            atms = refnod.findType(Atom)
            refAtms = refAtms + atms

        for name in mobnames:
            mobnod = self.mobNodes[name]
            atms = mobnod.findType(Atom)
            mobAtms = mobAtms + atms
        # Now apply the filters to the sets
        if choice:
            refFiltAtms = refAtms.get(self.filters[choice])
            mobFiltAtms = mobAtms.get(self.filters[choice])
        if not len(refFiltAtms) == len(mobFiltAtms):
            #print 'slicing', slice
            self.warningMsg("the two sets of atoms needs to be of the same length")
            return
        ebn = self.cmdForms['pairs'].descr.entryByName
        lc = ebn['newpairs']['widget']
        for refatm, mobatm in map(None, refFiltAtms, mobFiltAtms):
            #self.pairs.append((refatm, mobatm))
            pairName = refatm.full_name() + '---' + mobatm.full_name()
            self.newPairs[pairName]=(refatm,mobatm)
            lc.add((pairName, None))
开发者ID:ruschecker,项目名称:DrugDiscovery-Home,代码行数:29,代码来源:superimposeCommandsNew.py


示例2: filterAcceptors

 def filterAcceptors(self, accAts):
     ntypes = ['Npl', 'Nam']
     npls = accAts.get(lambda x, ntypes=ntypes: x.babel_type=='Npl')
     nams = accAts.get(lambda x, ntypes=ntypes: x.babel_type=='Nam')
     #nAts = accAts.get(lambda x, ntypes=ntypes: x.babel_type in ntypes)
     restAts = accAts.get(lambda x, ntypes=ntypes: x.babel_type not in ntypes)
     if not restAts: restAts = AtomSet([])
     #if nAts:
     if npls:
         #for at in nAts:
         for at in npls:
             s = 0
             for b in at.bonds:
                 if b.bondOrder=='aromatic':
                     s = s + 2
                 else: s = s + b.bondOrder
             #if s<3:
             #apparently this is wrong
             if s<4:
                 restAts.append(at)
     if nams:
         #for at in nAts:
         for at in nams:
             s = 0
             for b in at.bonds:
                 if b.bondOrder=='aromatic':
                     s = s + 2
                 else: s = s + b.bondOrder
                 #s = s + b.bondOrder
             if s<3:
                 restAts.append(at)
     return restAts
开发者ID:Pymol-Scripts,项目名称:Pymol-script-repo,代码行数:32,代码来源:hydrogenBondBuilder.py


示例3: get_atoms

def get_atoms(mol, list_of_indicies, names_to_use=['N','CA','C'], verbose=False):
    if verbose: 
        print "in get_atoms with list of indicies:" 
        print list_of_indicies
    if not len(list_of_indicies):
        raise 'invalid input: list of indicies is empty!'
    atoms = AtomSet()
    num_res = 0
    for item in list_of_indicies:
        first, second = item
        #check for valid index and for end of chain
        max_index = len(mol.chains.residues)-1
        assert first<=max_index, 'invalid start of residue range'
        assert second<=max_index, 'invalid end of residue range'
        assert second>=first, 'second index cannot be smaller than first'
        if second==max_index:
            #ie mol.chains.residues[second]==mol.chains.residues[-1]:
            these_res = mol.chains.residues[first:]
        else:
            these_res = mol.chains.residues[first:second+1]
        if verbose: print "Adding  %3d residues " %(len(these_res)),
        num_res+=len(these_res)
        if verbose: print "Now there are %d residues total" %(num_res)
        for r in these_res:
            for n in names_to_use:
                atoms.append( r.atoms.get(n)[0])
    assert len(atoms), 'invalid input: lists of indicies did not correspond to any residues!'
    if verbose: print 'returning %d atoms' %(len(atoms))
    return atoms
开发者ID:8848,项目名称:Pymol-script-repo,代码行数:29,代码来源:superimpose_based_on_subset.py


示例4: getAtoms

 def getAtoms(self,bnds):
     ats0 = AtomSet()
     for b in bnds:
         ats0.append(b.atom1)
         ats0.append(b.atom2)
     d = {}
     for a in ats0:
         d[a] = 0
     return AtomSet(d.keys())
开发者ID:jackygrahamez,项目名称:DrugDiscovery-Home,代码行数:9,代码来源:bondSelector.py


示例5: doit

 def doit(self, bonds):
     global var
     var=1 
     ats = AtomSet([])
     for bond in bonds:
         ats.append(bond.atom1)
         ats.append(bond.atom2)
         self.vf.removeBonds(bond.atom1, bond.atom2)
     var=0
     self.vf.GUI.VIEWER.Redraw()
开发者ID:jackygrahamez,项目名称:DrugDiscovery-Home,代码行数:10,代码来源:bondsCommands.py


示例6: checkForPossibleH

 def checkForPossibleH(self, ats, blen):
     #@@FIX THIS: WHAT IS THE POINT OF THIS???
     #check that if at has all bonds, at least one is to a hydrogen
     # have to do this by element??
     probAts = AtomSet(ats.get(lambda x, blen=blen: len(x.bonds)==blen))
     #probOAts = ats.get(lambda x, blen=blen: len(x.bonds)==blen)
     #probSAts = ats.get(lambda x, blen=blen: len(x.bonds)==blen)
     if probAts:
         rAts = AtomSet([])
         for at in probAts:
             if not len(at.findHydrogens()):
                 rAts.append(at)
         if len(rAts):
             ats =  ats.subtract(rAts)
     return ats
开发者ID:Pymol-Scripts,项目名称:Pymol-script-repo,代码行数:15,代码来源:hydrogenBondBuilder.py


示例7: setupUndoAfter

 def setupUndoAfter(self, ats, angle,**kw):
     #no atoms, <4 atoms, 
     aSet = AtomSet(self.atomList)
     self.undoMenuString = self.name
     if len(self.atomList)==0:
         undoCmd = 'self.setTorsionGC.atomList=[]; self.setTorsionGC.update()'
     elif len(self.atomList)<4:
         #need to step back here
         undoCmd = 'self.setTorsionGC.atomList=self.setTorsionGC.atomList[:-1]; self.setTorsionGC.update()'
     elif self.origValue==self.oldValue:
         return
     else:
         restoreAngle = self.origValue
         self.undoNow = 1
         undoCmd = 'self.setTorsionGC(\''+ aSet.full_name()+ '\',' + str(restoreAngle) + ', topCommand=0)'
     self.vf.undo.addEntry((undoCmd), (self.name))
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:16,代码来源:setangleCommands.py


示例8: doit

 def doit(self, ats):
     if len(ats)>2:
         if len(self.atomList):
             atSet = ats + self.atomList
         else: atSet = ats
         parent = atSet[0].parent
         parent.buildBondsByDistanceOnAtoms(atSet)
         self.atomList = AtomSet([])
         self.update(True)
     else:
         lenAts = len(self.atomList)
         last = None
         if lenAts:
             last = self.atomList[-1]
             top = self.atomList[0].top
         for at in ats:
             #check for repeats of same atom
             if lenAts and at==last:
                 continue
             #lenAts = len(self.atomList)
             #if lenAts and at==self.atomList[-1]:
             #    continue
             if lenAts and at.top!=self.atomList[-1].top:
                 msg = "intermolecular bond to %s disallowed"%(at.full_name())
                 self.warningMsg(msg)
             self.atomList.append(at)
             self.undoAtList.append(at)
             lenAts = len(self.atomList)
         self.update(True)
         #if only have one atom, there is nothing else to do
         if lenAts<2: return
         #now build bonds between pairs of atoms
         atSet = self.atomList
         if lenAts%2!=0:
             atSet = atSet[:-1]
             #all pairs of atoms will be bonded
             #so keep only the last one
             self.atomList = atSet[-1:]
             lenAts = lenAts -1
         else:
             self.vf.labelByExpression(self.atomList, negate=1, topCommand=0)
             self.atomList = AtomSet([])
         for i in range(0, lenAts, 2):
             at1 = atSet[i]
             at2 = atSet[i+1]
             self.vf.addBonds(at1, at2, origin='UserDefined', topCommand=0)
     self.update(True)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:47,代码来源:bondsCommands.py


示例9: buildCloseContactAtoms

 def buildCloseContactAtoms(self, percentCutoff, ligand, comment="USER AD> "):
     pairDict = self.distanceSelector.select(ligand.allAtoms,
                     self.macro_atoms, percentCutoff=percentCutoff)
     self.pairDict = pairDict
     #reset here
     lig_close_ats = AtomSet()
     macro_close_ats = AtomSet()
     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())
     lig_close_ats = closeAtoms.get(lambda x: x.top==ligand).uniq()
     #ligClAtStr = lig_close_ats.full_name()
     ligClAtStr = comment + "lig_close_ats: %d\n" %( len(lig_close_ats))
     if len(lig_close_ats):
         ligClAtStr += comment + "%s\n" %( lig_close_ats.full_name())
     macro_close_ats = closeAtoms.get(lambda x: x in self.macro_atoms).uniq()
     macroClAtStr = comment + "macro_close_ats: %d\n" %( len(macro_close_ats))
     if len(macro_close_ats):
         macroClAtStr += comment + "%s\n" %( macro_close_ats.full_name())
     #macroClAtStr = "macro_close_ats: " + len(macro_close_ats)+"\n" +macro_close_ats.full_name()
     rdict = self.results
     rdict['lig_close_atoms'] = lig_close_ats
     rdict['macro_close_atoms'] = macro_close_ats
     if self.verbose: print "macroClAtStr=", macroClAtStr
     if self.verbose: print "ligClAtStr=", ligClAtStr
     if self.verbose: print "returning "+ macroClAtStr + '==' + ligClAtStr
     return  macroClAtStr , ligClAtStr
开发者ID:8848,项目名称:Pymol-script-repo,代码行数:32,代码来源:InteractionDetector.py


示例10: set_carbon_names

 def set_carbon_names(self, atoms, type):
     #set carbon names explicitly
     if not atoms or not len(atoms):
         return "ERROR: set_carbon_names called with no atoms"
     assert type in ['C','A']
     if not hasattr(atoms, 'autodock_element'):
         atoms.autodock_element = atoms.element
     changed = AtomSet()
     for at in atoms:
         if at.element!='C': continue
         if at.autodock_element!=type:
             if self.rename:
                 if len(at.name)>1:
                     at.name = type + at.name[1:]
                 else:
                     at.name = type
             at.autodock_element = type
             changed.append(at)
     return changed
开发者ID:8848,项目名称:Pymol-script-repo,代码行数:19,代码来源:atomTypeTools.py


示例11: onRemoveObjectFromViewer

 def onRemoveObjectFromViewer(self, mol):
     lenAts = len(self.atomList)
     #if cmd has no atoms on its list, nothing to do
     if not lenAts:
         return
     #remove any atoms which are being deleted from viewer
     self.atomList = AtomSet(self.atomList) - mol.allAtoms
     #if some have been removed, do an update
     if lenAts!=len(self.atomList):
         self.update()
         self.extslider.set(0)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:11,代码来源:setangleCommands.py


示例12: removeNeighbors

 def removeNeighbors(self, atDict):
     #filter out at-itself and at-bondedat up to 1:4
     #NB keys could be hydrogens OR donors
     for at in atDict.keys():
         closeAts = atDict[at]
         bondedAts = AtomSet([])
         for b in at.bonds:
             ###at2 = b.neighborAtom(at)
             at2 = b.atom1
             if id(at2)==id(at): at2 = b.atom2
             bondedAts.append(at2)
             #9/13 remove this:
             ##also remove 1-3
             for b2 in at2.bonds:
                 at3 = b2.atom1
                 if id(at3)==id(at2): at3 = b.atom2
                 #at3 = b2.neighborAtom(at2)
                 if id(at3)!=id(at):
                     bondedAts.append(at3)
                 #for b3 in at3.bonds:
                     #at4 = b2.neighborAtom(at3)
                     #if at4!=at and at4!=at2:
                         #bondedAts.append(at4)
         bondedAts = bondedAts.uniq()
         goodAts = []
         for i in range(len(closeAts)):
             cAt = closeAts[i]
             if cAt not in bondedAts:
                 goodAts.append(cAt)
         if len(goodAts):
             atDict[at] = goodAts
         else:
             del atDict[at]
     return atDict
开发者ID:Pymol-Scripts,项目名称:Pymol-script-repo,代码行数:34,代码来源:hydrogenBondBuilder.py


示例13: checkAromatics

 def checkAromatics(self):
     """
     checkAromatics
     """
     #this depends on userPref useProteinAromaticList
     if not len(self.cyclebonds):
         self.aromaticCs = AtomSet()
         return ""
     if self.isPeptide and self.useProteinAromaticList:
         self.aromaticCs = self.getPeptideAromatics()
         return ""
     if self.isPeptide:
         self.getPeptideBondDict()
     else:
         self.getLigandBondDict()
     counter = 0
     while counter < self.cyclecount:
         counter = counter + 1
         blist = self.bondDict[counter]
         for item in blist:
             at = item.atom1
             self._getAdjAtom(item, blist)
             #now each bond has 3 atoms specified for it: its own two and the next1 to atom1
             result = self._getNormal(item)
             item.nrmsize = result[0]
             item.nrms = result[1]
             #next find the other bond w/atom2:
             z2 = filter(lambda x,item=item, at2=item.atom2, blist=blist:x!=item and x.atom1==at2 or x.atom2==at2, blist)
             #finally, return the other atom in this bond
             item.nextbond2 = z2[0]
             if item.nextbond2==item:
                 item.nextbond2 = z2[1]
             neighbor2 = self._getnxtAtom(item.atom2,item.nextbond2)
             item.next2 = neighbor2
             #next have to check whether the normals are parallel
             #check each pair in each bond, how to keep track??
             #have to get normal at item's atom2: so have to get next2 for this bond:
         #have to loop twice to make sure neighbor has nrms
         for item in blist:
             p = item.nrms
             psize = item.nrmsize
             q = item.nextbond2.nrms
             qsize = item.nextbond2.nrmsize
             #theta is the critical test for planarity:
             #if angle between 2 nrms is 0, atoms are planar
             #NB>test is comparing theta,cos(angle), w/zero
             item.theta = Numeric.dot(p,q)/(psize*qsize)
             for p in ['next1','next2','nextbond','nextbond2']:
                 delattr(item, p)
     self.updateAromatics(self.aromaticCutOff)
     msg = '    -found '+ str(len(self.aromaticCs)) + ' aromatic carbons\n'
     return  msg
开发者ID:ruschecker,项目名称:DrugDiscovery-Home,代码行数:52,代码来源:LigandMixin.py


示例14: superimpose_cb

 def superimpose_cb(self):
     refAtoms = AtomSet()
     mobAtoms = AtomSet()
     for pair in self.newPairs.values():
         refAtoms.append(pair[0])
         mobAtoms.append(pair[1])
         
     apply( self.doitWrapper, (refAtoms,mobAtoms),  {} )
开发者ID:ruschecker,项目名称:DrugDiscovery-Home,代码行数:8,代码来源:superimposeCommandsNew.py


示例15: buildHydrogenBonds

 def buildHydrogenBonds(self, ligand, comment="USER AD> "):
     h_pairDict = self.hydrogen_bond_builder.build(ligand.allAtoms, self.macro_atoms)
     self.h_pairDict = h_pairDict
     #keys should be from lig, values from macro 
     #sometimes are [email protected]@check [email protected]@
     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
     d = self.results
     macro_hb_ats = d['macro_hb_atoms'] = all_hb_ats.get(lambda x: x.top==self.macro)
     self.macro_hb_ats = macro_hb_ats
     # process lig
     lig_hb_ats = d['lig_hb_atoms'] = all_hb_ats.get(lambda x: x in ligand.allAtoms)
     self.lig_hb_ats = lig_hb_ats
     outS = comment + "lig_hb_atoms : %d\n"%(len(lig_hb_ats))
     for p in self.lig_hb_ats:  #intD.results['lig_hb_atoms']:
         for hb in p.hbonds:
             if hasattr(hb, 'used'): continue
             if hb.hAt is not None:
                 outS += comment + "%s,%s~%s\n"%(hb.donAt.full_name(), hb.hAt.name, hb.accAt.full_name())
             else:
                 outS += comment + "%s~%s\n"%(hb.donAt.full_name(), hb.accAt.full_name())
             hb.used = 1
             #hsg1V:B:ARG8:NH2,HH22~clean: : INI 20:N5
             #clean: : INI 20:O4,H3~hsg1V:B:ASP29:OD2
             #clean: : INI 20:O4,H3~hsg1V:B:ASP29:OD2
             #clean: : INI 20:N4,H3~hsg1V:B:GLY27:O
             #clean: : INI 20:O2,H2~hsg1V:B:ASP25:OD1
     #macroHStr = self.macro.allAtoms.get(lambda x: hasattr(x, 'hbonds') and len(x.hbonds)).full_name()
     #ligHStr = ligand.allAtoms.get(lambda x: hasattr(x, 'hbonds') and len(x.hbonds)).full_name()
     #return  macroHStr + '==' + ligHStr
     if self.verbose: 
         print  "buildHB returning:"
         print outS
     return outS
开发者ID:8848,项目名称:Pymol-script-repo,代码行数:38,代码来源:InteractionDetector.py


示例16: setAromaticCarbons

 def setAromaticCarbons(self, molecule, cutoff=None, debug=False):
     assert len(molecule.allAtoms.bonds[0])
     if cutoff: 
         if cutoff!=self.cutoff:
             old_aromCs = molecule.allAtoms.get(lambda x:\
                             (x.element=='C' and x.autodock_element=='A'))
             if old_aromCs is not None and len(old_aromCs)!=0:
                 if debug: print "resetting ", len(old_aromCs), " prior aromCs"
                 self.set_carbon_names(old_aromCs, 'C')
         self.cutoff = cutoff
     typed_atoms = molecule.allAtoms.get(lambda x: hasattr(x, 'autodock_element'))
     currentAromCs = AtomSet()
     if typed_atoms is not None and len(typed_atoms)==len(molecule.allAtoms):
         currentAromCs = molecule.allAtoms.get(lambda x: (x.element=='C' and x.autodock_element=='A'))
     if debug:
         if currentAromCs is not None and len(currentAromCs):
             print "now: ", len(currentAromCs)
         else:
             print "now: no aromCs"
     aromBnds = self.aromBndSel.select(molecule.allAtoms.bonds[0],
                                               self.cutoff)
     aromBndAts = self.aromBndSel.getAtoms(aromBnds)
     result = AtomSet()
     changed = AtomSet()
     if len(aromBndAts):
         aromCs =  AtomSet(filter(lambda x: x.element=='C', \
                                           aromBndAts))           
         aromCs = aromCs.uniq()
         if len(aromCs)>len(result):
             result = aromCs
         if debug: 
             print "len(aromCs)=", len(aromCs)
         changed = self.set_carbon_names(aromCs, 'A')
     #if len(changed)>len(result):
     #    result = changed
     #return  result
     return changed
开发者ID:8848,项目名称:Pymol-script-repo,代码行数:37,代码来源:atomTypeTools.py


示例17: onRemoveObjectFromViewer

 def onRemoveObjectFromViewer(self, obj):
     removeAts = AtomSet([])
     for at in self.atomList:
         if at in obj.allAtoms:
             removeAts.append(at)
     self.atomList = self.atomList - removeAts
     removeAts = AtomSet([])
     for at in self.undoAtList:
         if at in obj.allAtoms:
             removeAts.append(at)
     self.undoAtList = self.undoAtList - removeAts
     self.update()
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:12,代码来源:bondsCommands.py


示例18: getCations

 def getCations(self, atoms):
     #select atoms in ARG and LYS residues
     arg_cations = atoms.get(lambda x: (x.parent.type=='ARG' and \
                             x.name in ['CZ']))
     lys_cations = atoms.get(lambda x: (x.parent.type=='LYS' and \
                             x.name in ['NZ', 'HZ1', 'HZ2', 'HZ3']))
     #select any positively-charged metal ions... cannot include CA here
     metal_cations = atoms.get(lambda x: x.name in ['Mn','MN', 'Mg',\
                             'MG', 'FE', 'Fe', 'Zn', 'ZN'])
     ca_cations = atoms.get(lambda x: x.name in ['CA', 'Ca'] and x.parent.type=='CA')
     cations = AtomSet() 
     #cations.extend(arg_cations)
     for a in arg_cations:
         cations.append(a)
     #cations.extend(lys_cations)
     for a in lys_cations:
         cations.append(a)
     #cations.extend(metal_cations)
     for a in metal_cations:
         cations.append(a)
     #cations.extend(ca_cations)
     for a in ca_cations:
         cations.append(a)
     return cations
开发者ID:8848,项目名称:Pymol-script-repo,代码行数:24,代码来源:InteractionDetector.py


示例19: getDonors

    def getDonors(self, nodes, paramDict):
        donorList = paramDict['donorTypes']
        #print 'donorList=', donorList
        # currently this is a set of hydrogens
        hats = AtomSet(nodes.get(lambda x: x.element=='H'))
        #hats are optional: if none, process donors
        # if there are hats: dAts are all atoms bonded to all hydrogens
        if hats:
            dAts = AtomSet([])
            for at in hats:
                for b in at.bonds:
                    at2 = b.atom1
                    if id(at2)==id(at): at2 = b.atom2
                    dAts.append(at2)
                    #dAts.append(b.neighborAtom(at))
        else:
            dAts = nodes
        #get the sp2 hybridized possible donors which are all ns
        sp2 = []
        for t in ['Nam', 'Ng+', 'Npl']:
            if t in donorList:
                sp2.append(t)
        #ntypes = ['Nam', 'Ng+', 'Npl']

        sp2DAts = None
        if len(sp2):
            sp2DAts = AtomSet(dAts.get(lambda x, sp2=sp2: x.babel_type in sp2))

        hsp2 = AtomSet([])
        if sp2DAts:
            if hats:
                hsp2 = AtomSet(hats.get(lambda x, sp2DAts=sp2DAts:x.bonds[0].atom1 \
                        in sp2DAts or x.bonds[0].atom2 in sp2DAts))
        if sp2DAts:
            #remove any sp2 N atoms which already have 3 bonds not to hydrogens
            n2Dons = AtomSet(sp2DAts.get(lambda x: x.element=='N'))
            if n2Dons:
                n2Dons.bl=0
                for at in n2Dons:
                    for b in at.bonds:
                        if type(b.bondOrder)==type(2):
                            at.bl = at.bl + b.bondOrder
                        else:
                            at.bl = at.bl + 2
                        #allow that there might already be a hydrogen
                    nH = at.findHydrogens()
                    at.bl = at.bl - len(nH)
                badAts = AtomSet(n2Dons.get(lambda x: x.bl>2))
                if badAts:
                    sp2DAts = sp2DAts - badAts
                delattr(n2Dons,'bl')
        #get the sp3 hybridized possible donors
        sp3 = []
        for t in ['N3+', 'S3', 'O3']:
            if t in donorList:
                sp3.append(t)
        n3DAts = None
        if 'N3+' in sp3:
            n3DAts = AtomSet(dAts.get(lambda x: x.babel_type=='N3+'))
        o3DAts = None
        if 'O3' in sp3:
            o3DAts = AtomSet(dAts.get(lambda x: x.babel_type=='O3'))
        if o3DAts:
            #remove any O3 atoms which already have 2 bonds not to hydrogens
            badO3s = AtomSet([])
            for at in o3DAts:
                if len(at.bonds)<2: continue
                if len(at.findHydrogens()): continue
                else:
                    badO3s.append(at)
            if len(badO3s):
                o3DAts = o3DAts - badO3s
        s3DAts = None
        if 'S3' in sp3:
            s3DAts = AtomSet(dAts.get(lambda x: x.babel_type=='S3'))
        sp3DAts = AtomSet([])
        for item in [n3DAts, o3DAts, s3DAts]:
            if item:
                sp3DAts = sp3DAts + item
        hsp3 = AtomSet([])
        if sp3DAts:
            if hats:
                hsp3 = AtomSet(hats.get(lambda x, sp3DAts=sp3DAts:x.bonds[0].atom1 \
                    in sp3DAts or x.bonds[0].atom2 in sp3DAts))
        hsp = hsp2 + hsp3
        #print 'hsp=', hsp.name
        #print 'sp2DAts=', sp2DAts.name
        #print 'sp3DAts=', sp3DAts.name
        return hsp, sp2DAts, sp3DAts
开发者ID:Pymol-Scripts,项目名称:Pymol-script-repo,代码行数:89,代码来源:hydrogenBondBuilder.py


示例20: AddBondsGUICommand

class AddBondsGUICommand(MVCommand, MVAtomICOM):
    """
    The AddBondGUICommand provides an interactive way of creating bonds between two given atoms by picking on them. To use this command you need first to load it into PMV. Then you can find the entry 'addBonds' under the Edit menu. To add bonds  you just need to pick on the 2 atoms you want to bind. If you drag select  a bunch of atoms, the command will buildBondsByDistance between them.This command is undoable.
   \nPackage : Pmv
   \nModule  : bondsCommands
   \nClass   : AddBondsGUICommand
   \nCommand : addBondsGC
   \nSynopsis:\n
        None<-addBondsGC(atoms)\n
    \nRequired Arguments:\n    
        atoms  : atom(s)\n
    """
    
    def __init__(self, func=None):
        MVCommand.__init__(self, func)
        MVAtomICOM.__init__(self)
        self.atomList = AtomSet([])
        self.undoAtList = AtomSet([])
        self.labelStrs = []


    def onRemoveObjectFromViewer(self, obj):
        removeAts = AtomSet([])
        for at in self.atomList:
            if at in obj.allAtoms:
                removeAts.append(at)
        self.atomList = self.atomList - removeAts
        removeAts = AtomSet([])
        for at in self.undoAtList:
            if at in obj.allAtoms:
                removeAts.append(at)
        self.undoAtList = self.undoAtList - removeAts
        self.update()

       
    def onAddCmdToViewer(self):
        if not self.vf.commands.has_key('setICOM'):
            self.vf.loadCommand('interactiveCommands', 'setICOM', 'Pmv',
                                topCommand=0) 
        if not self.vf.commands.has_key('addBonds'):
            self.vf.loadCommand('bondsCommands', 'addBonds', 'Pmv',
                                topCommand=0) 
        if not self.vf.commands.has_key('removeBondsGC'):
            self.vf.loadCommand('bondsCommands', 'removeBondsGC', 'Pmv',
                                topCommand=0) 
        self.masterGeom = Geom('addBondsGeom',shape=(0,0), 
                               pickable=0, protected=True)
        self.masterGeom.isScalable = 0
        self.spheres = Spheres(name='addBondsSpheres', shape=(0,3),
                               inheritMaterial=0,
                               radii=0.2, quality=15,
                               materials = ((1.,1.,0.),), protected=True) 
        if not self.vf.commands.has_key('labelByExpression'):
            self.vf.loadCommand('labelCommands', 
                                ['labelByExpression',], 'Pmv', topCommand=0)
        if self.vf.hasGui:
            miscGeom = self.vf.GUI.miscGeom
            self.vf.GUI.VIEWER.AddObject(self.masterGeom, parent=miscGeom)
            self.vf.GUI.VIEWER.AddObject(self.spheres, parent=self.masterGeom)


    def __call__(self, atoms, **kw):
        """None<-addBondsGC(atoms)
           \natoms  : atom(s)"""
        if type(atoms) is StringType:
            self.nodeLogString = "'"+atoms+"'"
        ats = self.vf.expandNodes(atoms)
        if not len(ats): return 'ERROR'
        return apply(self.doitWrapper, (ats,), kw)


    def doit(self, ats):
        if len(ats)>2:
            if len(self.atomList):
                atSet = ats + self.atomList
            else: atSet = ats
            parent = atSet[0].parent
            parent.buildBondsByDistanceOnAtoms(atSet)
            self.atomList = AtomSet([])
            self.update(True)
        else:
            lenAts = len(self.atomList)
            last = None
            if lenAts:
                last = self.atomList[-1]
                top = self.atomList[0].top
            for at in ats:
                #check for repeats of same atom
                if lenAts and at==last:
                    continue
                #lenAts = len(self.atomList)
                #if lenAts and at==self.atomList[-1]:
                #    continue
                if lenAts and at.top!=self.atomList[-1].top:
                    msg = "intermolecular bond to %s disallowed"%(at.full_name())
                    self.warningMsg(msg)
                self.atomList.append(at)
                self.undoAtList.append(at)
                lenAts = len(self.atomList)
            self.update(True)
#.........这里部分代码省略.........
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:101,代码来源:bondsCommands.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python stringSelector.CompoundStringSelector类代码示例发布时间:2022-05-24
下一篇:
Python MolKit.Read类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap