Exemplo n.º 1
0
 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 list(pairDict.items()):
         if len(v):
             cdict[k] = 1
         for at in v:
             if at not in macro_close_ats:
                 cdict[at] = 1
     closeAtoms = AtomSet(list(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
    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))
Exemplo n.º 3
0
    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))
Exemplo n.º 4
0
 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
 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 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
     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
Exemplo n.º 6
0
 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 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
     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
Exemplo n.º 7
0
    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
    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