mgltools-pybabel-1.5.7~rc1~cvs.20130519/0000755000175000017500000000000012146213334016646 5ustar debiandebianmgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/0000755000175000017500000000000012146213337020167 5ustar debiandebianmgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/atomTypes.py0000644000175000017500000005003712040275515022532 0ustar debiandebian############################################################################# # # Author: Michel F. SANNER # Reimplemented from Babel v1.6 from Pat Walters and Math Stahl # # Copyright: M. Sanner TSRI 2000 # ############################################################################# # # $Header: /opt/cvs/python/packages/share1.5/PyBabel/atomTypes.py,v 1.6 2012/10/19 16:09:49 rhuey Exp $ # # $Id: atomTypes.py,v 1.6 2012/10/19 16:09:49 rhuey Exp $ # """ This file implements the AtomHybridization class that can be used to assign atom types. example: >>> atype = AtomHybridization() >>> atype.assignHybridization(atoms) atoms has to be a list of atom objects Atom: a.element : atom's chemical element symbol (string) a.coords : 3-sequence of floats a.bonds : list of Bond objects Bond: b.atom1 : instance of Atom b.atom2 : instance of Atom after completion each atom has the following additional members: babel_type: string babel_atomic_number: int babel_organic reimplmentation of Babel1.6 in Python by Michel Sanner April 2000 Original code by W. Patrick Walters and Matthew T. Stahl """ import string from babelAtomTypes import babel_types from babelElements import babel_elements from util import * # for valence_three SP3_MAX = 114.8 MAY_BE_SP2 = 122.0 SP_MIN = 160.0 # for valence_one V1_C1_C1_CUTOFF = 1.22 V1_C2_C_CUTOFF = 1.41 V1_C2_N_CUTOFF = 1.37 V1_N1_C1_CUTOFF = 1.20 V1_N3_C_CUTOFF = 1.38 V1_N3_N3_CUTOFF = 1.43 V1_N3_N2_CUTOFF = 1.41 V1_O2_C2_CUTOFF = 1.30 V1_O2_AS_CUTOFF = 1.685 V1_S2_C2_CUTOFF = 1.76 V1_S2_AS_CUTOFF = 2.11 V2_C3_C_CUTOFF = 1.53 V2_C3_N_CUTOFF = 1.46 V2_C3_O_CUTOFF = 1.44 V2_N2_C_CUTOFF = 1.38 V2_N2_N_CUTOFF = 1.32 V2_C2_C_CUTOFF = 1.42 V2_C2_N_CUTOFF = 1.41 GEN_C3_C_CUTOFF = 1.45 class AtomHybridization: def __init__(self): """constructor""" self.atoms = None def get_atomic_number(self, name): """return the element number for a given name or raises a ValueError exception if the element is not known""" _name = string.upper(name[0]) if len(name)>1: if not name[1] in string.digits: _name = _name + string.lower(name[1]) if _name in babel_elements.keys(): return babel_elements[_name]['num'] else: raise ValueError( "Could not find atomic number for %s %s"% \ (name,_name) ) def assignHybridization(self, atoms): """atoms is a list of objects of type Atom having the following members: Atom: a.element : atom's chemical element symbol (string) a.coords : 3-sequence of floats a.bonds : list of Bond objects Bond: b.atom1 : instance of Atom b.atom2 : instance of Atom after completion each atom has the following additional members: babel_type: string babel_atomic_number: int babel_organic """ self.atoms = atoms for a in self.atoms: a.babel_type = a.element a._babel_redo = 0 a.babel_atomic_number = self.get_atomic_number(a.babel_type) if a.babel_type[0] in [ 'C', 'H', 'O', 'N', 'S', 'P' ]: a.babel_organic=1 else: a.babel_organic = 0 if a.element=='Ca': a.babel_organic = 0 self.phase1() self.valence_four() self.valence_three() self.valence_two() self.valence_one() self.phase4() self.phase5() self.phase6() self.check_for_amides() # cleanup for a in self.atoms: delattr(a,'_babel_redo') delattr(self,'atoms') def count_heavy_atoms(self, atom): count = 0 for b in atom.bonds: bonded_atom = b.atom1 if bonded_atom==atom: bonded_atom=b.atom2 if bonded_atom.babel_type[0] == 'H': count = count + 1 return len(atom.bonds) - count def count_free_ox(self, atom): free_O_count=0 for b in atom.bonds: bonded_atom = b.atom1 if bonded_atom==atom: bonded_atom=b.atom2 if bonded_atom.babel_type[0] == 'O' and \ self.count_heavy_atoms(bonded_atom) == 1: free_O_count = free_O_count+1 return free_O_count def phase1(self): for a in self.atoms: if a.babel_type[0] == 'H': a.babel_type = 'H' if len(a.bonds): k = a.bonds[0].atom1 if k==a: k = a.bonds[0].atom2 if k.babel_type[0] == 'C' and k.element == 'C': a.babel_type = 'HC' def valence_four(self): for a in self.atoms: if len(a.bonds) == 4 and a.babel_organic: if a.babel_type[0] == 'C' and a.element == 'C': if a.babel_type=='C': a.babel_type = "C3" elif a.babel_type[0] == 'N': if self.count_free_ox(a) >= 1: a.babel_type = "Nox" else: a.babel_type = "N3+" elif a.babel_type[0] == 'P': if len(a.babel_type) == 1: count = self.count_free_ox(a) if count >= 2: a.babel_type = "Pac" elif count == 1: a.babel_type = "Pox" else: a.babel_type = "P3+" elif a.babel_type[0] == 'S': if a.babel_type=='S': count = self.count_free_ox(a) if count >= 3: a.babel_type = "Sac" elif count >= 1: a.babel_type = "Sox" else: a.babel_type = "S" elif a.babel_type[0] == 'B': count = self.count_free_ox(a) if count >= 3: a.babel_type = "Bac" if count >= 1: a.babel_type = "Box" else: a.babel_type = "B" def valence_three(self): for a in self.atoms: if len(a.bonds) == 3 and a.babel_organic: k = a.bonds[0].atom1 if k==a: k = a.bonds[0].atom2 l = a.bonds[1].atom1 if l==a: l = a.bonds[1].atom2 m = a.bonds[2].atom1 if m==a: m = a.bonds[2].atom2 angle1 = bond_angle(k.coords, a.coords, l.coords) angle2 = bond_angle(k.coords, a.coords, m.coords) angle3 = bond_angle(l.coords, a.coords, m.coords) avg_angle = (angle1 + angle2 + angle3)/3 if a.babel_type[0] =='C' and a.element == 'C': if avg_angle < SP3_MAX: a.babel_type="C3" elif self.count_free_ox(a) >= 2: a.babel_type="Cac" else: a.babel_type = "C2" elif a.babel_type[0] =='N': if avg_angle < SP3_MAX: a.babel_type = "N3" elif self.count_free_ox(a) >= 2: a.babel_type = "Ntr" else: a.babel_type = "Npl" elif a.babel_type[0] =='B': if self.count_free_ox(a) >= 1: a.babel_type = "Box" else: a.babel_type = "B" elif a.babel_type =='S': if self.count_free_ox(a) >= 1: a.babel_type = "Sox" else: a.babel_type = "S3+" def valence_two(self): for a in self.atoms: if len(a.bonds) == 2 and a.babel_organic: k = a.bonds[0].atom1 if k==a: k = a.bonds[0].atom2 l = a.bonds[1].atom1 if l==a: l = a.bonds[1].atom2 if a.coords[0]==l.coords[0] and a.coords[1]==l.coords[1] and a.coords[2]==l.coords[2]: print a.full_name() +" and " +l.full_name() +" have the same coordinates" angle1 = bond_angle(k.coords, a.coords, l.coords) if a.babel_type[0] == 'C' and a.element == 'C': if a.babel_type =="C": if angle1 < SP3_MAX: a.babel_type = "C3" a._babel_redo = 1 elif angle1 < SP_MIN: a.babel_type = "C2" if angle1 < MAY_BE_SP2: a._babel_redo = 3 else: a.babel_type = "C1" elif a.babel_type[0] == 'N': if angle1 <= SP3_MAX: a.babel_type = "N3" a._babel_redo = 2 elif angle1 <= SP_MIN: a.babel_type = "Npl" else: a.babel_type = "N1" elif a.babel_type[0] == 'O': a.babel_type = "O3" elif a.babel_type[0] == 'S': if a.babel_type =="S": a.babel_type = "S3" def valence_one(self): for a in self.atoms: if len(a.bonds) == 1 and a.babel_organic: k = a.bonds[0].atom1 if k==a: k = a.bonds[0].atom2 bond_length = distance(a.coords, k.coords) if a.babel_type[0] == 'C' and a.element == 'C': if a.babel_type=="C": if k.babel_type[:2]=='C1' and \ bond_length <= V1_C1_C1_CUTOFF: a.babel_type = "C1" elif k.babel_type[0] == "C" and \ bond_length <= V1_C2_C_CUTOFF: a.babel_type = "C2" else: a.babel_type = "C3" if k.babel_type[0]=="N": if bond_length <= V1_C2_N_CUTOFF: a.babel_type = "C2" else: a.babel_type = "C3" if a.babel_type[0] == 'N': if a.babel_type=="N": if k.babel_type[:2]=='C1' and \ bond_length <= V1_N1_C1_CUTOFF: a.babel_type = "N1" elif (k.babel_type[:2] == "C2" or \ k.babel_type[:2] == "C3") \ and bond_length > V1_N3_C_CUTOFF: a.babel_type = "N3" elif a.babel_type[:2]== "N3" and \ bond_length > V1_N3_N3_CUTOFF: a.babel_type = "N3" elif a.babel_type[:2]== "Npl" and \ bond_length > V1_N3_N2_CUTOFF: a.babel_type = "N3" else: a.babel_type = "Npl" if a.babel_type[0] == 'O': if a.babel_type=="O": if k.babel_type in ["Cac", "Pac", "Sac", "Ntr"]: a.babel_type = "O-" elif k.babel_type in ["Nox", "Pox", "Sox"]: a.babel_type = "O2" elif k.babel_type[0] =="C" and \ bond_length <= V1_O2_C2_CUTOFF: a.babel_type = "O2" k.babel_type = "C2" k._babel_redo = 0 elif k.babel_type=="As" and \ bond_length <= V1_O2_AS_CUTOFF: a.babel_type = "O2" else: a.babel_type = "O3" if a.babel_type[0] == 'S': if a.babel_type=="S": if k.babel_type[0] =="P": a.babel_type = "S2" elif k.babel_type[0]=="C" and \ bond_length <= V1_S2_C2_CUTOFF: a.babel_type = "S2" k.babel_type = "C2" a._babel_redo = 0 elif k.babel_type=="As" and \ bond_length <= V1_S2_AS_CUTOFF: a.babel_type = "S2" else: a.babel_type = "S3" def phase4(self): for a in self.atoms: if a._babel_redo==1: for b in a.bonds: j = b.atom1 if j==a: j = b.atom2 bond_length = distance(a.coords, j.coords) if bond_length <= V2_C2_C_CUTOFF and j.babel_type[0] == 'C' and j.element == 'C': a.babel_type = "C2" elif bond_length <= V2_C2_N_CUTOFF and j.babel_type[0] =='N': a.babel_type = "C2" for b in a.bonds: j = b.atom1 if j==a: j = b.atom2 bond_length = distance(a.coords, j.coords) if bond_length > V2_C3_C_CUTOFF and j.babel_type[0] == 'C' and j.element == 'C': a.babel_type = "C3" elif bond_length > V2_C3_N_CUTOFF and j.babel_type[0] == 'N': a.babel_type = "C3" elif bond_length > V2_C3_O_CUTOFF and j.babel_type[0] == 'O': a.babel_type = "C3" elif a._babel_redo==2: for b in a.bonds: j = b.atom1 if j==a: j = b.atom2 bond_length = distance(a.coords, j.coords) if bond_length <= V2_N2_C_CUTOFF and j.babel_type[0] == 'C' and j.element == 'C': a.babel_type = "Npl" elif bond_length <= V2_N2_N_CUTOFF and j.babel_type[0] =='N': a.babel_type = "Npl" elif a._babel_redo==3: flag = 0 for b in a.bonds: j = b.atom1 if j==a: j = b.atom2 bond_length = distance(a.coords, j.coords) if bond_length <= V2_C2_C_CUTOFF and j.babel_type[0] == 'C' and j.element == 'C': a.babel_type = "C2" flag = 1 elif bond_length <= V2_C2_N_CUTOFF and j.babel_type[0] =='N': a.babel_type = "C2" flag = 1 if flag == 0: for b in a.bonds: j = b.atom1 if j==a: j = b.atom2 bond_length = distance(a.coords, j.coords) if bond_length > V2_C3_C_CUTOFF and j.babel_type[0]=='C' and j.element == 'C': a.babel_type = "C3" flag = 1 elif bond_length>V2_C3_N_CUTOFF and j.babel_type[0]=='N': a.babel_type = "C3" flag = 1 elif bond_length>V2_C3_O_CUTOFF and j.babel_type[0]=='O': a.babel_type = "C3" flag = 1 elif flag == 0: if bond_length > GEN_C3_C_CUTOFF and \ j.babel_type[0] == 'C' and j.element == 'C': a.babel_type = "C3" flag = 1 def phase5(self): for a in self.atoms: if a.babel_type == "C2": flag = 0; for b in a.bonds: j = b.atom1 if j==a: j = b.atom2 if not j.babel_type in ["C3", "DC", "HC", "N3", "N3+", "O3"] and\ not j.babel_type in ["Pac", "Sac", "Sox", "C1", "S3", "Cac" ]: flag = 1 if flag == 0: a.babel_type = "C3" def phase6(self): for a in self.atoms: no_plus = 1 protonated = 1 if a.babel_type=="N3": for b in a.bonds: conn = b.atom1 if conn==a: conn = b.atom2 # If an unsaturated atom is attached to this nitrogen then # it should be Npl if len(a.bonds) == 2 and \ conn.babel_type in ["Car","C2","Sox","Sac","Pac","So2"]: protonated = 0 a.babel_type = "Npl" # If the attached atom is something other that C3, # H or D the nitrogen is not positively charged if conn.babel_type != "C3" and conn.babel_atomic_number != 1: protonated = 0 if protonated: a.babel_type = "N3+" # look for guanadinium nitrogens elif a.babel_type == "C2": # First see if we have an sp2 carbon surrounded by 3 sp2 # nitrogens m = 0; for b in a.bonds: k = b.atom1 if k==a: k = b.atom2 if k.babel_type=="Npl" or k.babel_type=="N2" or k.babel_type=="Ng+": m=m+1 if m == 3: a.babel_type = "C+" for b in a.bonds: k = b.atom1 if k==a: k = b.atom2 k.babel_type = "Ng+" elif a.babel_type == "Cac": for b in a.bonds: k = b.atom1 if k==a: k = b.atom2 if k.babel_type[0]=="O" and self.count_heavy_atoms(k) == 1: k.babel_type = "O-" def check_for_carbonyl(self, atom): for b in atom.bonds: bonded_atom = b.atom1 if bonded_atom==atom: bonded_atom = b.atom2 if bonded_atom.babel_type=="O2" or bonded_atom.babel_type=="S2": return 3 return 2 def check_for_amides(self): for a in self.atoms: if a.babel_type=="Npl": for b in a.bonds: conn = b.atom1 if conn==a: conn = b.atom2 if conn.babel_type=="Cac" or conn.babel_type=="Sox" or \ conn.babel_type=="So2": a.babel_type = "Nam" break if conn.babel_type=="C2": if self.check_for_carbonyl(conn) == 3: a.babel_type = "Nam" break def getProperty(self, property, elements): """list <- getProperty(property, elements) property has to be 'num', 'cov_rad', 'bond_ord_rad', 'vdw_rad', 'bs_rad', 'max_bonds' or 'rgb' elements is a list of 1 or 2 character(s) strings """ if property not in babel_elements["C"].keys(): raise RuntimeError("Invalid property %s, has to be in %s\n" % \ (property, babel_elements["C"].keys())) prop = [] for el in elements: prop.append(babel_elements[el][property]) return prop class TypeConverter: def __init__(self, outputType): if outputType not in babel_types.keys(): raise RuntimeError("Invalid format %s\n"%outputType) self.outputType = outputType def convert(self, input, mode='all_caps'): try: i = babel_types['INT'].index(input) return babel_types[self.outputType][i] except: print "Unable to assign %s type to atom %s"%(self.outputType,input) if mode=='zero': return 0 elif mode=='dummy': i = babel_types['INT'].index("X") return babel_types[self.outputType][i] elif mode=='all_caps': return string.upper(input) else: return input def clean_atom_type(self, type_name): name = string.upper(type_name[0]) if len(type_name) > 1: name = name + string.lower(type_name[1]) if name[1] not in string.letters: return name[0] return name if __name__ == '__main__': import pdb, sys from cycle import RingFinder from bo import BondOrder from aromatic import Aromatic from MolKit.pdbParser import NewPdbParser parser = NewPdbParser("/tsri/pdb/struct/%s.pdb"%sys.argv[1]) mols = parser.parse() mol = mols[0] mol.buildBondsByDistance() allAtoms = mol.chains.residues.atoms bonds = allAtoms.bonds[0] print "assigning atom types" babel = AtomHybridization() babel.assignHybridization(allAtoms) mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/cycle.py0000644000175000017500000005756707725750224021674 0ustar debiandebian############################################################################ # # Author: Michel F. SANNER # Reimplemented from Babel v1.6 from Pat Walters and Math Stahl # # Copyright: M. Sanner TSRI 2000 # ############################################################################# # # $Id: cycle.py,v 1.8 2003/09/04 23:53:56 lindy Exp $ # """ This file implements the RingFinder class that can be used to identify rings in molecules. When rings are nested the smalest rings are reported. The algorithms in here are different from thoses in Babel1.6. They might fail to report all rings for rings in which any atom of a ring belongs also to more than 1 ring. findRings2 is more robust and should reports all the smallest cycles. It is more expansive too. Should be used for small molecules example: >>> r = RingFinder() >>> r.findRings2(atoms, bonds) >>> r.printRings() atoms has to be a list of Atom objects Atom: a.coords : 3-sequence of floats a.bonds : list of Bond objects Bond: b.atom1 : instance of Atom b.atom2 : instance of Atom after completion the RingFinder object has the following members: ringCount: number of rings rings : a list of rings. A ring is a dictionary with 2 keys 'atoms' and 'bonds'. The atoms in rings['atoms'] are ordered along the cycle. allRingAtoms: list of atoms that are in rings(atoms may appear twice) allRingBonds: list of bonds that are in rings(bonds may appear twice) In addition: atoms involved in rings have a member 'rings' that is a list of rings they belong to (0-based list of integers) Michel Sanner April 2000 """ class RingFinder: """ """ def __init__(self): """ """ self.num = 0 self.rings = [] def tagOneAtomBond(self, atom, inbond): # tag all bond that cannot be in a ring by adding them as keys to # self.bondInCycle[bond], value is set to 2 (no particular meaning) # since findRings2 will oly consider atoms for which at least one # bond is not yet in a cycle, pretending that the only bond to an # atom is already in a cycle will pevent it from being considered if len(atom.bonds)==1: bond = atom.bonds[0] self.bondInCycle[bond] = 2 #print 'REMOVE ',atom.name,bond.atom1.name,'-',bond.atom2.name if bond!=inbond: atom2 = bond.atom1 if atom2==atom: atom2=bond.atom2 self.tagOneAtomBond(atom2, bond) else: num = 0 for b in atom.bonds: if not self.bondInCycle.has_key(b): num = num + 1 bond = b if num == 1: #print 'REMOVE ',atom.name,bond.atom1.name,'-',bond.atom2.name self.bondInCycle[bond] = 2 atom2 = bond.atom1 if atom2==atom: atom2=bond.atom2 self.tagOneAtomBond(atom2, bond) def findRings2(self, atoms, bonds, maxSize=20): # EXPANSIVE but robust # for each atom for which at least one bond is not yet in a cycle # find the smallest cycle. Then check if the cycle is already known # if maxSize is specified, only ring of size maxSize will be found self.bondInCycle = {} # key is bond, is created when bond has been # traversed (persistant across search over atoms self._rings = [] # dict. with atoms as keys per cycle self.allRingAtoms = {} # dict with keys being all atoms in cycles self.allRingBonds = {} # dict with keys being all bonds in cycles self.ringCount = 0 # number of cycles maxLevel = maxSize/2 + 1 # tag all bonds that cannot be in cycles, i.e. they connect an atom # having only 1 neighbor (recursively) #for a in atoms: # self.tagOneAtomBond(a, None) # loop over all atoms for a in atoms: # being in a cycle requires at least 2 neighbors if len(a.bonds)==1: continue # count number of bond already in cycles or connecting # to an leaf atom (i.e. atom with only 1 neighbor) num = 0 for b in a.bonds: atom2 = b.atom1 if atom2==a: atom2=b.atom2 if len(atom2.bonds)==1 or self.bondInCycle.has_key(b): num = num + 1 # if at least on bond not in a cycle find smallest cycle for a if num < len(a.bonds): #print 'Find smallest Ring for', a.name, num, len(a.bonds) # ra is a list of atoms in cycle # rb is a list of bonds in cycle #print 'Find smallest cycle for', a.name ra, rb = self.findSmallestRing(a, maxLevel) #print 'Found cycle:', ra # check is that cycle has been found before if len(ra): same = 0 for r in self._rings: if len(ra)==len(r): same = 1 for a in ra: if not r.has_key(a): same = 0 break if same==1: break # if it hasn't be found before, add it if not same: # atoms in ra have to be sorted along the cycle ras = [ra[0]] # Take all odds first going trough list toward end for i in range(1, len(ra), 2): ras.append(ra[i]) # take all even going through list backwards and # starting a last of cycles woth even number of atoms # and one before last of rinfs with odd number of at. l = len(ra) if (l/2*2) != l: end = l-1 # odd -> skip last else: end = l-2 # end, use last for i in range(end, 1, -2): ras.append(ra[i]) ra = ras # build the dict of atoms for that cycle d = {} ringnum = len(self._rings) for a in ra: d[a] = 1 if not hasattr(a, 'rings'): a.rings = [ringnum] else: a.rings.append(ringnum) # add it to _rings self._rings.append(d) # add the cycle to self.rings self.rings.append( {'atoms':ra, 'bonds':rb } ) # update dict of all atoms in cycles self.allRingAtoms.update(d) # update dict of all bonds in cycles for b in rb: self.allRingBonds[b] = 1 # increment cycl counter self.ringCount = self.ringCount + 1 ## print 'RING ======================' ## for a in ra: ## print a.name ## for b in rb: ## print b.atom1.name,'-',b.atom2.name ## print 'END RING ======================' self.allRingAtoms = self.allRingAtoms.keys() self.allRingBonds = self.allRingBonds.keys() def findSmallestRing(self, root, maxLevel): # each new generation adds a level in the width first traversal level = 0 # each level has a stack of atoms stacks = [] # each level has a dict of atom:bond telling through which bond we # came to this atom bndDicts = [] # dict of atoms used to check if an atom has been seen before atinstack = {} # dict of bonds used to check if a bond has been seen before bondseen = {} # bond through which we came (None for root) bond = None atinstack[root] = 1 # list of atoms a this level levelstack = [] stacks.append(levelstack) # dict of atom:bond for this level levelDict = {} bndDicts.append(levelDict) # add children of root to this level's stack and dict for b in root.bonds: bondseen[bond] = 1 atom2 = b.atom1 if atom2==root: atom2 = b.atom2 if len(atom2.bonds)>1: #print 'adding to stack 0', atom2.name levelDict[atom2] = b levelstack.append(atom2) atinstack[atom2] = 1 maxLen = len(levelstack) # number of bonds with level 0 stackPtr = 0 # width first traversal, i.e. loop over stack adding levels while stackPtr < maxLen: # add a level levelstack = [] stacks.append(levelstack) levelDict = {} bndDicts.append(levelDict) #print "Looping over LEVEL: ", level # loop over atoms at this level for levelroot in stacks[level]: ## if len(levelroot.bonds)==1: ## continue # find bond through with we came to levelroot atom bond = bndDicts[level][levelroot] # if already seen get next level root ## if bondseen.has_key(bond): ## continue ## if len(bond.atom1.bonds)==1 or len(bond.atom2.bonds)==1: ## continue # this bond cannot be in a cycle ## if self.bondInCycle.has_key(bond) and \ ## self.bondInCycle[bond]==2: ## continue # else make this bond as seen bondseen[bond] = 1 #print 'level ROOT', levelroot.name, bond, atinstack.has_key(levelroot) # add children of levelroot to the current level for b in levelroot.bonds: # except for the parent of levelroot if b is bond: continue atom2 = b.atom1 if atom2==levelroot: atom2 = b.atom2 if len(atom2.bonds)==1: continue #print levelroot.name, atom2.name # if the child of levelroot is instack we found a cycle # so we start back tracking from both sides through the # levels until we reach a common atom. If that atom is # root we have the smallest cycle for root, else we # continue # 2 cases are possible: either we have a even or an odd # number of atoms in the cycle. For even numbers atom2 # is found in atinstack which is associated with this # level. else atom2 should be found in # bndDicts[level] if atinstack.has_key(atom2): #print 'CYCLE', atom2.name # even number of atoms #print 'instack' #for a in atinstack: # print a.name if levelDict.has_key(atom2): #print 'EVEN ******************' # cycle with even number of atoms # b1 is the bond from which we arrived at atom2 # previousely at this level b1 = levelDict[atom2] at1 = levelroot at2 = b1.atom1 if at2==atom2: at2 = b1.atom2 #print 'ringAtoms1', atom2.name, at1.name, at2.name ringAtoms = [atom2, at1, at2] ringBonds = [b, b1] # backtrack through level elif bndDicts[level].has_key(atom2): # odd number of atoms in cycle # b1 is the bond from which we arrived at atom2 # previousely at this level #print 'ODD ******************' at1 = levelroot at2 = atom2 #print 'ringAtoms2', at1.name, at2.name ringAtoms = [at1, at2] ringBonds = [b] else: continue # backtrack for i in range(level,-1,-1): #print 'level:', i b1 = bndDicts[i][at1] other1 = b1.atom1 if other1==at1: other1 = b1.atom2 #print other1.name b2 = bndDicts[i][at2] other2 = b2.atom1 if other2==at2: other2 = b2.atom2 #print other2.name at1 = other1 at2 = other2 ringBonds.append(b1) ringBonds.append(b2) ringAtoms.append(other1) if other1!=other2: ringAtoms.append(other2) else: break if other1==root or other2==root: for b in ringBonds: self.bondInCycle[b] = 1 return (ringAtoms, ringBonds) else: #print 'adding to stack', atom2.name, len(levelstack) levelstack.append(atom2) levelDict[atom2] = b atinstack[atom2] = 1 level = level + 1 if level==maxLevel: return [],[] maxLen = maxLen + len(levelstack) stackPtr = stackPtr + 1 return [],[] def backtrack(self, atom1, atom2, b): """go up ancestor tree until first common parent is found""" ringAtoms = [ atom2 ] ringbonds = [ b ] b._ring_seen = 1 while atom1!=atom2: ringAtoms.append( atom1 ) ringbonds.append( atom1._ring_ancestor_bond ) atom1 = atom1._ring_ancestor return { 'atoms':ringAtoms, 'bonds':ringbonds } def tag_neighbors(self, atom1, bond): """ """ atom2 = bond.atom1 if atom2==atom1: atom2 = bond.atom2 #print 'atom2', atom2.name, bond if hasattr(atom2,'_ring_ancestor'): self._rings.append( self.backtrack(atom1, atom2, bond) ) #print '\n********************* ring found' #for a in self._rings[-1]['atoms']: #print a.name return atom2._ring_ancestor = atom1 atom2._ring_ancestor_bond = bond bond._ring_seen = 1 for b in atom2.bonds: #FIXME: we are supposed to skip di-sulfite bridges here if hasattr(b, '_ring_seen') and b._ring_seen: continue self.tag_neighbors( atom2, b ) #print 'step back from', atom2.name, bond def findRings(self, atoms, bonds): """method to find cycles in molecules, first we simply tag all atoms and bonds in rings using a depth first traversal then we call checkRings for identifying the smallest cycles when fused rings are present """ i = 0 for b in bonds: b._ring_seen = 0 self._rings = [] # first try with leaf atoms (i.e only 1 neighbor) done = 0 for a in atoms: if len(a.bonds)==1: a._ring_ancestor = None a._ring_ancestor_bond = None #print 'start at ',a, a.bonds[0] self.tag_neighbors(a, a.bonds[0]) done = 1 break #print 'AAAA', done # for molecules with all atoms in cycles we did not find a leaf if not done: for a in atoms: if not hasattr(a, '_ring_ancestor'): l = len(a.bonds) if l==2: atom_before = a.bonds[0].atom1 if atom_before==a: atom_before=a.bonds[0].atom2 a._ring_ancestor = atom_before a._ring_ancestor_bond = a.bonds[0] self.tag_neighbors(a, a.bonds[1]) if a.bonds[0]._ring_seen: continue atom_before = a.bonds[1].atom1 if atom_before==a: atom_before=a.bonds[1].atom2 a._ring_ancestor = atom_before a._ring_ancestor_bond = a.bonds[0] ## for a in atoms: ## if not hasattr(a, '_ring_ancestor'): ## l = len(a.bonds) ## if l==0 or l > 2: continue ## if l==2: ## atom_before = a.bonds[0].atom1 ## if atom_before==a: atom_before=a.bonds[0].atom2 ## a._ring_ancestor = atom_before ## a._ring_ancestor_bond = a.bonds[0] ## self.tag_neighbors(a, a.bonds[1]) ## if a.bonds[0]._ring_seen: ## continue ## atom_before = a.bonds[1].atom1 ## if atom_before==a: atom_before=a.bonds[1].atom2 ## a._ring_ancestor = atom_before ## a._ring_ancestor_bond = a.bonds[0] ## else: ## a._ring_ancestor = None ## a._ring_ancestor_bond = None ## self.tag_neighbors(a, a.bonds[0]) for a in atoms: if hasattr(a,'_ring_ancestor'): delattr(a, '_ring_ancestor') if hasattr(a,'_ring_ancestor_bond'): delattr(a, '_ring_ancestor_bond') for b in bonds: delattr(b, '_ring_seen') self.checkRings() delattr(self, '_rings') def smallestCycle(self, atom): """ find smalest cycle containing starting at atom and traversing tree in breadth first order. When an atom with _ancestor is found we backtrack and both sides to build listst of atoms and bonds. It is possible that the first cycle does not contain the initial atom. """ if self._result: return self._result for b in atom.bonds: if self._result: return self._result if not hasattr(b, '_ring'): continue if b._seen: continue atom2 = b.atom1 if atom2==atom: atom2 = b.atom2 if atom2._ancestor: l1 = [atom2] atom2.rings.append( self.ringCount ) l2 = [atom] atom.rings.append( self.ringCount ) b1 = [b] b2 = [] a2 = atom2 a1 = atom done = 0 while not done: b1.append(a2._ancestor_bond) a = a2._ancestor if a != l2[-1]: l1.append(a) a.rings.append( self.ringCount ) a2 = a else: break b2.append(a1._ancestor_bond) a = a1._ancestor if a != l1[-1]: l2.append(a) a.rings.append( self.ringCount ) a1 = a else: break l2.reverse() b2.reverse() self._result = (l2+l1, b2+b1) return else: atom2._ancestor = atom atom2._ancestor_bond = b self.stack.append(atom2) b._seen = 1 if len(self.stack): a = self.stack[0] self.stack.remove(a) self.smallestCycle(a) return self._result def checkRings(self): """ this functions uses the rings found by findRings to identify smalest cycles in structure. After this method was called this object as the following new members: rings: a list of dictionnaries {'atoms':list of atoms, 'bonds': list} allRingAtoms: list of all atoms in rings allRingBonds: list of all bonds in rings ringCount: number of rings """ self.rings = [] self.allRingAtoms = [] self.allRingBonds = [] self.ringCount = 0 for ring in self._rings: self.allRingAtoms = self.allRingAtoms + ring['atoms'] self.allRingBonds = self.allRingBonds + ring['bonds'] for a in self.allRingAtoms: a.rings = [] for b in self.allRingBonds: b._ring = 1 # breadth first walking over atoms and bonds in rings # tag atoms in shortest cycle for a in self.allRingAtoms: if len(a.rings)>0: continue self.stack = [] for b in self.allRingBonds: b._seen = 0 for at in self.allRingAtoms: at._ancestor = None a._ancestor_bond = None self._result = None ratoms, rbonds = self.smallestCycle(a) if a in ratoms: self.ringCount = self.ringCount+1 self.rings.append( {'atoms':ratoms, 'bonds':rbonds} ) else: for at in ratoms: at.rings = at.rings[:-1] # clean up for a in self.allRingAtoms: if hasattr(a, '_ancestor'): delattr(a, '_ancestor') if hasattr(a, '_ancestor_bond'): delattr(a, '_ancestor_bond') for b in self.allRingBonds: if hasattr(b, '_ring'): delattr(b, '_ring') if hasattr(b, '_seen'): delattr(b, '_seen') if hasattr(self, '_result'): delattr(self, '_result') def printRings(self): """ """ if not hasattr(self, 'rings'): return i = 0 for r in self.rings: print 'RING ',i for j in range(len(r['atoms'])): a = r['atoms'][j] b = r['bonds'][j] print '%10s %4d %s'%(a.name, a.number, repr(b)) i = i + 1 if __name__ == '__main__': import pdb, sys from MolKit.pdbParser import NewPdbParser parser = NewPdbParser("/tsri/pdb/struct/%s.pdb"%sys.argv[1]) mols = parser.parse() mol = mols[0] mol.buildBondsByDistance() allAtoms = mol.chains.residues.atoms print 'Looking for rings' r = RingFinder() bonds = (allAtoms.bonds)[0] r.findRings(allAtoms, bonds) r.printRings() from MolKit.pdbParser import NewPdbqParser parser = NewPdbqParser("./txp.pdbq") mols = parser.parse() mol = mols[0] mol.buildBondsByDistance() allAtoms = mol.chains.residues.atoms print 'Looking for rings ...' r = RingFinder() print "Done" bonds = (allAtoms.bonds)[0] r.findRings(allAtoms, bonds) r.printRings() mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/.packager.py0000644000175000017500000000536007770420660022406 0ustar debiandebian# The .packager.py is used by the DistTools package to get the files to be # included in a distribution. def getFiles(root, what = 'all', plat=None): """ files <- getFiles(root, what='all', plat=None) files -- list of the files to be included in the download arguments: root -- path to the package. This is used by glob to get all the python modules. what -- string that can be 'all' and 'supported' to specified what files to include in the distribution. By default 'all' the files are added. plat -- platform ('linux2', 'irix646', 'sunos5' etc...) """ import os from glob import glob # 1- Specify the list of all the Python module allPyModule = ["*.py"] # 2- Specify the list of the non supported Python module. These files # will be removed from the release of the supported python modules. pynotsupported = [] # 3- Specify the documentation files and directories to be included in the # release docFiles = []#["doc"] # 4-Specify the extraFiles to be included in the release. extraFiles = ["CVS", "RELNOTES"] # 5-Specify the testFiles to be included in the release. testFiles = ["Tests"] ######################################################### ## Where things are done for you . ######################################################### # if some files need to be removed, we need the exact list of the pymodule. if len(pynotsupported): # store the path of the current directory olddir = os.getcwd() os.chdir(root) files = [] # we use glob to get the exact list of files. for p in allPyModule: files = files + glob(p) allPyModule = files files = [] # need to get the list of the files ... no wild card possible. for p in pynotsupported: files = files + glob(p) pynotsupported = files os.chdir(olddir) # Creation of the proper list of files depending on the value of what if what == 'supported' and len(pynotsupported): # need to remove the non supported python files from all the python # files # These are the keys used for to make the releases... supportedFiles = filter(lambda x, l = pynotsupported: not x in l, allPyModule) return supportedFiles + testFiles + extraFiles elif what == 'all' or ( what == 'supported' and not len(pynotsupported)): # Other wise just add the documentation, test and extra files to all # the python modules. allFiles= allPyModule + docFiles + testFiles + extraFiles return allFiles elif what == 'documentation': return docFiles else: return [] mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/util.py0000644000175000017500000001023511462577326021532 0ustar debiandebian############################################################################# # # Author: Michel F. SANNER # Reimplemented from Babel v1.6 from Pat Walters and Math Stahl # # Copyright: M. Sanner TSRI 2000 # ############################################################################# """ This file defines constants and a few functions used throughout the package reimplmentation of Babel1.6 in Python by Michel Sanner April 2000 Original code by W. Patrick Walters and Matthew T. Stahl """ # # $Header: /opt/cvs/python/packages/share1.5/PyBabel/util.py,v 1.3 2010/10/29 17:05:26 sargis Exp $ # # $Id: util.py,v 1.3 2010/10/29 17:05:26 sargis Exp $ # import math RAD_TO_DEG = 180.0/math.pi def distance(a, b): """float <- distance(a,b) returns the distance between 3D points a and b""" dx = b[0]-a[0] dy = b[1]-a[1] dz = b[2]-a[2] return math.sqrt( dx*dx + dy*dy +dz*dz) def bond_angle(a, b, c): """ float <- bond_angle(a, b, c) returns the angle in degrees between 3D pts a,b,c """ dist = distance(a,b) * distance(b,c) if dist == 0: # SD 2010 - http://mgl.scripps.edu/forum/viewtopic.php?f=11&t=245&p=1882 raise ZeroDivisionError("Input used:", a, b, c) cos_theta = ( (a[0] - b[0]) * (c[0] - b[0]) + (a[1] - b[1]) * (c[1] - b[1]) + (a[2] - b[2]) * (c[2] - b[2]) ) / dist if cos_theta + 1.0 < 0.0001: angle = 180.0 else: angle = (math.acos(cos_theta)) * RAD_TO_DEG return angle def torsion_angle(c1, c2, c3, c4): """ float <- torsion_angle(a, b, c, d) returns the torsion angle in degrees between 3D pts a,b,c,d """ v1 = (c1[0]-c2[0], c1[1]-c2[1], c1[2]-c2[2]) v2 = (c2[0]-c3[0], c2[1]-c3[1], c2[2]-c3[2]) v3 = (c3[0]-c4[0], c3[1]-c4[1], c3[2]-c4[2]) p = (v2[1]*v1[2] - v1[1]*v2[2], v1[0]*v2[2] - v2[0]*v1[2], v2[0]*v1[1] - v1[0]*v2[1]) q = (v3[1]*v2[2] - v2[1]*v3[2], v2[0]*v3[2] - v3[0]*v2[2], v3[0]*v2[1] - v2[0]*v3[1]) n = 1.0 / math.sqrt( p[0]*p[0] + p[1]*p[1] + p[2]*p[2] ) p = (p[0]*n, p[1]*n, p[2]*n ) n = 1.0 / math.sqrt( q[0]*q[0] + q[1]*q[1] + q[2]*q[2] ) q = (q[0]*n, q[1]*n, q[2]*n ) xtheta = p[0]*q[0] + p[1]*q[1] + p[2]*q[2] if xtheta > 1.0: xtheta = 1.0 if xtheta < -1.0: xtheta = -1.0 theta = math.acos(xtheta) * 57.29578 absth = math.fabs(theta) if absth < 0.001: return 0.0 elif math.fabs(absth - 180.0) < 0.001: return 180.0 s = v1[0]*q[0] + v1[1]*q[1] + v1[2]*q[2] if s < 0.0: theta = 360.0 - theta if theta > 180.0: theta = theta - 360.0 return theta def vec3(a, b, norm=1.0): """ x,y,z <- vec3(a, b, norm=1.0) returns the vector a, b scale to norm """ dx = b[0]-a[0] dy = b[1]-a[1] dz = b[2]-a[2] l = norm / math.sqrt( dx*dx + dy*dy +dz*dz) return [dx*l, dy*l, dz*l] def determinant_3x3(m): """ float <- determinant_3x3(m) returns the determinant of the 3x3 matrix m """ x = m[0][0] * (m[1][1] * m[2][2] - m[2][1] * m[1][2]) y = m[1][0] * (m[2][1] * m[0][2] - m[0][1] * m[2][2]) z = m[2][0] * (m[0][1] * m[1][2] - m[1][1] * m[0][2]) return (x + y + z) def invert_3x3(m): """ matrix3x3 <- invert_3x3(m) returns the inverse of a 3x3 matrix """ det = determinant_3x3(m) if (det != 0.0): t = [ [0,0,0], [0,0,0], [0,0,0] ] det = 1.0/det t[0][0] = m[1][1]*m[2][2] - m[2][1]*m[1][2] t[0][1] = m[2][1]*m[0][2] - m[0][1]*m[2][2] t[0][2] = m[0][1]*m[1][2] - m[1][1]*m[0][2] t[1][0] = m[1][2]*m[2][0] - m[2][2]*m[1][0] t[1][1] = m[2][2]*m[0][0] - m[0][2]*m[2][0] t[1][2] = m[0][2]*m[1][0] - m[1][2]*m[0][0] t[2][0] = m[1][0]*m[2][1] - m[2][0]*m[1][1] t[2][1] = m[2][0]*m[0][1] - m[0][0]*m[2][1] t[2][2] = m[0][0]*m[1][1] - m[1][0]*m[0][1] m[0][0] = t[0][0]*det m[0][1] = t[0][1]*det m[0][2] = t[0][2]*det m[1][0] = t[1][0]*det m[1][1] = t[1][1]*det m[1][2] = t[1][2]*det m[2][0] = t[2][0]*det m[2][1] = t[2][1]*det m[2][2] = t[2][2]*det return m mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/RELNOTES0000644000175000017500000000203310347155410021341 0ustar debiandebian============================================================================== Python-based Molecular Viewer Release Notes: ============================================================================== Release rel 1.4alpha1(December 2005) _____________________________________________________________________________ What's new since rel 1.3alpha2: ------------------------------ Bug Fixes since rel 1.3alpha2: ----------------------------- changes after 1.3alpha2: ----------------------- *previously get_atomic_number broke on MG: corrected in get_atomic_number method which checked that the constructed "_name" was a key in the babel_elements dictionary but then tried to retrieve the value for "name". Release rel 1.2beta1 (12/15/2003) _____________________________________________________________________________ What's new since rel 1.2alpha (09/18/2003): Bug Fixes since rel 1.2alpha (09/18/2003): Changes since rel 1.2alpha (09/18/2003): Known Issues: Backwards INCOMPATIBLE Changes since rel 1.2alpha (09/18/2003): mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/tools.py0000644000175000017500000000535707262424343021717 0ustar debiandebian############################################################################# # # Author: Michel F. SANNER # Reimplemented from Babel v1.6 from Pat Walters and Math Stahl # # Copyright: M. Sanner TSRI 2000 # ############################################################################# # # $Header: /opt/cvs/python/packages/share1.5/PyBabel/tools.py,v 1.1.1.1 2001/04/03 19:47:47 gillet Exp $ # # $Id: tools.py,v 1.1.1.1 2001/04/03 19:47:47 gillet Exp $ # # # import string def read_element_table(filename): """void <- read_element_table(filename) populates the elementsTable dictionary from the a given file. the file provides: line number, element string, cov_rad, bond_ord_rad, vdw_rad, bs_rad, max_bonds, red, green, blue """ f = open(filename) lines = f.readlines() f.close() elemTable = {} for i in range(len(lines)): dd = string.split(lines[i]) elemTable[dd[1]] = { 'num':i, 'cov_rad':float(dd[2]), 'bond_ord_rad':float(dd[3]), 'vdw_rad':float(dd[4]), 'bs_rad':float(dd[5]), 'max_bonds':int(dd[6]), 'rgb': (float(dd[7]),float(dd[8]),float(dd[9])) } return elemTable def writeElementTableAsPythonCode(elemTab, inFileName, outFileName): """write elemTable as a python dictionary that can be imported""" f = open(outFileName,'w') f.write("# File generated from %s\n#\n"%inFileName) f.write("babel_elements = {\n") for k,v in elemTab.items(): f.write(" '%s': %s, \n" % (k,str(v))) f.write('}\n#END\n'); f.close() def read_types_table(filename): f = open(filename) typestab = {} nrow, ncol = map( int, string.split(f.readline())) typeFormats = string.split(f.readline()) for t in typeFormats: typestab[t] = [] for i in range(nrow-1): typeNames = string.split(f.readline()) for j in range(ncol): typestab[typeFormats[j]].append(typeNames[j]) f.close() return typestab def writeTypesTableAsPythonCode(typestab, inFileName, outFileName): """write typestab as a python dictionary that can be imported""" f = open(outFileName,'w') f.write("# File generated from %s\n#\n"%inFileName) f.write("babel_types = {\n") for k,v in typestab.items(): f.write(" '%s': %s, \n" % (k,str(v))) f.write('}\n#END\n'); f.close() if __name__ == '__main__': # write tables et = read_element_table('element.lis') writeElementTableAsPythonCode(et, 'element.lis', 'babelElements.py') tt = read_types_table('types.lis') writeTypesTableAsPythonCode(tt, 'types.lis', 'babelAtomTypes.py') mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/gasteiger.py0000644000175000017500000003677411630221543022527 0ustar debiandebian############################################################################# # # Authors: Michel F. SANNER, Ruth HUEY and Garrett M. MORRIS # Reimplemented from Babel v1.6 from Pat Walters and Math Stahl # # Copyright: M. Sanner TSRI 2000 # # # Cobalt parameters added by Alex L. Perryman 8/24/2011 (due to user request) # ############################################################################# # # $Header: /opt/cvs/python/packages/share1.5/PyBabel/gasteiger.py,v 1.8 2011/09/02 18:41:39 rhuey Exp $ # # $Id: gasteiger.py,v 1.8 2011/09/02 18:41:39 rhuey Exp $ # # """ This file implements the gasteiger class. Before this gasteiger object can be used, atoms must have been assigned a type see (AtomHybridization in types.py). reimplmentation of Babel1.6 in Python by Michel Sanner April 2000 Original code by W. Patrick Walters and Matthew T. Stahl """ import math from atomTypes import TypeConverter ###Partial equilization of orbital electronegativity, PEOP ###PEOP method to calculate a, b and c ### from J. Gasteiger and M. Marsili, Tetrahedron 36, 3219 (1980) ### ###energy parameters ### ###for neutral atoms: ### from J. Hinze and H.H. Jaffe, J. Am. Chem. Soc. 84, 540 (1962) ### I0 Valence State Ionization Potentials ### E0 Valence State Electron Affinities ### ###for positive ions: ### from J. Hinze and H.H. Jaffe, J. Phys. Chem. 67, 1501 (1963) ### I+ Valence State Ionization Potentials ### E+ Valence State Electron Affinities ### ### orbital ids used: ### te tetrahedral, sp3 ### tr trigonal, sp2 ### di digonal, sp energyParms = {} #elemDict['sp2'] = hybridD = {} #elemDict['sp2'] = hybridD = {} #hybridD['I0'] = #hybridD['E0'] = #hybridD['I+'] = #hybridD['E+'] = #Carbon energyParms['C'] = {} energyParms['C']['sp3'] = hybridD ={} hybridD['I0'] = 14.61 #tetetete hybridD['E0'] = 1.34 #tetetete hybridD['I+'] = 26.71 #tetete, sigma hybridD['E+'] = 11.37 #tetete, sigma energyParms['C']['sp2'] = hybridD ={} hybridD['I0'] = 15.62 #trtrtr pi, sigma hybridD['E0'] = 1.95 #trtrtr pi, sigma hybridD['I+'] = 27.36 #trtr pi, sigma hybridD['E+'] = 11.91 #trtr pi, sigma #hybridD['I+'] = 23.68 #trtr pi, pi #hybridD['E+'] = 10.45 #trtr pi, pi energyParms['C']['sp'] = hybridD ={} hybridD['I0'] = 17.42 #didi pi pi, sigma hybridD['E0'] = 3.34 #didi pi pi, sigma hybridD['I+'] = 28.16 #di pi pi, sigma hybridD['E+'] = 12.96 #di pi pi, sigma #hybridD['I+'] = 29.85 #didi pi, sigma #hybridD['E+'] = 13.29 #didi pi, sigma #hybridD['I+'] = 23.86 #didi pi, pi #hybridD['E+'] = 9.83 #didi pi, pi #Nitrogen energyParms['N'] = {} energyParms['N']['sp3'] = hybridD ={} hybridD['I0'] = 18.93 #te2tetete hybridD['E0'] = 4.15 #te2tetete hybridD['I+'] = 33.29 #tetetete, sigma hybridD['E+'] = 14.14 #tetetete, sigma energyParms['N']['sp2'] = hybridD ={} hybridD['I0'] = 20.60 #tr2trtr pi, sigma hybridD['E0'] = 5.14 #tr2trtr pi, sigma hybridD['I+'] = 34.62 #trtrtr pi, sigma hybridD['E+'] = 15.09 #trtrtr pi, sigma #hybridD['I+'] = 28.71 #trtrtr pi, pi #hybridD['E+'] = 11.96 #trtrtr pi, pi energyParms['N']['sp'] = hybridD ={} hybridD['I0'] = 23.91 #di2di pi pi, sigma hybridD['E0'] = 7.45 #di2di pi pi, sigma hybridD['I+'] = 37.00 #didi pi pi, sigma hybridD['E+'] = 17.24 #didi pi pi, sigma #hybridD['I+'] = 28.70 #didi pi pi, pi #hybridD['E+'] = 12.06 #didi pi pi, pi #Oxygen energyParms['O'] = {} energyParms['O']['te'] = hybridD ={} hybridD['I0'] = 24.39 #te2te2tete hybridD['E0'] = 6.11 #te2te2tete hybridD['I+'] = 40.31 #te2tetete, sigma hybridD['E+'] = 18.70 #te2tetete, sigma energyParms['O']['sppp'] = hybridD ={} hybridD['I0'] = 17.28 #s2 p2 p p hybridD['E0'] = 2.01 #s2 p2 p p hybridD['I+'] = 34.15 #s2 p p p, p hybridD['E+'] = 14.61 #s2 p p p, p #hybridization adjusted to an angle of 106deg [methanol] #106 = 81% of 109.5 [te] + 19% of 90deg [sppp] energyParms['O']['sp3'] = hybridD ={} prop = 0.81 z = energyParms['O']['te'] y = energyParms['O']['sppp'] hybridD['I0'] = prop * z['I0'] + (1.0 - prop) * y['I0'] # methanol hybridD['E0'] = prop * z['E0'] + (1.0 - prop) * y['E0'] # methanol hybridD['I+'] = prop * z['I+'] + (1.0 - prop) * y['I+'] # methanol hybridD['E+'] = prop * z['E+'] + (1.0 - prop) * y['E+'] # methanol energyParms['O']['sp2'] = hybridD ={} hybridD['I0'] = 26.65 #tr2 tr2 tr pi, sigma hybridD['E0'] = 7.49 #tr2 tr2 tr pi, sigma hybridD['I+'] = 42.49 #tr2 tr tr pi, sigma hybridD['E+'] = 20.15 #tr2 tr tr pi, sigma ## new stuff #Beryllium (2) energyParms['Be'] = elemDict = {} elemDict['sp3'] = hybridD = {} hybridD['I0'] = 7.18 #tete hybridD['E0'] = 0.51 #tete hybridD['I+'] = 18.21 #s hybridD['E+'] = 9.32 #s #hybridD['I+'] = 14.25 #p #hybridD['E+'] = 5.32 #p elemDict['sp2'] = hybridD = {} hybridD['I0'] = 7.38 #tr pi, sigma hybridD['E0'] = 0.63 #tr pi, sigma hybridD['I+'] = 18.21 #s hybridD['E+'] = 9.32 #s #hybridD['I+'] = 14.25 #p #hybridD['E+'] = 5.32 #p #Sulfur (2) energyParms['S'] = elemDict = {} elemDict['sp3'] = hybridD = {} hybridD['I0'] = 15.50 #te2te2tete hybridD['E0'] = 4.77 #te2te2tete hybridD['I+'] = 27.65 #te2tetete, sigma hybridD['E+'] = 13.64 #te2tetete, sigma elemDict['sp2'] = hybridD = {} hybridD['I0'] = 16.27 #tr2 tr tr pi2 hybridD['E0'] = 5.49 #tr2 tr tr pi2 hybridD['I+'] = 28.51 #tr tr tr pi2, sigma hybridD['E+'] = 14.33 #tr tr tr pi2, sigma #Phosphorus (3) energyParms['P'] = elemDict = {} elemDict['sp3'] = hybridD = {} hybridD['I0'] = 14.57 #te2tetete hybridD['E0'] = 3.24 #te2tetete hybridD['I+'] = 24.10 #tetetete, sigma hybridD['E+'] = 12.09 #tetetete, sigma elemDict['sp2'] = hybridD = {} hybridD['I0'] = 15.59 #tr2 tr tr pi, sigma hybridD['E0'] = 3.74 #tr2 tr tr pi, sigma hybridD['I+'] = 25.14 #tr tr tr pi, sigma hybridD['E+'] = 12.72 #tr tr tr pi, sigma #Aluminium (3) energyParms['Al'] = elemDict = {} elemDict['sp3'] = hybridD = {} hybridD['I0'] = 8.17 #tetete hybridD['E0'] = 2.58 #tetete hybridD['I+'] = 15.75 #tete, sigma hybridD['E+'] = 6.64 #tete, sigma elemDict['sp2'] = hybridD = {} hybridD['I0'] = 8.65 #trtr pi, sigma hybridD['E0'] = 2.94 #trtr pi, sigma hybridD['I+'] = 16.28 #tr pi, sigma hybridD['E+'] = 6.74 #tr pi, sigma #Boron (3) energyParms['B'] = elemDict = {} elemDict['sp3'] = hybridD = {} hybridD['I0'] = 10.43 #tetete hybridD['E0'] = 1.53 #tetete hybridD['I+'] = 20.93 #tete, sigma hybridD['E+'] = 7.88 #tete, sigma elemDict['sp2'] = hybridD = {} hybridD['I0'] = 10.97 #trtr pi, sigma hybridD['E0'] = 1.87 #trtr pi, sigma hybridD['I+'] = 21.08 #tr pi, sigma hybridD['E+'] = 8.02 #tr pi, sigma #Silicon (4) energyParms['Si'] = {} energyParms['Si']['sp3'] = hybridD ={} hybridD['I0'] = 11.82 #tetetete hybridD['E0'] = 2.78 #tetetete hybridD['I+'] = 18.97 #tetete, sigma hybridD['E+'] = 10.08 #tetete, sigma energyParms['Si']['sp2'] = hybridD ={} hybridD['I0'] = 12.61 #trtrtr pi, sigma hybridD['E0'] = 3.20 #trtrtr pi, sigma hybridD['I+'] = 19.62 #trtr pi, sigma hybridD['E+'] = 10.57 #trtr pi, sigma #hybridD['I+'] = 16.53 #trtr pi, pi #hybridD['E+'] = 9.54 #trtr pi, pi energyParms['Si']['sp'] = hybridD ={} hybridD['I0'] = 14.06 #didi pi pi, sigma hybridD['E0'] = 4.07 #didi pi pi, sigma hybridD['I+'] = 20.62 #di pi pi, sigma hybridD['E+'] = 11.56 #di pi pi, sigma #hybridD['I0'] = 9.18 #didi pi pi, pi #hybridD['E0'] = 2.20 #didi pi pi, pi #hybridD['I+'] = 16.50 #didi pi, pi #hybridD['E+'] = 8.60 #didi pi, pi #Magnesium energyParms['Mg'] = {} energyParms['Mg']['sp3'] = hybridD ={} hybridD['I0'] = 6.28 #tete hybridD['E0'] = 0.32 #tete hybridD['I+'] = 15.03 #s, s hybridD['E+'] = 7.64 #s, s energyParms['Mg']['sp2'] = hybridD ={} hybridD['I0'] = 6.75 #tr pi, sigma hybridD['E0'] = 0.38 #tr pi, sigma hybridD['I+'] = 15.03 #s, s hybridD['E+'] = 7.64 #s, s energyParms['Mg']['sp'] = hybridD ={} hybridD['I0'] = 7.30 #di pi, sigma hybridD['E0'] = 0.78 #di pi, sigma hybridD['I+'] = 15.03 #s, s hybridD['E+'] = 7.64 #s, s #Cobalt energyParms['Co'] = {} energyParms['Co']['sp3'] = hybridD ={} hybridD['I0'] = 7.88 #tete hybridD['E0'] = 0.66 #tete hybridD['I+'] = 17.08 #s, s hybridD['E+'] = 7.88 #s, s #Note: these values for Co are actually NOT atom-type specific; data = on element Co #these values for Co added by Alex L. Perryman (due to a request by Khia-Yu Ku) #must find "promotion energies" for Co before making atom-type specific corrections class Gasteiger: """ """ def __init__(self): """ """ self.setup_sigma_params() def setup_sigma_params(self): """ """ self.par = { "H" : [ 7.17, 6.24, -0.56, 0.0 ], "C3": [ 7.98, 9.18, 1.88, 0.0 ], "C2": [ 8.79, 9.32, 1.51, 0.0 ], "C1": [ 10.39, 9.45, 0.73, 0.0 ], "N3": [ 11.54, 10.82, 1.36, 0.0 ], "N2": [ 12.87, 11.15, 0.85, 0.0 ], "N1": [ 15.68, 11.70, -0.27, 0.0 ], "O3": [ 14.18, 12.92, 1.39, 0.0 ], "O2": [ 17.07, 13.79, 0.47, 0.0 ], "F" : [ 14.66, 13.85, 2.31, 0.0 ], "Cl": [ 11.00, 9.69, 1.35, 0.0 ], "Br": [ 10.08, 8.47, 1.16, 0.0 ], "I" : [ 9.90, 7.96, 0.96, 0.0 ], "CO": [ 4.27, 6.08, 2.13, 0.0 ], "Co": [ 4.27, 6.08, 2.13, 0.0 ], "S3": [ 10.14, 9.13, 1.38, 0.0 ] } #add values compute from energyParms information #NB: this overwrites specified entries BUT the numbers are # virtually the same... for element, elementD in energyParms.items(): for hybrid, hybridD in elementD.items(): I0 = hybridD['I0'] E0 = hybridD['E0'] IPLUS = hybridD['I+'] EPLUS = hybridD['E+'] a = 0.5 * (I0 + E0) a = round(a, 3) b = 0.25 * (IPLUS + EPLUS - E0) b = round(b, 3) c = 0.25 * (IPLUS - 2 * I0 + EPLUS - E0) c = round(c, 3) if hybrid=='sp': key = element + '1' elif hybrid not in ['sp2', 'sp3']: continue else: key = element + hybrid[-1] self.par[key] = [a, b, c, 0.0] for p in self.par.values(): p[3] = p[0] + p[1] + p[2] def lookup_sigma_params(self, atoms): """ """ converter = TypeConverter("MAP") for a in atoms: type = converter.convert( a.babel_type ) if type[:2] in self.par.keys(): a._gast_par = self.par[type] else: print "Sorry, there are no Gasteiger parameters available for atom %s"%a.full_name() a._gast_par = [ 0.0, 0.0, 0.0, 1.0 ] def calc_sigma_charges(self, atoms): """ """ # set formal charges for a in atoms: a.gast_charge = 0.0 if a.babel_atomic_number==6: # carbons if a.babel_type=="C+": a.gast_charge = 1.0 elif a.babel_atomic_number==7: # nitrogens if len(a.bonds)==4: a.gast_charge = 1.0 if a.babel_type == "N3+": a.gast_charge = 1.0 elif a.babel_atomic_number==8: # oxygens if a.babel_type=="O-": a.gast_charge = -0.5 a._xx = a._gast_par[0] z1 = 1.0 cycle = 0 while (1): z1 = z1 * 0.5 d1 = 0.0 for a in atoms: if a._gast_par[3] != 1.0: q1 = a.gast_charge for b in a.bonds: a2 = b.atom1 if a2==a: a2 = b.atom2 if a2._gast_par[3] != 1.0: hybridD = a2._gast_par[3] if a2._xx > a._xx: hybridD = a._gast_par[3] if a.babel_type == 'H': hybridD = 20.02 if a2.babel_type == 'H': hybridD = 20.02 a.gast_charge = a.gast_charge + \ (a2._xx - a._xx)/hybridD*z1 q1 = math.fabs(a.gast_charge - q1) if q1 > d1: d1 = q1 if d1 >= 0.001: for a in atoms: a._xx = a._gast_par[0] + a._gast_par[1] * a.gast_charge + \ a._gast_par[2] * a.gast_charge * a.gast_charge cycle = cycle+1 if d1<=0.001 or cycle>5: break def compute(self, atoms): """compute(atoms) compute gasteiger charges for a set of atoms""" self.lookup_sigma_params(atoms) self.calc_sigma_charges(atoms) # cleanup for a in atoms: delattr(a,'_gast_par') delattr(a,'_xx') if __name__=="__main__": # import pdb, sys # from MolKit.pdbParser import NewPdbParser # parser = NewPdbParser("/tsri/pdb/struct/%s.pdb"%sys.argv[1]) # mols = parser.parse() # mol = mols[0] # mol.buildBondsByDistance() # allAtoms = mol.chains.residues.atoms # print "assigning atom types" # from atomTypes import AtomHybridization # babel = AtomHybridization() # babel.assignHybridization(allAtoms) # print "computing charges" # Gast = Gasteiger() # Gast.compute(allAtoms) # print allAtoms.babel_type[:20] # print allAtoms.gast_charge[:20] # f = open("result.charges", "w") # for i in range(len(allAtoms)): # a = allAtoms[i] # f.write("%2d %4s %10.4f\n"%(i+1, a.babel_type, a.gast_charge)) # f.close() for element, elementD in energyParms.items(): print 'Element = ', element for hybrid, hybridD in elementD.items(): I0 = hybridD['I0'] E0 = hybridD['E0'] IPLUS = hybridD['I+'] EPLUS = hybridD['E+'] a = 0.5 * (I0 + E0) b = 0.25 * (IPLUS + EPLUS - E0) c = 0.25 * (IPLUS - 2 * I0 + EPLUS - E0) print ' ',hybrid, ' hybridization:' print ' a =', a, print 'b =', b, print 'c =', c print '\n', mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/LICENSE0000644000175000017500000000436411033235255021200 0ustar debiandebianThis software is copyrighted by Michel F. Sanner (sanner@scripps.edu) and TSRI. The following terms apply to all files associated with the software unless explicitly disclaimed in individual files. MGLTOOLS SOFTWARE LICENSE AGREEMENT. 1. Grant Of Limited License; Software Use Restrictions. The programs received by you will be used only for NON COMMERCIAL purposes. This license is issued to you as an individual. For COMMERCIAL use done with the software please contact Michel F. Sanner for details about commercial usage license agreements. For any question regarding license agreements, please contact Michel Sanner: TSRI, Molecular Biology Department, TCP 26, 10550 North Torrey Pines Road, La Jolla, CA 92037 sanner@scripps.edu tel (858) 784-7742 fax (858) 784-2341 2. COMMERCIAL USAGE is defined as revenues generating activities. These include using this software for consulting activities and selling applications built on top of, or using this software. Scientific research in an academic environment and teaching are considered NON COMMERCIAL. 3. Copying Restrictions. You will not sell or otherwise distribute commercially these programs or derivatives to any other party, whether with or without consideration. 4. Ownership of Software. You will not obtain, and will not attempt to obtain copyright coverage thereon without the express purpose written consent of The Scripps Research Institute and Dr. Sanner. 5. IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 6. THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/bo.py0000644000175000017500000004004007555355452021154 0ustar debiandebian############################################################################# # # Author: Michel F. SANNER # Reimplemented from Babel v1.6 from Pat Walters and Math Stahl # # Copyright: M. Sanner TSRI 2000 # ############################################################################# # # $Header: /opt/cvs/python/packages/share1.5/PyBabel/bo.py,v 1.4 2002/10/22 23:11:38 sanner Exp $ # # $Id: bo.py,v 1.4 2002/10/22 23:11:38 sanner Exp $ # """ This file implements the BondOrder class that can be used to compute bond order. Before a BondOrder object can be used, atoms must have been assigned a type see (AtomHybridization in types.py). Bond order can be calculated using 2 different methods depending on whether rings have been identified previously or not. Babel decides to use the first method for molecules with more than 200 atoms and the second one else. example: >>> from PyBabel.atomTypes import AtomHybridization >>> from PyBabel.cycle import RingFinder >>> atype = AtomHybridization() >>> atype.assignHybridization(atoms) >>> bo = BondOrder() >>> bo.assignBondOrder( atoms, bonds ) or >>> atype = AtomHybridization() >>> atype.assignHybridization(atoms) >>> rings = RingFinder() >>> rings.findRings(allAtoms, bonds) >>> bo = BondOrder() >>> bo.assignBondOrder( atoms, bonds, rings ) atoms has to be a list of atom objects Atom: a.coords : 3-sequence of floats a.bonds : list of Bond objects babel_type: string babel_atomic_number: int Bond: b.atom1 : instance of Atom b.atom2 : instance of Atom after completion each bond has a 'bondOrder' attribute (integer) reimplmentation of Babel1.6 in Python by Michel Sanner April 2000 Original code by W. Patrick Walters and Matthew T. Stahl """ import string, math from babelAtomTypes import babel_types from babelElements import babel_elements from util import * from atomTypes import TypeConverter SINGLE_DOUBLE_CUTOFF = 0.95 #SINGLE_DOUBLE_CUTOFF = 0.955 DOUBLE_TRIPLE_CUTOFF = 0.81 class BondOrder: """ """ def assignBondOrder(self, atoms, bonds, rings=None): """ """ if not rings: self.assign_bond_order1(atoms, bonds) else: self.assign_bond_order2(atoms, bonds, rings) def assign_bond_order1(self, atoms, bonds): """ """ hyb_val = [0,3,2,1] converter = TypeConverter("HYB") for a in atoms: hyb = converter.convert(a.babel_type, 'dummy') a._redo = hyb_val[int(hyb)] #print a.full_name(), a.babel_type, hyb, a._redo for b in bonds: # initialize bondOrder attribute if b.bondOrder is None: b.bondOrder = 1 sum_code = b.atom1._redo + b.atom2._redo #print b, sum_code if sum_code == 6: b.bondOrder = 3 elif sum_code == 4: b.bondOrder = 2 else: b.bondOrder = 1 if self.is_carboxyl(b): b.bondOrder = 2 if b.bondOrder < 1 or b.bondOrder > 3: print "Bond %s is wierd - Bond order is %d\n" % \ (b, b.bondOrder) self.check_for_conjugation(atoms) # cleanup for a in atoms: delattr(a, '_redo') def is_carboxyl(self, bond): """ """ c_end = 0 o_end = 0 check = 0 if bond.atom1.babel_type == "Cac" and bond.atom2.babel_type == 'O': c_end = bond.atom1 o_end = bond.atom2 check = 1 if bond.atom2.babel_type == "Cac" and bond.atom1.babel_type == 'O': check = 1 c_end = bond.atom2 o_end = bond.atom1 if check and len(o_end.bonds) == 1: return 1 else: return 0 def check_for_conjugation(self, atoms): """ """ for a in atoms: #if a.full_name()=='1crn: :ASN14:CG': raise for b1 in a.bonds: if b1.bondOrder<=1: continue for b2 in a.bonds: if b1==b2: continue if b2.bondOrder<=1: continue if len(b2.atom1.bonds) > 1 and len(b2.atom2.bonds) > 1: b2.bondOrder = 1 def check_for_carbonyl(self, atom): """ """ for b in atom.bonds: bonded_atom = b.atom1 if bonded_atom==atom: bonded_atom = b.atom2 if bonded_atom.babel_type=="O2" or bonded_atom.babel_type=="S2": return 3 return 2 def assign_bond_order2(self, atoms, bonds, rings): """ """ self.rings = rings for a in atoms: if hasattr(a, 'rings'): a._redo = 1 else: a._redo = 0 a._dot = 0 a._dbatom = 0 self.assign_hybrid_radii(atoms) self.estimate_bond_order2(bonds) for ring in self.rings.rings: if len(ring['atoms'])==5: self.process_5_ring(ring) for b in bonds: # initialize bondOrder attribute if b.bondOrder is None: b.bondOrder = 1 b._dbbond = 0 if b.bondOrder == 2: if len(b.atom1.bonds) > 1 and b.atom1.babel_type[0] == 'O': b.bondOrder = 1 elif len(b.atom2.bonds) > 1 and b.atom2.babel_type[0] == 'O': b.bondOrder = 1 for b in bonds: if b.bondOrder == 2: if len(b.atom1.bonds) == 1 and b.atom1.babel_type[0] == 'N': b.bondOrder = 1 elif len(b.atom2.bonds) == 1 and b.atom2.babel_type[0] == 'N': b.bondOrder = 1 ## for b in bonds: ## if b.bondOrder > 1: ## print "%3d %3d"%(atoms.index(b.atom1)+1, atoms.index(b.atom2)+1) for b in bonds: if b.bondOrder > 1: a1 = b.atom1 if a1._redo and self.check_for_carbonyl(a1) != 3: a1._dot = 1 a2 = b.atom2 if a2._redo and self.check_for_carbonyl(a2) != 3: a2._dot = 1 if len(a1.bonds) == 1 or len(a2.bonds) == 1: a1._dot = 0 a2._dot = 0 ## for a in atoms: ## if a._dot==1: ## print atoms.index(a)+1, a._dot for a in atoms: if a.babel_type=="Npl" and len(a.bonds) == 3: a._dot = 0 ## for a in atoms: ## if a._dot==1: ## print atoms.index(a)+1, a._dot self.atoms = atoms self.cycles = 0 self.bondStack = [] self.bondChoice = [] # for PYTHON interpreters after 1.5 the recursion depth is limited # this method can exceed the default recursion depth import sys if float(sys.version[:3]) > 1.5: sys.setrecursionlimit(20000) self.connect_the_dots(0,0) for b in self.bondStack: if b.bondOrder > 1: b._dbbond = 1 b.atom1._dbatom = 1 b.atom2._dbatom = 1 for b in bonds: if b.atom1.babel_type=="O2" or b.atom2.babel_type=="O2": b._dbbond = 1 b.atom1._dbatom = 1 b.atom2._dbatom = 1 elif b.atom1.babel_type=="O-" and len(b.atom1.bonds) == 1: b._dbbond = 1 b.atom1._dbatom = 1 b.atom2._dbatom = 1 elif b.atom2.babel_type=="O-" and len(b.atom2.bonds) == 1: b._dbbond = 1 b.atom1._dbatom = 1 b.atom2._dbatom = 1 for a in atoms: a._dot = 0 for b in bonds: if b.bondOrder > 1: a1 = b.atom1 a2 = b.atom2 if a1._dbatom==0 and a2._dbatom==0: a1._dot = 1 a2._dot = 1 self.bondStack = [] self.bondChoice = [] self.connect_the_dots(0,0) for b in self.bondStack: if b.bondOrder > 1: b._dbbond = 1 ## for b in bo.bondStack: ## a1 = b.atom1 ## a2 = b.atom2 ## print a1.number, a2.number, a1._dot, a2._dot, b.bondOrder for b in self.bondStack: b._dbbond = 1 for b in bonds: if not b._dbbond: b.bondOrder = 1 for a in atoms: a._redo = 0 for b in a.bonds: a._redo = a._redo + b.bondOrder if (a.babel_atomic_number == 6 or a.babel_atomic_number) == 7 and \ a._redo > 4: for b in a.bonds: conn=None if b.bondOrder == 2: b.bondOrder = 1 #cleanup for a in atoms: delattr(a, '_dot') delattr(a, '_dbatom') delattr(a, '_redo') for b in bonds: delattr(b, '_dbbond') delattr(self, 'atoms') delattr(self, 'cycles') delattr(self, 'rings') ## for b in bonds: ## n = b.atom1.number ## print "%4i %4i %2i"%(n, b.atom2.number, b.bondOrder) def connect_the_dots(self, atom, start): """ """ a = self.atoms[atom] if start == len(a.bonds): return #print 'AAA', atom+1 if a._dot: done = 0 i = start for b in a.bonds[start:]: con = b.atom1 if con==a: con=b.atom2 if con._dot: self.bondStack.append(b) self.bondChoice.append(0) if a==b.atom1: self.bondChoice[-1] = i+1 else: self.bondChoice[-1] = -i-1 a._dot = a._dot-1 con._dot = con._dot-1 done = 1 break i = i + 1 if not done and len(self.bondStack): b = self.bondStack[-1] if self.bondChoice[-1] > 0: new_atm = b.atom1 else: new_atm = b.atom2 choice_bnd = abs(self.bondChoice[-1]) self.bondChoice = self.bondChoice[:-1] self.bondStack = self.bondStack[:-1] b.atom1._dot = b.atom1._dot + 1 b.atom2._dot = b.atom2._dot + 1 #print 'BBB', self.atoms.index(new_atm)+1 self.connect_the_dots(self.atoms.index(new_atm), choice_bnd ) if self.cycles > 10000: #print 'EEE' return if atom+1 == len(self.atoms): #print 'DDD' return else: self.cycles = self.cycles+1 #print 'CCC', atom+2 self.connect_the_dots(atom+1,0) def get_bond(self, bonds, a1, a2): """ """ for b in bonds: if (b.atom1==a1 and b.atom2==a2) or (b.atom1==a2 and b.atom2==a1): return b def process_5_ring(self, ring): """ """ atoms = ring['atoms'] t1 = torsion_angle(atoms[4].coords,atoms[0].coords, atoms[1].coords,atoms[2].coords) t2 = torsion_angle(atoms[0].coords,atoms[1].coords, atoms[2].coords,atoms[3].coords) t3 = torsion_angle(atoms[1].coords,atoms[2].coords, atoms[3].coords,atoms[4].coords) t4 = torsion_angle(atoms[2].coords,atoms[3].coords, atoms[4].coords,atoms[0].coords) t5 = torsion_angle(atoms[3].coords,atoms[4].coords, atoms[0].coords,atoms[1].coords) if math.fabs(t1) < 7.0: a1 = atoms[0] a2 = atoms[1] bond = self.get_bond(ring['bonds'], a1, a2 ) bond.bondOrder = 1 dist = distance(a1.coords, a2.coords) cov_sum = a1.babel_bond_ord_rad + a2.babel_bond_ord_rad ratio = dist/cov_sum if ratio < SINGLE_DOUBLE_CUTOFF: bond.bondOrder = 2 if math.fabs(t2) < 7.0: a1 = atoms[1] a2 = atoms[2] bond = self.get_bond(ring['bonds'], a1, a2 ) bond.bondOrder = 1 dist = distance(a1.coords, a2.coords) cov_sum = a1.babel_bond_ord_rad + a2.babel_bond_ord_rad ratio = dist/cov_sum if ratio < SINGLE_DOUBLE_CUTOFF: bond.bondOrder = 2 if math.fabs(t3) < 7.0: a1 = atoms[2] a2 = atoms[3] bond = self.get_bond(ring['bonds'], a1, a2 ) bond.bondOrder = 1 dist = distance(a1.coords, a2.coords) cov_sum = a1.babel_bond_ord_rad + a2.babel_bond_ord_rad ratio = dist/cov_sum if ratio < SINGLE_DOUBLE_CUTOFF: bond.bondOrder = 2 if math.fabs(t4) < 7.0: a1 = atoms[3] a2 = atoms[4] bond = self.get_bond(ring['bonds'], a1, a2 ) bond.bondOrder = 1 dist = distance(a1.coords, a2.coords) cov_sum = a1.babel_bond_ord_rad + a2.babel_bond_ord_rad ratio = dist/cov_sum if ratio < SINGLE_DOUBLE_CUTOFF: bond.bondOrder = 2 if math.fabs(t5) < 7.0: a1 = atoms[4] a2 = atoms[0] bond = self.get_bond(ring['bonds'], a1, a2 ) bond.bondOrder = 1 dist = distance(a1.coords, a2.coords) cov_sum = a1.babel_bond_ord_rad + a2.babel_bond_ord_rad ratio = dist/cov_sum if ratio < SINGLE_DOUBLE_CUTOFF: bond.bondOrder = 2 def estimate_bond_order2(self, bonds): """ """ converter = TypeConverter("HYB") for b in bonds: bo = 1 a1 = b.atom1 a2 = b.atom2 dist = distance(a1.coords, a2.coords) cov_sum = a1.babel_bond_ord_rad + a2.babel_bond_ord_rad ratio = dist/cov_sum start_type = converter.convert(a1.babel_type, "all_caps") end_type = converter.convert(a2.babel_type, "all_caps") if ratio <= DOUBLE_TRIPLE_CUTOFF: if start_type[0] == '1' and end_type[0] == '1': bo = 3 elif ratio <= SINGLE_DOUBLE_CUTOFF: if start_type[0] == '2' and end_type[0] == '2': bo = 2 b.bondOrder = bo def assign_hybrid_radii(self, atoms): """ """ converter = TypeConverter("XYZ") for a in atoms: atm_type = converter.convert(a.babel_type, 'zero') if atm_type == 0: atm_type = a.babel_type atm_type = converter.clean_atom_type(atm_type) a.babel_cov_rad = babel_elements[atm_type]['cov_rad'] a.babel_bond_ord_rad = babel_elements[atm_type]['bond_ord_rad'] a.babel_max_bonds = babel_elements[atm_type]['max_bonds'] if __name__ == '__main__': import pdb, sys from atomTypes import AtomHybridization from cycle import RingFinder from MolKit.pdbParser import NewPdbParser parser = NewPdbParser("/tsri/pdb/struct/%s.pdb"%sys.argv[1]) mols = parser.parse() mol = mols[0] mol.buildBondsByDistance() allAtoms = mol.chains.residues.atoms bonds = allAtoms.bonds[0] print "assigning atom types" babel = AtomHybridization() babel.assignHybridization(allAtoms) print "looking for rings" rings = RingFinder() rings.findRings(allAtoms, bonds) print "assigning bond order" bo = BondOrder() #pdb.run("bo.assignBondOrder(allAtoms, bonds)") bo.assignBondOrder(allAtoms, bonds) for b in bonds: if b.bondOrder > 1: a1 = b.atom1 a2 = b.atom2 print '%-20s %-20s %d'% ( a1.full_name(), a2.full_name(), b.bondOrder ) mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/regression/0000755000175000017500000000000012146213337022347 5ustar debiandebianmgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/regression/test_cycles.py0000644000175000017500000000547407557365230025266 0ustar debiandebianimport sys, string from mglutil.regression import testplus class Atom: def __init__(self, coords): self.coords = coords self.bonds = [] class Bond: def __init__(self, atom1, atom2): self.atom1 = atom1 self.atom2 = atom2 self.atom1.bonds.append(self) self.atom2.bonds.append(self) def getGraphFromFile(filename): f = open(filename) nba = int(f.readline()) atoms = [] for i in range(nba): data = string.split(f.readline()) x,y,z = map( float, data) atoms.append(Atom((x,y,z))) bonds = [] nbb = int(f.readline()) for i in range(nbb): data = string.split(f.readline()) at1,at2 = map( int, data) bonds.append( Bond( atoms[at1], atoms[at2] ) ) return atoms, bonds def test_findCycles4(): # test that atoms in cycles are ordered on taxol atoms, bonds = getGraphFromFile('txp.graph') from PyBabel.cycle import RingFinder rings = RingFinder() rings.findRings2(atoms, bonds) def hasBond(a1, a2, cycleHasBond): for b in cyclebonds: if b.atom1==a1 and b.atom2==a2: return 1 elif b.atom1==a2 and b.atom2==a1: return 1 return 0 def isOrdered(cycleatoms, cyclebonds): def hasBond(a1, a2, cyclebonds): for b in cyclebonds: if b.atom1==a1 and b.atom2==a2: return 1 elif b.atom1==a2 and b.atom2==a1: return 1 return 0 start = cycleatoms[0] for end in cycleatoms[1:]: if not hasBond(start, end, cyclebonds): return 0 start = end return 1 for r in rings.rings: assert isOrdered(r['atoms'], r['bonds']) def test_findCycles1(): # test cycle detection on taxol atoms, bonds = getGraphFromFile('txp.graph') from PyBabel.cycle import RingFinder rings = RingFinder() rings.findRings2(atoms, bonds) assert rings.ringCount==6 def test_findCycles2(): # test cycle detection on modified taxol to have 5 membered ring atoms, bonds = getGraphFromFile('fuzedRings2.graph') from PyBabel.cycle import RingFinder rings = RingFinder() rings.findRings2(atoms, bonds) assert rings.ringCount==4 def test_findCycles3(): # test cycle detection on taxol merged rings only atoms, bonds = getGraphFromFile('fuzedRings1.graph') from PyBabel.cycle import RingFinder rings = RingFinder() rings.findRings2(atoms, bonds) assert rings.ringCount==4 harness = testplus.TestHarness( "PyBabel_cycles", funs = testplus.testcollect( globals()), ) if __name__ == '__main__': testplus.chdir() print harness sys.exit( len( harness)) mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/regression/fuzedRings1.graph0000644000175000017500000000116507553055164025606 0ustar debiandebian18 16.249000 3.187000 -2.243000 15.723000 3.736000 -3.656000 15.856000 2.917000 -4.383000 16.403000 5.029000 -4.338000 15.353000 6.155000 -4.768000 15.697000 7.184000 -5.892000 16.996000 7.007000 -6.703000 18.082000 6.221000 -5.953000 17.621000 4.818000 -5.379000 18.992000 4.236000 -4.798000 19.555000 4.413000 -3.353000 18.597000 4.094000 -2.197000 18.333000 5.033000 -1.232000 17.090000 4.858000 -0.324000 15.891000 4.217000 -1.093000 17.784000 2.741000 -2.213000 14.220000 5.781000 -5.751000 14.578000 6.792000 -6.697000 21 0 14 0 15 5 6 0 1 10 11 7 8 9 10 3 4 16 17 11 15 11 12 5 17 13 14 4 5 1 3 3 8 6 7 12 13 1 2 8 9 4 16 mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/regression/fuzedRings2.graph0000644000175000017500000000112207553055164025600 0ustar debiandebian17 16.249000 3.187000 -2.243000 15.723000 3.736000 -3.656000 15.856000 2.917000 -4.383000 16.403000 5.029000 -4.338000 15.353000 6.155000 -4.768000 15.697000 7.184000 -5.892000 16.996000 7.007000 -6.703000 18.082000 6.221000 -5.953000 17.621000 4.818000 -5.379000 18.992000 4.236000 -4.798000 19.555000 4.413000 -3.353000 18.597000 4.094000 -2.197000 18.333000 5.033000 -1.232000 15.891000 4.217000 -1.093000 17.784000 2.741000 -2.213000 14.220000 5.781000 -5.751000 14.578000 6.792000 -6.697000 20 6 7 8 9 10 11 7 8 5 16 0 13 3 8 12 13 0 14 0 1 11 12 4 5 11 14 15 16 5 6 9 10 1 2 3 4 1 3 4 15 mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/regression/txp.graph0000644000175000017500000000744207553055164024224 0ustar debiandebian111 16.249000 3.187000 -2.243000 15.723000 3.736000 -3.656000 15.856000 2.917000 -4.383000 16.403000 5.029000 -4.338000 16.890000 5.547000 -3.499000 15.353000 6.155000 -4.768000 15.697000 7.184000 -5.892000 15.581000 8.231000 -5.551000 16.996000 7.007000 -6.703000 17.385000 7.997000 -7.003000 16.777000 6.499000 -7.661000 18.082000 6.221000 -5.953000 18.419000 6.859000 -5.108000 17.621000 4.818000 -5.379000 18.992000 4.236000 -4.798000 19.555000 4.413000 -3.353000 19.874000 5.471000 -3.343000 18.597000 4.094000 -2.197000 18.333000 5.033000 -1.232000 17.090000 4.858000 -0.324000 17.416000 4.165000 0.470000 15.891000 4.217000 -1.093000 15.223000 3.753000 -0.343000 15.277000 5.043000 -1.493000 17.784000 2.741000 -2.213000 18.100000 1.687000 -3.334000 17.811000 2.001000 -4.344000 19.177000 1.440000 -3.397000 17.559000 0.733000 -3.187000 18.221000 1.872000 -0.979000 17.685000 0.904000 -0.931000 19.303000 1.639000 -0.987000 18.026000 2.321000 0.000000 19.184000 6.279000 -1.006000 20.264000 6.083000 -1.143000 18.895000 7.089000 -1.701000 19.079000 6.680000 0.018000 17.138000 3.907000 -6.567000 16.219000 4.275000 -7.052000 17.887000 3.853000 -7.380000 16.950000 2.861000 -6.271000 14.220000 5.781000 -5.751000 13.200000 5.939000 -5.353000 14.291000 4.764000 -6.177000 15.480000 2.019000 -1.929000 14.992000 1.777000 -2.726000 14.276000 3.959000 -3.512000 14.712000 6.789000 -3.614000 14.578000 6.792000 -6.697000 19.166000 6.109000 -6.881000 19.534000 5.222000 -6.766000 19.745000 3.660000 -5.595000 20.704000 3.625000 -3.055000 20.491000 3.219000 -2.210000 16.639000 6.094000 0.317000 16.081000 5.996000 1.591000 15.833000 4.940000 2.183000 15.791000 7.379000 2.223000 16.420000 8.106000 1.675000 16.232000 7.392000 3.590000 16.030000 8.265000 3.941000 14.308000 7.861000 2.085000 14.177000 8.018000 0.997000 14.069000 9.251000 2.756000 14.000000 9.412000 4.153000 14.061000 8.552000 4.804000 13.845000 10.676000 4.716000 13.792000 10.789000 5.790000 13.755000 11.795000 3.895000 13.637000 12.777000 4.332000 13.813000 11.655000 2.512000 13.738000 12.527000 1.877000 13.969000 10.392000 1.946000 14.015000 10.310000 0.869000 13.295000 6.857000 2.540000 13.364000 6.403000 3.455000 12.557000 6.124000 1.701000 12.621000 6.319000 0.483000 11.731000 5.167000 2.279000 10.849000 4.288000 1.515000 10.147000 3.406000 2.556000 9.583000 4.013000 3.287000 9.433000 2.697000 2.098000 10.874000 2.809000 3.136000 9.760000 5.075000 0.760000 10.197000 5.720000 -0.024000 9.034000 4.410000 0.258000 9.194000 5.738000 1.439000 11.626000 3.364000 0.557000 12.421000 2.807000 1.086000 10.972000 2.624000 0.060000 12.124000 3.936000 -0.247000 13.350000 2.941000 -3.711000 13.697000 1.788000 -3.997000 11.840000 3.267000 -3.533000 11.428000 4.563000 -3.188000 12.149000 5.354000 -3.029000 10.074000 4.854000 -3.032000 9.763000 5.854000 -2.763000 9.122000 3.856000 -3.213000 8.073000 4.082000 -3.094000 9.518000 2.565000 -3.549000 8.778000 1.789000 -3.686000 10.869000 2.271000 -3.710000 11.159000 1.262000 -3.972000 15.390000 7.718000 -2.837000 16.579000 8.022000 -2.942000 14.473000 8.362000 -1.827000 13.673000 8.929000 -2.334000 13.998000 7.587000 -1.203000 15.029000 9.054000 -1.172000 116 94 103 68 69 80 82 5 6 37 38 52 53 55 57 103 104 68 70 18 33 13 14 41 48 92 94 19 21 74 75 17 18 6 7 57 58 33 36 88 90 54 55 1 46 41 42 41 43 95 97 29 32 84 85 74 76 11 13 70 71 57 59 25 28 79 80 8 10 61 63 29 30 6 8 15 52 14 51 57 61 107 108 46 92 29 31 25 26 64 66 101 103 70 72 37 40 0 44 25 27 49 50 92 93 15 17 33 34 59 60 63 72 37 39 1 3 19 20 84 87 21 22 94 95 8 9 33 35 107 109 3 5 24 29 15 16 80 83 79 84 18 19 21 23 8 11 14 15 47 105 0 21 64 65 19 54 1 2 84 86 63 64 66 67 44 45 11 49 11 12 72 73 3 13 66 68 0 1 3 4 24 25 88 89 99 100 55 56 5 41 17 24 5 47 6 48 95 96 80 81 76 77 105 107 79 88 97 99 97 98 0 24 61 62 107 110 13 37 99 101 105 106 88 91 61 74 76 78 101 102 78 79 mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/babelAtomTypes.py0000644000175000017500000002546507262424343023474 0ustar debiandebian############################################################################# # # Author: Michel F. SANNER # Reimplemented from Babel v1.6 from Pat Walters and Math Stahl # # Copyright: M. Sanner TSRI 2000 # ############################################################################# # # $Header: /opt/cvs/python/packages/share1.5/PyBabel/babelAtomTypes.py,v 1.1.1.1 2001/04/03 19:47:47 gillet Exp $ # # $Id: babelAtomTypes.py,v 1.1.1.1 2001/04/03 19:47:47 gillet Exp $ # # File generated from types.lis # babel_types = { 'ATN': ['0', '25', '26', '25', '0', '6', '6', '6', '6', '6', '6', '6', '7', '7', '7', '7', '7', '7', '7', '7', '7', '8', '8', '8', '8', '16', '16', '16', '16', '16', '16', '16', '16', '5', '5', '5', '15', '15', '15', '15', '15', '1', '1', '1', '1', '1', '1', '9', '17', '35', '53', '32', '50', '82', '34', '52', '8', '0', '6', '6', '7', '7', '0', '1', '1', '1', '6', '1', '6', '7', '1', '74', '6', '7', '7', '11', '19', '20', '9', '13', '14', '4', '6', '8', '46', '46', '28', '29', '7', '7', '8', '6', '8', '6', '23', '30', '6', '7', '8', '16', '6', '6', '6', '8', '16'], 'DOK': ['25', '25', '25', '25', '25', '5', '1', '1', '1', '1', '1', '1', '9', '10', '8', '8', '8', '8', '8', '8', '9', '12', '12', '11', '12', '14', '14', '14', '14', '14', '14', '14', '14', '20', '20', '20', '13', '13', '13', '13', '13', '7', '6', '6', '6', '6', '6', '15', '16', '17', '18', '25', '25', '25', '25', '25', '12', '25', '5', '5', '8', '8', '25', '25', '6', '6', '5', '6', '5', '8', '6', '25', '1', '8', '8', '19', '19', '21', '20', '20', '24', '1', '1', '11', '25', '25', '25', '25', '9', '8', '12', '1', '12', '5', '25', '25', '1', '1', '1', '1', '1', '1', '1', '12', '14'], 'DRE': ['X', 'Mn', 'Fe', 'Li', 'Du', 'C_3', 'C_2', 'C_2', 'C_1', 'C_2', 'C_2', 'C_3', 'N_3', 'N_3', 'N_2', 'N_2', 'N_2', 'N_1', 'N_2', 'N_2', 'N_2', 'O_3', 'O_2', 'O_2', 'O_3', 'S_3', 'S_3', 'S_3', 'S_3', 'S_3', 'S_3', 'S_3', 'S_3', 'B_2', 'B_2', 'B_3', 'P_3', 'P_3', 'P_3', 'P_3', 'P_3', 'H_', 'H_', 'H_', 'H_', 'H_', 'H_', 'F_', 'Cl', 'Br', 'I_', 'Ge3', 'Xx', 'Xx', 'Se3', 'Te3', 'O_3', 'Xx', 'Xx', 'Xx', 'N_2', 'N_2', 'Xx', 'H_HB', 'H_', 'H_HB', 'C_3', 'H_', 'Xx', 'N_2', 'H_HB', 'Xx', 'C_R', 'N_R', 'N_2', 'Xx', 'Xx', 'Ca', 'Xx', 'Al3', 'Si3', 'O_2', 'C_2', 'O_2', 'Du', 'Du', 'Ni', 'Cu', 'N_3', 'N_2', 'O_3', 'C_2', 'O_3', 'C_3', 'Du', 'Zn', 'C', 'N', 'O', 'S', 'C', 'C', 'C', 'O_3', 'S_3'], 'M3D': ['un.0', 'Mn.0', 'Fe.6', 'Li.0', 'un.0', 'C.4', 'C.3', 'C.3', 'C.2', 'C.3', 'C.3', 'C.4', 'N.4', 'N.4', 'N.3', 'N.3', 'N.3', 'N.2', 'N.3', 'N.3', 'N.3', 'O.4', 'O.4', 'O.3', 'O.R', 'S.4', 'S.2', 'S.4', 'S.3', 'S.4', 'S.4', 'S.4', 'S.2', 'B.0', 'B.0', 'B.0', 'P.4', 'P.4', 'P.4', 'P.4', 'P.4', 'H.1', 'H.1', 'H.1', 'H.1', 'H.1', 'H.1', 'F.1', 'Cl.1', 'Br.1', 'I.1', 'Ge.4', 'Sn.0', 'Pb.0', 'Se.4', 'Te.4', 'O.4', 'ep.1', 'C.4', 'C.3', 'N.3', 'N.3', 'un.0', 'H.1', 'H.0', 'H.1', 'C.4', 'H.1', 'un.0', 'N.3', 'H.1', 'W.0', 'C.R', 'N.R', 'N.3', 'Na.6', 'K.0', 'Ca.6', 'Li.0', 'Al.6', 'Si.4', 'O.3', 'C.3', 'O.R', 'Pd.0', 'Pt.0', 'Ni.0', 'Cu.0', 'N.4', 'N.3', 'O.R', 'C.3', 'O.3', 'C.4', 'V.0', 'Zn.0', 'C.0', 'N.0', 'O.0', 'S.0', 'C.0', 'C.0', 'C.0', 'O.R', 'S.4'], 'MMD': ['62', '62', '62', '62', '61', '3', '2', '2', '1', '2', '2', '10', '32', '26', '25', '25', '25', '24', '26', '25', '35', '16', '16', '15', '20', '49', '52', '49', '49', '49', '49', '49', '49', '54', '54', '55', '53', '53', '53', '53', '53', '41', '45', '48', '48', '48', '48', '56', '57', '58', '59', '62', '62', '62', '62', '62', '23', '63', '10', '12', '29', '36', '62', '42', '44', '43', '3', '43', '62', '25', '42', '62', '2', '25', '25', '25', '0', '0', '0', '0', '60', '18', '11', '15', '62', '62', '62', '62', '32', '25', '20', '11', '20', '3', '62', '62', '62', '62', '62', '62', '62', '62', '62', '20', '49'], 'MOL': ['26', '26', '26', '26', '26', '1', '2', '2', '4', '2', '2', '1', '31', '5', '19', '19', '6', '7', '6', '6', '31', '8', '8', '9', '9', '10', '10', '10', '18', '29', '30', '30', '10', '26', '26', '26', '12', '12', '12', '12', '12', '13', '13', '13', '13', '13', '13', '16', '15', '14', '17', '26', '26', '26', '26', '26', '8', '20', '2', '2', '6', '6', '26', '13', '13', '13', '13', '13', '1', '6', '13', '26', '3', '11', '28', '21', '22', '23', '24', '25', '27', '32', '33', '9', '26', '26', '26', '26', '31', '19', '9', '33', '9', '1', '0', '0', '33', '33', '33', '33', '33', '33', '33', '9', '30'], 'MAP': ['X', 'Mn', 'Fe', 'Li', 'Du', 'C3', 'C2', 'C2', 'C1', 'C2', 'C2', 'C3', 'N3', 'N3', 'N2', 'N2', 'N2', 'N1', 'N2', 'N2', 'N2', 'O3', 'O3', 'O2', 'O2', 'S3', 'S3', 'S3', 'S2', 'S3', 'S3', 'S3', 'S3', 'B2', 'B2', 'B3', 'P3', 'P3', 'P3', 'P3', 'P3', 'H', 'H', 'H', 'H', 'D', 'D', 'F', 'Cl', 'Br', 'I', 'Ge', 'Sn', 'Pb', 'Se', 'Te', 'O', 'Lp', 'C-3', 'C.3', 'N2', 'N2', 'Xx', 'H', 'H', 'H', 'C3', 'H', 'Xx', 'N2', 'H', 'W', 'C2', 'N2', 'N2', 'NA', 'K', 'CA', 'LI', 'AL', 'SI', 'O2', 'C2', 'O2', 'Du', 'Pt', 'Ni', 'Cu', 'N3', 'N2', 'O2', 'C2', 'O3', 'C3', 'V', 'V', 'C', 'N', 'O', 'S', 'C', 'C', 'C', 'O2', 'S3'], 'MM2': ['0', '0', '0', '0', '0', '1', '2', '38', '4', '3', '3', '27', '39', '8', '9', '9', '37', '10', '8', '9', '8', '6', '6', '7', '7', '15', '16', '16', '17', '17', '18', '18', '15', '27', '26', '27', '25', '25', '25', '25', '25', '5', '5', '5', '5', '36', '36', '11', '12', '13', '14', '31', '32', '33', '34', '35', '6', '20', '0', '0', '9', '9', '0', '21', '5', '23', '22', '28', '29', '40', '24', '0', '2', '9', '9', '9', '0', '0', '0', '0', '0', '47', '30', '41', '464', '464', '0', '0', '39', '9', '7', '30', '7', '1', '0', '0', '30', '30', '30', '30', '30', '30', '30', '7', '18'], 'ALC': ['Du', 'Du', 'Du', 'LI', 'Du', 'C3', 'C2', 'C2', 'C1', 'C2', 'C2', 'C3', 'N3+', 'N3', 'NPL3', 'NPL3', 'N2', 'N1', 'N2', 'N2', 'NPL3', 'O3', 'O3', 'O2', 'O2', 'S3', 'S3', 'S3', 'S2', 'SO', 'SO2', 'SO2', 'S3', 'Du', 'Du', 'B', 'P3', 'P3', 'P3', 'P3', 'P3', 'H', 'H', 'H', 'H', 'H', 'H', 'F', 'CL', 'BR', 'I', 'GE', 'SN', 'PB', 'SE', 'TE', 'O', 'Lp', 'C2', 'C2', 'N2', 'N2', 'Du', 'H', 'H', 'H', 'H', 'H', 'C', 'N2', 'H', 'W', 'C2', 'NPL3', 'NPL3', 'Na', 'K', 'Ca', 'Li', 'Al', 'Si', 'O', 'C2', 'O2', 'Du', 'Du', 'Du', 'Du', 'N3+', 'NPL3', 'O2', 'C2', 'O3', 'C3', 'Du', 'Zn', 'C', 'N', 'O', 'S', 'C', 'C', 'C', 'O2', 'SO2'], 'HAD': ['0', '0', '0', '0', '0', '4', '3', '3', '2', '0', '3', '4', '4', '3', '2', '3', '0', '0', '0', '0', '3', '2', '2', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '3', '2', '3', '0', '0', '0', '0', '0', '4', '1', '3', '0', '0', '0', '0', '0', '4', '3', '0', '3', '0', '4', '0', '0', '3', '3', '3', '3', '3', '3', '3', '0', '0'], 'MCML': ['X', 'M', 'M', 'M', 'Z', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'O', 'O', 'O', 'O', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'B', 'B', 'B', 'P', 'P', 'P', 'P', 'P', 'H', 'H', 'H', 'H', 'D', 'D', 'F', 'L', 'R', 'I', 'E', 'X', 'Z', 'Z', 'Z', 'Z', 'Z', 'C', 'C', 'N', 'N', 'Z', 'H', 'H', 'H', 'C', 'H', 'C', 'N', 'O', 'W', 'C', 'N', 'N', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'O', 'C', 'O', 'Z', 'Z', 'M', 'M', 'N', 'N', 'O', 'C', 'O', 'C', 'Z', 'Z', 'C', 'N', 'O', 'S', 'C', 'C', 'C', 'O', 'S'], 'XYZ': ['X', 'Mn', 'Fe', 'Li', 'Du', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'O', 'O', 'O', 'O', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'B', 'B', 'B', 'P', 'P', 'P', 'P', 'P', 'H', 'H', 'H', 'D', 'D', 'D', 'F', 'Cl', 'Br', 'I', 'Ge', 'Sn', 'Pb', 'Se', 'Te', 'O', 'Lp', 'C', 'C', 'N', 'N', 'Du', 'H', 'H', 'H', 'H', 'H', 'C', 'N', 'O', 'W', 'C', 'N', 'N', 'Na', 'K', 'Ca', 'Li', 'Al', 'Si', 'O', 'C', 'O', 'Pd', 'Pt', 'Ni', 'Cu', 'N', 'N', 'O', 'C', 'O', 'C', 'V', 'Zn', 'C', 'N', 'O', 'S', 'C', 'C', 'C', 'O', 'S'], 'C3D': ['0', '258', '266', '258', '0', '64', '63', '63', '62', '63', '63', '64', '79', '73', '72', '72', '72', '71', '72', '72', '79', '82', '82', '81', '86', '164', '164', '164', '161', '161', '161', '161', '164', '53', '53', '53', '159', '159', '159', '154', '159', '11', '11', '11', '12', '19', '19', '91', '171', '351', '531', '324', '504', '824', '342', '0', '82', '10', '61', '0', '72', '78', '0', '11', '11', '11', '64', '11', '64', '72', '11', '744', '2', '37', '9', '9', '190', '200', '97', '133', '19', '47', '2', '81', '464', '464', '284', '000', '79', '72', '86', '2', '86', '64', '234', '234', '2', '2', '2', '2', '2', '2', '2', '86', '161'], 'INT': ['X', 'Mn', 'Fe', 'Li', 'Du', 'C3', 'C2', 'C2', 'C1', 'Cac', 'Cbl', 'C-', 'N3+', 'N3', 'N2', 'Npl', 'Naz', 'N1', 'Nox', 'Ntr', 'Ng+', 'O3', 'Oes', 'O2', 'O-', 'S3', 'S', 'S3+', 'S2', 'Sac', 'So2', 'Sox', 'S', 'Bac', 'Box', 'B', 'P3', 'Pac', 'Pox', 'P3+', 'P', 'HC', 'H-', 'H', 'H', 'DC', 'D', 'F', 'Cl', 'Br', 'I', 'Ge', 'Sn', 'Pb', 'Se', 'Te', 'O', 'Lp', 'C-', 'C.', 'NC', 'N2+', 'Z0', 'HO', 'H+', 'HN', 'C3', 'H', 'Cx', 'N2', 'HO', 'W', 'Car', 'Nar', 'Nam', 'Na', 'K', 'Ca', 'Li', 'Al', 'Si', 'OCO2', 'C+', 'O2', 'Pd', 'Pt', 'Ni', 'Cu', 'N4', 'Npl', 'O-', 'C+', 'O', 'C', 'V', 'Zn', 'Cany', 'Nany', 'Oany', 'Sany', 'Rar', 'R', 'Nr', 'Oco2', 'So'], 'HYB': ['0', '0', '0', '0', '0', '3', '2', '2', '1', '2', '2', '2', '3', '3', '2', '2', '2', '1', '2', '2', '2', '3', '3', '2', '2', '3', '3', '3', '2', '2', '3', '2', '3', '0', '0', '0', '3', '2', '3', '3', '3', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '2', '2', '2', '0', '0', '0', '0', '0', '0', '0', '2', '0', '0', '0', '0', '0', '0', '2', '2', '2', '2', '3', '0', '0', '0', '0', '0', '0', '0', '0', '0', '2', '2'], 'SYB': ['Du', 'Du', 'Du', 'Du', 'Du', 'C.3', 'C.2', 'C.2', 'C.1', 'C.2', 'C.2', 'C.3', 'N.4', 'N.3', 'N.2', 'N.pl3', 'N.2', 'N.1', 'N.4', 'N.pl3', 'N.pl3', 'O.3', 'O.3', 'O.2', 'O.co2', 'S.3', 'S.3', 'S.3', 'S.2', 'S.3', 'S.o2', 'S.o', 'S.3', 'Du', 'Du', 'Du', 'P.3', 'P.3', 'P.3', 'P.3', 'P.3', 'H', 'H', 'H', 'H', 'H', 'H', 'F', 'Cl', 'Br', 'I', 'Du', 'Du', 'Du', 'Du', 'Du', 'O.3', 'LP', 'C.2', 'C.2', 'N.2', 'N.2', 'Du', 'H', 'H', 'H', 'H', 'H', 'C', 'N', 'O', 'W', 'C.ar', 'N.ar', 'N.am', 'Na', 'K', 'Ca', 'Li', 'Al', 'Si', 'O.co2', 'C.cat', 'O.2', 'Du', 'Du', 'Du', 'Du', 'N.4', 'N.pl3N', 'O.co2O', 'C.catC', 'O.3', 'C.3', 'V', 'Zn', 'C.', 'N.', 'O.', 'S.', 'R.ar', 'R.', 'Nr.', 'O.co2', 'S.o2'], 'XED': ['21', '20', '20', '20', '20', '1', '2', '2', '4', '2', '2', '1', '5', '6', '8', '9', '7', '23', '6', '8', '5', '10', '11', '11', '26', '12', '12', '12', '13', '12', '12', '12', '12', '20', '20', '20', '14', '14', '14', '14', '14', '15', '15', '15', '15', '15', '15', '16', '17', '18', '19', '20', '20', '20', '20', '20', '10', '30', '2', '2', '8', '7', '20', '15', '15', '15', '1', '15', '20', '8', '15', '20', '3', '8', '8', '20', '20', '20', '20', '20', '20', '11', '2', '11', '20', '20', '20', '20', '5', '9', '26', '2', '26', '1', '20', '20', '2', '2', '2', '2', '2', '2', '2', '26', '12'], } #END mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/babelElements.py0000644000175000017500000004033607537704063023322 0ustar debiandebian############################################################################# # # Author: Michel F. SANNER # Garrett M. MORRIS # Reimplemented from Babel v1.6 from Pat Walters and Math Stahl # # Copyright: M. Sanner TSRI 2000 # # 2002/08/12 21:55:00 garrett: # Elements sorted according to atomic number by GMM. # # 2002/08/12 21:55:00 garrett: # guess_babel_elements added by GMM, to help make code more forgiving # and less likely to croak. # ############################################################################# # # $Header: /opt/cvs/python/packages/share1.5/PyBabel/babelElements.py,v 1.2 2002/09/11 18:15:15 garrett Exp $ # # $Id: babelElements.py,v 1.2 2002/09/11 18:15:15 garrett Exp $ # # File generated from element.lis # babel_elements = { 'Xx': {'bond_ord_rad': 0.0, 'cov_rad': 0.0, 'bs_rad': 0.0, 'vdw_rad': 0.0, 'max_bonds': 0, 'num': 0, 'rgb': (0.07, 0.5, 0.7)}, 'H': {'bond_ord_rad': 0.352, 'cov_rad': 0.23, 'bs_rad': 0.24, 'vdw_rad': 1.2, 'max_bonds': 1, 'num': 1, 'rgb': (1.0, 1.0, 1.0)}, 'He': {'bond_ord_rad': 0.7, 'cov_rad': 0.7, 'bs_rad': 0.244, 'vdw_rad': 1.22, 'max_bonds': 0, 'num': 2, 'rgb': (1.0, 0.37, 0.08)}, 'Li': {'bond_ord_rad': 1.23, 'cov_rad': 0.68, 'bs_rad': 0.304, 'vdw_rad': 1.52, 'max_bonds': 1, 'num': 3, 'rgb': (0.0, 0.0, 0.1)}, 'Be': {'bond_ord_rad': 0.9, 'cov_rad': 0.35, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 2, 'num': 4, 'rgb': (1.0, 0.37, 0.08)}, 'B': {'bond_ord_rad': 1.0, 'cov_rad': 0.83, 'bs_rad': 0.416, 'vdw_rad': 2.08, 'max_bonds': 3, 'num': 5, 'rgb': (0.07, 0.5, 0.7)}, 'C': {'bond_ord_rad': 0.762, 'cov_rad': 0.68, 'bs_rad': 0.37, 'vdw_rad': 1.85, 'max_bonds': 4, 'num': 6, 'rgb': (0.5, 0.5, 0.5)}, 'N': {'bond_ord_rad': 0.676, 'cov_rad': 0.68, 'bs_rad': 0.308, 'vdw_rad': 1.54, 'max_bonds': 4, 'num': 7, 'rgb': (0.0, 0.0, 1.0)}, 'O': {'bond_ord_rad': 0.64, 'cov_rad': 0.68, 'bs_rad': 0.28, 'vdw_rad': 1.4, 'max_bonds': 2, 'num': 8, 'rgb': (1.0, 0.0, 0.0)}, 'F': {'bond_ord_rad': 0.63, 'cov_rad': 0.64, 'bs_rad': 0.27, 'vdw_rad': 1.35, 'max_bonds': 1, 'num': 9, 'rgb': (0.0, 0.0, 0.1)}, 'Ne': {'bond_ord_rad': 0.7, 'cov_rad': 0.7, 'bs_rad': 0.32, 'vdw_rad': 1.6, 'max_bonds': 0, 'num': 10, 'rgb': (1.0, 0.37, 0.08)}, 'Na': {'bond_ord_rad': 1.54, 'cov_rad': 0.97, 'bs_rad': 0.462, 'vdw_rad': 2.31, 'max_bonds': 1, 'num': 11, 'rgb': (0.0, 0.0, 0.1)}, 'Mg': {'bond_ord_rad': 1.36, 'cov_rad': 1.1, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 2, 'num': 12, 'rgb': (0.0, 0.0, 0.1)}, 'Al': {'bond_ord_rad': 1.18, 'cov_rad': 1.35, 'bs_rad': 0.41, 'vdw_rad': 2.05, 'max_bonds': 6, 'num': 13, 'rgb': (0.0, 0.0, 0.1)}, 'Si': {'bond_ord_rad': 1.118, 'cov_rad': 1.2, 'bs_rad': 0.4, 'vdw_rad': 2.0, 'max_bonds': 6, 'num': 14, 'rgb': (0.7, 0.0, 0.1)}, 'P': {'bond_ord_rad': 1.094, 'cov_rad': 0.75, 'bs_rad': 0.38, 'vdw_rad': 1.4, 'max_bonds': 5, 'num': 15, 'rgb': (0.5, 0.1, 0.8)}, 'S': {'bond_ord_rad': 1.053, 'cov_rad': 1.02, 'bs_rad': 0.37, 'vdw_rad': 1.85, 'max_bonds': 6, 'num': 16, 'rgb': (1.0, 1.0, 0.0)}, 'Cl': {'bond_ord_rad': 1.033, 'cov_rad': 0.99, 'bs_rad': 0.362, 'vdw_rad': 1.81, 'max_bonds': 1, 'num': 17, 'rgb': (0.0, 0.0, 0.1)}, 'Ar': {'bond_ord_rad': 1.74, 'cov_rad': 0.7, 'bs_rad': 0.382, 'vdw_rad': 1.91, 'max_bonds': 0, 'num': 18, 'rgb': (1.0, 0.37, 0.08)}, 'K': {'bond_ord_rad': 2.03, 'cov_rad': 1.33, 'bs_rad': 0.462, 'vdw_rad': 2.31, 'max_bonds': 1, 'num': 19, 'rgb': (0.0, 0.0, 0.1)}, 'Ca': {'bond_ord_rad': 1.74, 'cov_rad': 0.99, 'bs_rad': 0.395, 'vdw_rad': 1.973, 'max_bonds': 2, 'num': 20, 'rgb': (0.0, 0.0, 0.1)}, 'Sc': {'bond_ord_rad': 1.44, 'cov_rad': 1.44, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 21, 'rgb': (0.05, 0.05, 0.5)}, 'Ti': {'bond_ord_rad': 1.32, 'cov_rad': 1.47, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 22, 'rgb': (0.05, 0.05, 0.5)}, 'V': {'bond_ord_rad': 1.22, 'cov_rad': 1.33, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 23, 'rgb': (0.05, 0.05, 0.5)}, 'Cr': {'bond_ord_rad': 1.18, 'cov_rad': 1.35, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 24, 'rgb': (0.05, 0.05, 0.5)}, 'Mn': {'bond_ord_rad': 1.17, 'cov_rad': 1.35, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 8, 'num': 25, 'rgb': (0.05, 0.05, 0.5)}, 'Fe': {'bond_ord_rad': 1.17, 'cov_rad': 1.34, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 26, 'rgb': (0.7, 0.0, 0.1)}, 'Co': {'bond_ord_rad': 1.16, 'cov_rad': 1.33, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 27, 'rgb': (0.05, 0.05, 0.5)}, 'Ni': {'bond_ord_rad': 1.15, 'cov_rad': 1.5, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 28, 'rgb': (0.05, 0.05, 0.5)}, 'Cu': {'bond_ord_rad': 1.17, 'cov_rad': 1.52, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 29, 'rgb': (0.05, 0.05, 0.5)}, 'Zn': {'bond_ord_rad': 1.25, 'cov_rad': 1.45, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 30, 'rgb': (0.05, 0.05, 0.5)}, 'Ga': {'bond_ord_rad': 1.26, 'cov_rad': 1.22, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 3, 'num': 31, 'rgb': (0.05, 0.05, 0.5)}, 'Ge': {'bond_ord_rad': 1.188, 'cov_rad': 1.17, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 4, 'num': 32, 'rgb': (0.05, 0.05, 0.5)}, 'As': {'bond_ord_rad': 1.2, 'cov_rad': 1.21, 'bs_rad': 0.4, 'vdw_rad': 2.0, 'max_bonds': 3, 'num': 33, 'rgb': (0.4, 1.0, 0.1)}, 'Se': {'bond_ord_rad': 1.187, 'cov_rad': 1.22, 'bs_rad': 0.4, 'vdw_rad': 2.0, 'max_bonds': 2, 'num': 34, 'rgb': (0.8, 1.0, 0.1)}, 'Br': {'bond_ord_rad': 1.187, 'cov_rad': 1.21, 'bs_rad': 0.42, 'vdw_rad': 2.1, 'max_bonds': 1, 'num': 35, 'rgb': (0.0, 0.0, 0.1)}, 'Kr': {'bond_ord_rad': 1.91, 'cov_rad': 1.91, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 0, 'num': 36, 'rgb': (1.0, 0.37, 0.08)}, 'Rb': {'bond_ord_rad': 2.16, 'cov_rad': 1.47, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 1, 'num': 37, 'rgb': (0.05, 0.05, 0.5)}, 'Sr': {'bond_ord_rad': 1.91, 'cov_rad': 1.12, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 2, 'num': 38, 'rgb': (0.05, 0.05, 0.5)}, 'Y': {'bond_ord_rad': 1.62, 'cov_rad': 1.78, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 39, 'rgb': (0.05, 0.05, 0.5)}, 'Zr': {'bond_ord_rad': 1.45, 'cov_rad': 1.56, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 40, 'rgb': (0.05, 0.05, 0.5)}, 'Nb': {'bond_ord_rad': 1.34, 'cov_rad': 1.48, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 41, 'rgb': (0.05, 0.05, 0.5)}, 'Mo': {'bond_ord_rad': 1.3, 'cov_rad': 1.47, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 42, 'rgb': (0.05, 0.05, 0.5)}, 'Tc': {'bond_ord_rad': 1.27, 'cov_rad': 1.35, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 43, 'rgb': (0.05, 0.05, 0.5)}, 'Ru': {'bond_ord_rad': 1.25, 'cov_rad': 1.4, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 44, 'rgb': (0.05, 0.05, 0.5)}, 'Rh': {'bond_ord_rad': 1.25, 'cov_rad': 1.45, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 45, 'rgb': (0.05, 0.05, 0.5)}, 'Pd': {'bond_ord_rad': 1.28, 'cov_rad': 1.5, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 46, 'rgb': (0.05, 0.05, 0.5)}, 'Ag': {'bond_ord_rad': 1.34, 'cov_rad': 1.59, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 47, 'rgb': (0.05, 0.05, 0.5)}, 'Cd': {'bond_ord_rad': 1.48, 'cov_rad': 1.69, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 48, 'rgb': (0.05, 0.05, 0.5)}, 'In': {'bond_ord_rad': 1.44, 'cov_rad': 1.63, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 3, 'num': 49, 'rgb': (0.05, 0.05, 0.5)}, 'Sn': {'bond_ord_rad': 1.385, 'cov_rad': 1.46, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 4, 'num': 50, 'rgb': (0.05, 0.05, 0.5)}, 'Sb': {'bond_ord_rad': 1.4, 'cov_rad': 1.46, 'bs_rad': 0.44, 'vdw_rad': 2.2, 'max_bonds': 3, 'num': 51, 'rgb': (0.05, 0.05, 0.5)}, 'Te': {'bond_ord_rad': 1.378, 'cov_rad': 1.47, 'bs_rad': 0.44, 'vdw_rad': 2.2, 'max_bonds': 2, 'num': 52, 'rgb': (0.05, 0.05, 0.5)}, 'I': {'bond_ord_rad': 1.387, 'cov_rad': 1.4, 'bs_rad': 0.43, 'vdw_rad': 2.15, 'max_bonds': 1, 'num': 53, 'rgb': (0.05, 0.05, 0.5)}, 'Xe': {'bond_ord_rad': 1.98, 'cov_rad': 1.98, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 0, 'num': 54, 'rgb': (0.05, 0.05, 0.5)}, 'Cs': {'bond_ord_rad': 2.35, 'cov_rad': 1.67, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 1, 'num': 55, 'rgb': (0.05, 0.05, 0.5)}, 'Ba': {'bond_ord_rad': 1.98, 'cov_rad': 1.34, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 2, 'num': 56, 'rgb': (0.05, 0.05, 0.5)}, 'La': {'bond_ord_rad': 1.69, 'cov_rad': 1.87, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 12, 'num': 57, 'rgb': (0.05, 0.05, 0.5)}, 'Ce': {'bond_ord_rad': 1.83, 'cov_rad': 1.83, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 58, 'rgb': (0.05, 0.05, 0.5)}, 'Pr': {'bond_ord_rad': 1.82, 'cov_rad': 1.82, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 59, 'rgb': (0.05, 0.05, 0.5)}, 'Nd': {'bond_ord_rad': 1.81, 'cov_rad': 1.81, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 60, 'rgb': (0.05, 0.05, 0.5)}, 'Pm': {'bond_ord_rad': 1.8, 'cov_rad': 1.8, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 61, 'rgb': (0.05, 0.05, 0.5)}, 'Sm': {'bond_ord_rad': 1.8, 'cov_rad': 1.8, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 62, 'rgb': (0.05, 0.05, 0.5)}, 'Eu': {'bond_ord_rad': 1.99, 'cov_rad': 1.99, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 63, 'rgb': (0.05, 0.05, 0.5)}, 'Gd': {'bond_ord_rad': 1.79, 'cov_rad': 1.79, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 64, 'rgb': (0.05, 0.05, 0.5)}, 'Tb': {'bond_ord_rad': 1.76, 'cov_rad': 1.76, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 65, 'rgb': (0.05, 0.05, 0.5)}, 'Dy': {'bond_ord_rad': 1.75, 'cov_rad': 1.75, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 66, 'rgb': (0.05, 0.05, 0.5)}, 'Ho': {'bond_ord_rad': 1.74, 'cov_rad': 1.74, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 67, 'rgb': (0.05, 0.05, 0.5)}, 'Er': {'bond_ord_rad': 1.73, 'cov_rad': 1.73, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 68, 'rgb': (0.05, 0.05, 0.5)}, 'Tm': {'bond_ord_rad': 1.72, 'cov_rad': 1.72, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 69, 'rgb': (0.05, 0.05, 0.5)}, 'Yb': {'bond_ord_rad': 1.94, 'cov_rad': 1.94, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 70, 'rgb': (0.05, 0.05, 0.5)}, 'Lu': {'bond_ord_rad': 1.72, 'cov_rad': 1.72, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 71, 'rgb': (0.05, 0.05, 0.5)}, 'Hf': {'bond_ord_rad': 1.44, 'cov_rad': 1.57, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 72, 'rgb': (0.05, 0.05, 0.5)}, 'Ta': {'bond_ord_rad': 1.34, 'cov_rad': 1.43, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 73, 'rgb': (0.05, 0.05, 0.5)}, 'W': {'bond_ord_rad': 1.3, 'cov_rad': 1.37, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 74, 'rgb': (0.05, 0.05, 0.5)}, 'Re': {'bond_ord_rad': 1.28, 'cov_rad': 1.35, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 75, 'rgb': (0.05, 0.05, 0.5)}, 'Os': {'bond_ord_rad': 1.26, 'cov_rad': 1.37, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 76, 'rgb': (0.05, 0.05, 0.5)}, 'Ir': {'bond_ord_rad': 1.27, 'cov_rad': 1.32, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 77, 'rgb': (0.05, 0.05, 0.5)}, 'Pt': {'bond_ord_rad': 1.3, 'cov_rad': 1.5, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 78, 'rgb': (0.05, 0.05, 0.5)}, 'Au': {'bond_ord_rad': 1.34, 'cov_rad': 1.5, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 79, 'rgb': (0.05, 0.05, 0.5)}, 'Hg': {'bond_ord_rad': 1.49, 'cov_rad': 1.7, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 80, 'rgb': (0.05, 0.05, 0.5)}, 'Tl': {'bond_ord_rad': 1.48, 'cov_rad': 1.55, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 3, 'num': 81, 'rgb': (0.05, 0.05, 0.5)}, 'Pb': {'bond_ord_rad': 1.48, 'cov_rad': 1.54, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 4, 'num': 82, 'rgb': (0.05, 0.05, 0.5)}, 'Bi': {'bond_ord_rad': 1.45, 'cov_rad': 1.54, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 3, 'num': 83, 'rgb': (0.05, 0.05, 0.5)}, 'Po': {'bond_ord_rad': 1.46, 'cov_rad': 1.68, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 2, 'num': 84, 'rgb': (0.05, 0.05, 0.5)}, 'At': {'bond_ord_rad': 1.45, 'cov_rad': 0.7, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 1, 'num': 85, 'rgb': (0.05, 0.05, 0.5)}, 'Rn': {'bond_ord_rad': 2.4, 'cov_rad': 2.4, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 0, 'num': 86, 'rgb': (0.05, 0.05, 0.5)}, 'Fr': {'bond_ord_rad': 2.0, 'cov_rad': 2.0, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 1, 'num': 87, 'rgb': (0.05, 0.05, 0.5)}, 'Ra': {'bond_ord_rad': 1.9, 'cov_rad': 1.9, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 2, 'num': 88, 'rgb': (0.05, 0.05, 0.5)}, 'Ac': {'bond_ord_rad': 1.88, 'cov_rad': 1.88, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 89, 'rgb': (0.05, 0.05, 0.5)}, 'Th': {'bond_ord_rad': 1.79, 'cov_rad': 1.79, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 90, 'rgb': (0.05, 0.05, 0.5)}, 'Pa': {'bond_ord_rad': 1.61, 'cov_rad': 1.61, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 91, 'rgb': (0.05, 0.05, 0.5)}, 'U': {'bond_ord_rad': 1.58, 'cov_rad': 1.58, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 92, 'rgb': (0.05, 0.05, 0.5)}, 'Np': {'bond_ord_rad': 1.55, 'cov_rad': 1.55, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 93, 'rgb': (0.05, 0.05, 0.5)}, 'Pu': {'bond_ord_rad': 1.53, 'cov_rad': 1.53, 'bs_rad': 0.18, 'vdw_rad': 0.9, 'max_bonds': 6, 'num': 94, 'rgb': (0.05, 0.05, 0.5)}, 'Am': {'bond_ord_rad': 1.07, 'cov_rad': 1.51, 'bs_rad': 0.0, 'vdw_rad': 0.0, 'max_bonds': 0, 'num': 95, 'rgb': (0.05, 0.05, 0.5)}, 'Cm': {'bond_ord_rad': 0.0, 'cov_rad': 0.0, 'bs_rad': 0.0, 'vdw_rad': 0.0, 'max_bonds': 0, 'num': 96, 'rgb': (0.05, 0.05, 0.5)}, 'Bk': {'bond_ord_rad': 0.0, 'cov_rad': 0.0, 'bs_rad': 0.0, 'vdw_rad': 0.0, 'max_bonds': 0, 'num': 97, 'rgb': (0.05, 0.05, 0.5)}, 'Cf': {'bond_ord_rad': 0.0, 'cov_rad': 0.0, 'bs_rad': 0.0, 'vdw_rad': 0.0, 'max_bonds': 0, 'num': 98, 'rgb': (0.05, 0.05, 0.5)}, 'Es': {'bond_ord_rad': 0.0, 'cov_rad': 0.0, 'bs_rad': 0.0, 'vdw_rad': 0.0, 'max_bonds': 0, 'num': 99, 'rgb': (0.05, 0.05, 0.5)}, 'Fm': {'bond_ord_rad': 0.0, 'cov_rad': 0.0, 'bs_rad': 0.0, 'vdw_rad': 0.0, 'max_bonds': 0, 'num': 100, 'rgb': (0.05, 0.05, 0.5)}, 'Md': {'bond_ord_rad': 0.0, 'cov_rad': 0.0, 'bs_rad': 0.0, 'vdw_rad': 0.0, 'max_bonds': 0, 'num': 101, 'rgb': (0.05, 0.05, 0.5)}, 'No': {'bond_ord_rad': 0.0, 'cov_rad': 0.0, 'bs_rad': 0.0, 'vdw_rad': 0.0, 'max_bonds': 0, 'num': 102, 'rgb': (0.05, 0.05, 0.5)}, 'Lr': {'bond_ord_rad': 0.0, 'cov_rad': 0.0, 'bs_rad': 0.0, 'vdw_rad': 0.0, 'max_bonds': 0, 'num': 106, 'rgb': (0.05, 0.05, 0.5)}, 'D': {'bond_ord_rad': 0.346, 'cov_rad': 0.23, 'bs_rad': 0.24, 'vdw_rad': 1.2, 'max_bonds': 1, 'num': 107, 'rgb': (1.0, 1.0, 1.0)}, } # # guess_babel_elements # # These atom types are based on the assumption that the atom name in the molecule # is only 1 character, and these assignments are the most likely equivalent # if the second letter is missing. This dictionary should be consulted only if # the previous dictionary babel_elements failed to contain the desired element. # guess_babel_elements = { 'X': {'bond_ord_rad': 0.0, 'cov_rad': 0.0, 'bs_rad': 0.0, 'vdw_rad': 0.0, 'max_bonds': 0, 'num': 0, 'rgb': (0.07, 0.5, 0.7)}, 'L': {'bond_ord_rad': 1.23, 'cov_rad': 0.68, 'bs_rad': 0.304, 'vdw_rad': 1.52, 'max_bonds': 1, 'num': 3, 'rgb': (0.0, 0.0, 0.1)}, 'T': {'bond_ord_rad': 1.32, 'cov_rad': 1.47, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 22, 'rgb': (0.05, 0.05, 0.5)}, 'V': {'bond_ord_rad': 1.22, 'cov_rad': 1.33, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 23, 'rgb': (0.05, 0.05, 0.5)}, 'M': {'bond_ord_rad': 1.17, 'cov_rad': 1.35, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 8, 'num': 25, 'rgb': (0.05, 0.05, 0.5)}, 'F': {'bond_ord_rad': 1.17, 'cov_rad': 1.34, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 26, 'rgb': (0.7, 0.0, 0.1)}, 'Z': {'bond_ord_rad': 1.25, 'cov_rad': 1.45, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 30, 'rgb': (0.05, 0.05, 0.5)}, 'G': {'bond_ord_rad': 1.26, 'cov_rad': 1.22, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 3, 'num': 31, 'rgb': (0.05, 0.05, 0.5)}, 'R': {'bond_ord_rad': 2.16, 'cov_rad': 1.47, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 1, 'num': 37, 'rgb': (0.05, 0.05, 0.5)}, 'E': {'bond_ord_rad': 1.99, 'cov_rad': 1.99, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 63, 'rgb': (0.05, 0.05, 0.5)}, 'A': {'bond_ord_rad': 1.34, 'cov_rad': 1.5, 'bs_rad': 0.34, 'vdw_rad': 1.7, 'max_bonds': 6, 'num': 79, 'rgb': (0.05, 0.05, 0.5)}, 'D': {'bond_ord_rad': 0.346, 'cov_rad': 0.23, 'bs_rad': 0.24, 'vdw_rad': 1.2, 'max_bonds': 1, 'num': 107, 'rgb': (1.0, 1.0, 1.0)}, } #END mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/Tests/0000755000175000017500000000000012146213337021271 5ustar debiandebianmgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/Tests/test_cycles.py0000644000175000017500000000552007723711205024170 0ustar debiandebianimport sys, string from mglutil.regression import testplus class Atom: def __init__(self, coords): self.coords = coords self.bonds = [] class Bond: def __init__(self, atom1, atom2): self.atom1 = atom1 self.atom2 = atom2 self.atom1.bonds.append(self) self.atom2.bonds.append(self) def getGraphFromFile(filename): f = open(filename) nba = int(f.readline()) atoms = [] for i in range(nba): data = string.split(f.readline()) x,y,z = map( float, data) atoms.append(Atom((x,y,z))) bonds = [] nbb = int(f.readline()) for i in range(nbb): data = string.split(f.readline()) at1,at2 = map( int, data) bonds.append( Bond( atoms[at1], atoms[at2] ) ) return atoms, bonds def test_findCycles4(): # test that atoms in cycles are ordered on taxol atoms, bonds = getGraphFromFile('Data/txp.graph') from PyBabel.cycle import RingFinder rings = RingFinder() rings.findRings2(atoms, bonds) def hasBond(a1, a2, cycleHasBond): for b in cyclebonds: if b.atom1==a1 and b.atom2==a2: return 1 elif b.atom1==a2 and b.atom2==a1: return 1 return 0 def isOrdered(cycleatoms, cyclebonds): def hasBond(a1, a2, cyclebonds): for b in cyclebonds: if b.atom1==a1 and b.atom2==a2: return 1 elif b.atom1==a2 and b.atom2==a1: return 1 return 0 start = cycleatoms[0] for end in cycleatoms[1:]: if not hasBond(start, end, cyclebonds): return 0 start = end return 1 for r in rings.rings: assert isOrdered(r['atoms'], r['bonds']) def test_findCycles1(): # test cycle detection on taxol atoms, bonds = getGraphFromFile('Data/txp.graph') from PyBabel.cycle import RingFinder rings = RingFinder() rings.findRings2(atoms, bonds) assert rings.ringCount==6 def test_findCycles2(): # test cycle detection on modified taxol to have 5 membered ring atoms, bonds = getGraphFromFile('Data/fuzedRings2.graph') from PyBabel.cycle import RingFinder rings = RingFinder() rings.findRings2(atoms, bonds) assert rings.ringCount==4 def test_findCycles3(): # test cycle detection on taxol merged rings only atoms, bonds = getGraphFromFile('Data/fuzedRings1.graph') from PyBabel.cycle import RingFinder rings = RingFinder() rings.findRings2(atoms, bonds) assert rings.ringCount==4 harness = testplus.TestHarness( "PyBabel_cycles", funs = testplus.testcollect( globals()), ) if __name__ == '__main__': testplus.chdir() print harness sys.exit( len( harness)) mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/Tests/Data/0000755000175000017500000000000012146213337022142 5ustar debiandebianmgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/Tests/Data/fuzedRings1.graph0000644000175000017500000000116507723711205025373 0ustar debiandebian18 16.249000 3.187000 -2.243000 15.723000 3.736000 -3.656000 15.856000 2.917000 -4.383000 16.403000 5.029000 -4.338000 15.353000 6.155000 -4.768000 15.697000 7.184000 -5.892000 16.996000 7.007000 -6.703000 18.082000 6.221000 -5.953000 17.621000 4.818000 -5.379000 18.992000 4.236000 -4.798000 19.555000 4.413000 -3.353000 18.597000 4.094000 -2.197000 18.333000 5.033000 -1.232000 17.090000 4.858000 -0.324000 15.891000 4.217000 -1.093000 17.784000 2.741000 -2.213000 14.220000 5.781000 -5.751000 14.578000 6.792000 -6.697000 21 0 14 0 15 5 6 0 1 10 11 7 8 9 10 3 4 16 17 11 15 11 12 5 17 13 14 4 5 1 3 3 8 6 7 12 13 1 2 8 9 4 16 mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/Tests/Data/fuzedRings2.graph0000644000175000017500000000112207723711205025365 0ustar debiandebian17 16.249000 3.187000 -2.243000 15.723000 3.736000 -3.656000 15.856000 2.917000 -4.383000 16.403000 5.029000 -4.338000 15.353000 6.155000 -4.768000 15.697000 7.184000 -5.892000 16.996000 7.007000 -6.703000 18.082000 6.221000 -5.953000 17.621000 4.818000 -5.379000 18.992000 4.236000 -4.798000 19.555000 4.413000 -3.353000 18.597000 4.094000 -2.197000 18.333000 5.033000 -1.232000 15.891000 4.217000 -1.093000 17.784000 2.741000 -2.213000 14.220000 5.781000 -5.751000 14.578000 6.792000 -6.697000 20 6 7 8 9 10 11 7 8 5 16 0 13 3 8 12 13 0 14 0 1 11 12 4 5 11 14 15 16 5 6 9 10 1 2 3 4 1 3 4 15 mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/Tests/Data/txp.graph0000644000175000017500000000744207723711205024011 0ustar debiandebian111 16.249000 3.187000 -2.243000 15.723000 3.736000 -3.656000 15.856000 2.917000 -4.383000 16.403000 5.029000 -4.338000 16.890000 5.547000 -3.499000 15.353000 6.155000 -4.768000 15.697000 7.184000 -5.892000 15.581000 8.231000 -5.551000 16.996000 7.007000 -6.703000 17.385000 7.997000 -7.003000 16.777000 6.499000 -7.661000 18.082000 6.221000 -5.953000 18.419000 6.859000 -5.108000 17.621000 4.818000 -5.379000 18.992000 4.236000 -4.798000 19.555000 4.413000 -3.353000 19.874000 5.471000 -3.343000 18.597000 4.094000 -2.197000 18.333000 5.033000 -1.232000 17.090000 4.858000 -0.324000 17.416000 4.165000 0.470000 15.891000 4.217000 -1.093000 15.223000 3.753000 -0.343000 15.277000 5.043000 -1.493000 17.784000 2.741000 -2.213000 18.100000 1.687000 -3.334000 17.811000 2.001000 -4.344000 19.177000 1.440000 -3.397000 17.559000 0.733000 -3.187000 18.221000 1.872000 -0.979000 17.685000 0.904000 -0.931000 19.303000 1.639000 -0.987000 18.026000 2.321000 0.000000 19.184000 6.279000 -1.006000 20.264000 6.083000 -1.143000 18.895000 7.089000 -1.701000 19.079000 6.680000 0.018000 17.138000 3.907000 -6.567000 16.219000 4.275000 -7.052000 17.887000 3.853000 -7.380000 16.950000 2.861000 -6.271000 14.220000 5.781000 -5.751000 13.200000 5.939000 -5.353000 14.291000 4.764000 -6.177000 15.480000 2.019000 -1.929000 14.992000 1.777000 -2.726000 14.276000 3.959000 -3.512000 14.712000 6.789000 -3.614000 14.578000 6.792000 -6.697000 19.166000 6.109000 -6.881000 19.534000 5.222000 -6.766000 19.745000 3.660000 -5.595000 20.704000 3.625000 -3.055000 20.491000 3.219000 -2.210000 16.639000 6.094000 0.317000 16.081000 5.996000 1.591000 15.833000 4.940000 2.183000 15.791000 7.379000 2.223000 16.420000 8.106000 1.675000 16.232000 7.392000 3.590000 16.030000 8.265000 3.941000 14.308000 7.861000 2.085000 14.177000 8.018000 0.997000 14.069000 9.251000 2.756000 14.000000 9.412000 4.153000 14.061000 8.552000 4.804000 13.845000 10.676000 4.716000 13.792000 10.789000 5.790000 13.755000 11.795000 3.895000 13.637000 12.777000 4.332000 13.813000 11.655000 2.512000 13.738000 12.527000 1.877000 13.969000 10.392000 1.946000 14.015000 10.310000 0.869000 13.295000 6.857000 2.540000 13.364000 6.403000 3.455000 12.557000 6.124000 1.701000 12.621000 6.319000 0.483000 11.731000 5.167000 2.279000 10.849000 4.288000 1.515000 10.147000 3.406000 2.556000 9.583000 4.013000 3.287000 9.433000 2.697000 2.098000 10.874000 2.809000 3.136000 9.760000 5.075000 0.760000 10.197000 5.720000 -0.024000 9.034000 4.410000 0.258000 9.194000 5.738000 1.439000 11.626000 3.364000 0.557000 12.421000 2.807000 1.086000 10.972000 2.624000 0.060000 12.124000 3.936000 -0.247000 13.350000 2.941000 -3.711000 13.697000 1.788000 -3.997000 11.840000 3.267000 -3.533000 11.428000 4.563000 -3.188000 12.149000 5.354000 -3.029000 10.074000 4.854000 -3.032000 9.763000 5.854000 -2.763000 9.122000 3.856000 -3.213000 8.073000 4.082000 -3.094000 9.518000 2.565000 -3.549000 8.778000 1.789000 -3.686000 10.869000 2.271000 -3.710000 11.159000 1.262000 -3.972000 15.390000 7.718000 -2.837000 16.579000 8.022000 -2.942000 14.473000 8.362000 -1.827000 13.673000 8.929000 -2.334000 13.998000 7.587000 -1.203000 15.029000 9.054000 -1.172000 116 94 103 68 69 80 82 5 6 37 38 52 53 55 57 103 104 68 70 18 33 13 14 41 48 92 94 19 21 74 75 17 18 6 7 57 58 33 36 88 90 54 55 1 46 41 42 41 43 95 97 29 32 84 85 74 76 11 13 70 71 57 59 25 28 79 80 8 10 61 63 29 30 6 8 15 52 14 51 57 61 107 108 46 92 29 31 25 26 64 66 101 103 70 72 37 40 0 44 25 27 49 50 92 93 15 17 33 34 59 60 63 72 37 39 1 3 19 20 84 87 21 22 94 95 8 9 33 35 107 109 3 5 24 29 15 16 80 83 79 84 18 19 21 23 8 11 14 15 47 105 0 21 64 65 19 54 1 2 84 86 63 64 66 67 44 45 11 49 11 12 72 73 3 13 66 68 0 1 3 4 24 25 88 89 99 100 55 56 5 41 17 24 5 47 6 48 95 96 80 81 76 77 105 107 79 88 97 99 97 98 0 24 61 62 107 110 13 37 99 101 105 106 88 91 61 74 76 78 101 102 78 79 mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/Tests/__init__.py0000644000175000017500000000004510473340316023400 0ustar debiandebian#ignore = {"test_dependencies" : []} mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/Tests/test_dependencies.py0000644000175000017500000000161311216031312025315 0ustar debiandebian# ################################################################# # Author: Sowjanya Karnati ################################################################# # #Purpose:To update dependencies list # # $Id: test_dependencies.py,v 1.5 2009/06/17 00:03:22 vareille Exp $ from mglutil.TestUtil.Tests.dependenciestest import DependencyTester import unittest,sys, os d = DependencyTester() result_expected =[] class test_dep(unittest.TestCase): def test_dep_1(self): if os.name != 'nt': #sys.platform != 'win32': result = d.rundeptester('PyBabel') if result !=[]: print "\nThe Following Packages are not present in CRITICAL or NONCRITICAL DEPENDENCIES of PyBabel :\n %s" %result self.assertEqual(result,result_expected) else: self.assertEqual(result,result_expected) if __name__ == '__main__': unittest.main() mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/__init__.py0000644000175000017500000002272210405661700022302 0ustar debiandebian############################################################################# # # Author: Michel F. SANNER # Reimplemented from Babel v1.6 from Pat Walters and Math Stahl # # Copyright: M. Sanner TSRI 2000 # ############################################################################# # # $Header: /opt/cvs/python/packages/share1.5/PyBabel/__init__.py,v 1.10 2006/03/15 00:45:52 annao Exp $ # # $Id: __init__.py,v 1.10 2006/03/15 00:45:52 annao Exp $ # # """ PyBabel v0.1alpha This a Python re-implmentation of some of Babel v1.6 functionalities, including: - Atom hybridization assignment (from geometry) - Gasteiger charges calculations - atom type conversions - properties from atom element name - finding rings - assigning bond orders - identifying aromatic rings - adding hydrogen atoms I - Atom hybridization assignment: The AtomHybridization class allows to assign atom types. example: >>> #create an instance of AtomHybridization >>> from PyBabel.atomTypes import AtomHybridization >>> babel = AtomHybridization() >>> babel.assignHybridization(allAtoms) allAtoms is a list of 'Atom' objects having the following members: - a.element : atom's chemical element symbol (string, 2 character max, second character lower case) - a.coords : 3-sequence of floats (tuple, float or array) - a.bonds : list of Bond objects Bond are objects having the following members: - b.atom1 : instance of Atom - b.atom2 : instance of Atom After completion each atom has the following additional members: - babel_type : string - babel_atomic_number : int - babel_organic : 0/1 II - Gasteiger charges calculations: Before Gasteiger charges can be calculated, babel AtomHybridization as to be assigned (see I). example: >>> #create an instance of AtomHybridization >>> from PyBabel.atomTypes import AtomHybridization >>> babel = AtomHybridization() >>> babel.assignHybridization(allAtoms) >>> >>> from PyBabel.gasteiger import Gasteiger >>> Gast = Gasteiger() >>> Gast.compute(allAtoms) allAtoms is a list of 'Atom' objects having the following members: * Atom: - a.babel_type - a.babel_atomic_number - a.bonds After completion each atom has a gast_charge member III - types conversion Before atom types can be obtained, babel's internal types have to be assigned (see I) example: >>> #create an instance of AtomHybridization >>> from PyBabel.atomTypes import AtomHybridization >>> babel = AtomHybridization() >>> babel.assignHybridization(allAtoms) >>> >>> from PyBabel.atomTypes import AtomHybridization >>> converter = TypeConverter('SYB') >>> newTypes = map( converter.convert, allAtoms.babel_type) IV - properties from atom element name Before atom properties can be obtained, babel's internal types have to be assigned (see I) example: >>> #create an instance of AtomHybridization >>> from PyBabel.atomTypes import AtomHybridization >>> babel = AtomHybridization() >>> babel.assignHybridization(allAtoms) >>> >>> rad = babel.getProperty('vdw_rad', allAtoms.element) valid property names are: - 'num' - 'cov_rad' - 'bond_ord_rad' - 'vdw_rad' - 'bs_rad' - 'max_bonds' - 'rgb' V - finding rings: This algorithm is different from the one used in Babel to avoid the N^2 complexity in number of bonds. When rings are nested the smalest rings are reported. The algorithms might fail to report all rings if all the atoms in some rings belong to multiple rings. example: >>> #create an instance of RingFinder object >>> from PyBabel.cycle import RingFinder >>> r = RingFinder() >>> r.findRings(atoms, bonds) >>> r.printRings() atoms has to be a list of Atom objects * Atom: - a.coords : 3-sequence of floats - a.bonds : list of Bond objects * Bond: - b.atom1 : instance of Atom - b.atom2 : instance of Atom After completion the RingFinder object has the following members: - ringCount: number of rings - rings : a list of rings. A ring is a dictionary with 2 keys 'atoms' and 'bonds' - allRingAtoms: list of atoms that are in rings(atoms may appear twice) - allRingBonds: list of bonds that are in rings(bonds may appear twice) In addition: atoms involved in rings have a member 'ring' that is a list of rings they belong to (0-based list of integers) VI - assigning bond orders: The BondOrder class that can be used to compute bond order. Before a BondOrder object can be used, atoms must have been assigned a type (see I) Bond order can be calculated using 2 different methods depending on whether rings have been identified previously or not. Babel decides to use the first method for molecules with more than 200 atoms and the second one else. example: >>> #create an instance of AtomHybridization >>> from PyBabel.atomTypes import AtomHybridization >>> atype = AtomHybridization() >>> atype.assignHybridization(atoms) >>> #create an instance of BondOrder object >>> from PyBabel.bo import BondOrder >>> bo = BondOrder() >>> bo.assignBondOrder( atoms, bonds ) or >>> #create an instance of AtomHybridization >>> from PyBabel.atomTypes import AtomHybridization >>> atype = AtomHybridization() >>> atype.assignHybridization(atoms) >>> from PyBabel.cycle import RingFinder >>> rings = RingFinder() >>> rings.findRings(allAtoms, bonds) >>> from PyBabel.bo import BondOrder >>> bo = BondOrder() >>> bo.assignBondOrder( atoms, bonds, rings ) atoms has to be a list of atom objects * Atom: - a.coords : 3-sequence of floats - a.bonds : list of Bond objects - babel_type: string - babel_atomic_number: int * Bond: - b.atom1 : instance of Atom - b.atom2 : instance of Atom After completion each bond has a 'bondOrder' attribute (integer) VII - identifying aromatic rings Before this Aromatic object can be used to identify aromatic rings, 1. atoms must have been assigned a type (see I) 2. rings must have been identified (see V) 3. bond orders must have been defined (see VI) example: >>> #create an instance of AtomHybridization >>> from PyBabel.atomTypes import AtomHybridization >>> atype = AtomHybridization() >>> atype.assignHybridization(atoms) >>> from PyBabel.cycle import RingFinder >>> rings = RingFinder() >>> rings.findRings(atoms, bonds) >>> from PyBabel.bo import BondOrder >>> bo = BondOrder() >>> bo.assignBondOrder(atoms, bonds, rings) >>> from PyBabel.aromatic import Aromatic >>> arom = Aromatic(rings) >>> arom.find_aromatic_atoms(atoms) atoms has to be a list of atom objects * Atom: - a.coords : 3-sequence of floats - a.bonds : list of Bond objects - babel_type: string - babel_atomic_number: int * Bond: - b.atom1 : instance of Atom - b.atom2 : instance of Atom After completion the bondOrder member of bonds in aromatic bonds is is 'aromatic'. The aromatic rings has a new key called 'aromatic' set to 1 or 0 VIII - adding hydrogen atoms Before this AddHydrogens object can be used, atoms must have been assigned a type (see I) Hydrogen atoms can be added using 2 different methods. The first one requires bondOrders to have been calculated previousely. example: >>> #create an instance of AtomHybridization >>> from PyBabel.atomTypes import AtomHybridization >>> atype = AtomHybridization() >>> atype.assignHybridization(atoms) >>> from PyBabel.addh import AddHydrogens >>> addh = AddHydrogens() >>> hat = addh.addHydrogens(atoms) atoms has to be a list of atom objects: * Atom: - a.coords : 3-sequence of floats - a.bonds : list of Bond objects - babel_type: string - babel_atomic_number: int * Bond: - b.atom1 : instance of Atom - b.atom2 : instance of Atom example: >>> from PyBabel.addh import AddHydrogens >>> addh = AddHydrogens() >>> hat = addh.addHydrogens(atoms, method='withBondOrder') atoms has to be a list of atom objects as above and * Bond: - b.atom1 : instance of Atom - b.atom2 : instance of Atom - b.bondOrder : integer These calls return a list 'hat' containing a tuple for each Hydrogen atom to be added. This tuple provides: - coordsH : 3-float coordinates of the H atom - atom : the atom to which the H atom is to be connected - atomic_number : the babel_atomic_number of the H atom - type : tyhe babel_type of the H atom Michel Sanner April 2000 sanner@scripps.edu """ CRITICAL_DEPENDENCIES = ['MolKit', 'mglutil'] NONCRITICAL_DEPENDENCIES = ['Pmv', 'DejaVu'] mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/addh.py0000644000175000017500000004725510703460324021453 0ustar debiandebian############################################################################# # # Author: Michel F. SANNER # Reimplemented from Babel v1.6 from Pat Walters and Math Stahl # # Copyright: M. Sanner TSRI 2000 # ############################################################################# # # $Header: /opt/cvs/python/packages/share1.5/PyBabel/addh.py,v 1.6 2007/10/11 17:43:48 sargis Exp $ # # $Id: addh.py,v 1.6 2007/10/11 17:43:48 sargis Exp $ # """ This file implements the AddHydrogens class. Before this AddHydrogens object can be used, atoms must have been assigned a type see (AtomHybridization in types.py). Hydrogen atoms can be added using 2 different methods. The first one requires bondOrders to have been calculated previousely. example: >>> atype = AtomHybridization() >>> atype.assignHybridization(atoms) >>> addh = AddHydrogens() >>> hat = addh.addHydrogens(atoms) atoms has to be a list of atom objects Atom: a.coords : 3-sequence of floats a.bonds : list of Bond objects babel_type: string babel_atomic_number: int Bond: b.atom1 : instance of Atom b.atom2 : instance of Atom or >>> addh = AddHydrogens() >>> hat = addh.addHydrogens(atoms, method='withBondOrder') atoms has to be a list of atom objects as above and Bond: b.atom1 : instance of Atom b.atom2 : instance of Atom b.bondOrder : integer these calls return a list 'hat' containing a tuple for each Hydrogen atom to be added. This tuple provides: coordsH : 3-float coordinates of the H atom atom : the atom to which the H atom is to be connected atomic_number : the babel_atomic_number of the H atom type : tyhe babel_type of the H atom reimplmentation of Babel1.6 in Python by Michel Sanner April 2000 Original code by W. Patrick Walters and Matthew T. Stahl """ import math from atomTypes import TypeConverter from util import * ONE_OVER_SQRT3 = 0.577350269 SQRT_TWO_THIRDS = 0.816496581 SP3_C_H_DIST = 1.115 SP2_C_H_DIST = 1.103 SP_C_H_DIST = 1.090 SP3_N_H_DIST = 1.020 SP2_N_H_DIST = 1.020 SP3_O_H_DIST = 0.950 class AddHydrogens: """ """ def addHydrogens(self, atoms, method='noBondOrder'): """ """ Hatoms = [] # method = 'noBondOrder' if method=='noBondOrder': num_H_to_add = self.count_missing_hydrogens(atoms) if num_H_to_add: Hatoms = self.place_hydrogens1(atoms, num_H_to_add) else: num_H_to_add = self.count_missing_bo_hydrogens(atoms) if num_H_to_add: Hatoms = self.place_hydrogens2(atoms, num_H_to_add) # cleanup for a in atoms: delattr(a, '_redo') return Hatoms def place_hydrogens1(self, atoms, num_H_to_add): """ """ Hat = [] for a in atoms: if a.babel_type == "C3": val = len(a.bonds) if val == 3: Hat = Hat + self.add_tertiary_hydrogen(a, SP3_C_H_DIST) elif val == 2: Hat = Hat + self.add_methylene_hydrogens(a ,SP3_C_H_DIST) elif val==1: Hat = Hat + self.add_methyl_hydrogen(a, SP3_C_H_DIST) Hat = Hat + self.add_methylene_hydrogens(a, SP3_C_H_DIST, Hat[-1]) elif a.babel_type == "N3+": val = len(a.bonds) if val == 2: Hat = Hat + self.add_methylene_hydrogens(a ,SP3_N_H_DIST) elif val==1: Hat = Hat + self.add_methyl_hydrogen(a, SP3_N_H_DIST) Hat = Hat + self.add_methylene_hydrogens(a ,SP3_N_H_DIST, Hat[-1]) elif a.babel_type == "C2" or a.babel_type == "Car": val = len(a.bonds) if val == 2: Hat = Hat + self.add_sp2_hydrogen(a ,SP2_C_H_DIST) elif a.babel_type == "Npl" or a.babel_type == "Nam" or \ a.babel_type == "Ng+": val = len(a.bonds) if val == 2: Hat = Hat + self.add_sp2_hydrogen(a ,SP2_N_H_DIST) elif a.babel_type == "C1": if len(a.bonds) == 1: Hat = Hat + self.add_sp_hydrogen(a ,SP_C_H_DIST) elif a.babel_type == "O3": if len(a.bonds) == 1: Hat = Hat + self.add_methyl_hydrogen(a, SP3_O_H_DIST) for a in atoms: if a.babel_type == "C2": if len(a.bonds) == 1: Hat = Hat + self.add_vinyl_hydrogens(a ,SP2_C_H_DIST) elif a.babel_type == "Npl" or a.babel_type == "Nam" or \ a.babel_type == "Ng+": if len(a.bonds) == 1: # FIXME babel C code says SP2_C_H_DIST here ??? Hat = Hat + self.add_vinyl_hydrogens(a ,SP2_N_H_DIST) return Hat def place_hydrogens2(self, atoms, num_H_to_add): """ """ Hat = [] converter = TypeConverter("HYB") for a in atoms: type_name = converter.convert(a.babel_type, 'zero') hyb = int(type_name) code = a.babel_atomic_number * 10 + hyb to_add = a._redo if code == 63: # sp3 carbon if to_add==1: Hat = Hat + self.add_tertiary_hydrogen(a, SP3_C_H_DIST) elif to_add==2: Hat = Hat + self.add_methylene_hydrogens(a ,SP3_C_H_DIST) elif to_add==3: Hat = Hat + self.add_methyl_hydrogen(a, SP3_C_H_DIST) Hat = Hat + self.add_methylene_hydrogens(a, SP3_C_H_DIST, Hat[-1]) elif code == 73: # sp3 nitrogen if to_add==1: if a.babel_type=="N3+": Hat = Hat + self.add_tertiary_hydrogen(a, SP3_N_H_DIST) else: Hat = Hat + self.add_sp3_N_hydrogen(a, SP3_N_H_DIST) elif to_add==2: Hat = Hat + self.add_methylene_hydrogens(a ,SP3_N_H_DIST) elif to_add==3: Hat = Hat + self.add_methyl_hydrogen(a, SP3_N_H_DIST) Hat = Hat + self.add_methylene_hydrogens(a ,SP3_N_H_DIST, Hat[-1]) elif code == 62: # sp2 carbon if to_add==1: Hat = Hat + self.add_sp2_hydrogen(a ,SP2_C_H_DIST) elif code == 72: # sp2 nitrogen if to_add==1: Hat = Hat + self.add_sp2_hydrogen(a ,SP2_N_H_DIST) elif code == 61: # sp carbon if to_add==1: Hat = Hat + self.add_sp_hydrogen(a ,SP_C_H_DIST) elif code == 83: # sp3 oxygen if to_add==1: Hat = Hat + self.add_methyl_hydrogen(a, SP3_O_H_DIST) # save vinyl and amide protons for last, # this way we know where to put them for a in atoms: type_name = converter.convert(a.babel_type, 'zero') hyb = int(type_name) code = a.babel_atomic_number * 10 + hyb to_add = a._redo if code == 62: # sp2 carbon if to_add==2: Hat = Hat + self.add_vinyl_hydrogens(a ,SP2_C_H_DIST) elif code == 72: # sp2 nitrogens if to_add==2: Hat = Hat + self.add_vinyl_hydrogens(a ,SP2_N_H_DIST) return Hat def type_added_hydrogen(self, atom): """ return babel_atomic_number and babel_type for adde H atom""" atomic_number = 1 if atom.babel_atomic_number == 6: htype = "HC" else: htype = "H" return atomic_number, htype def add_sp3_N_hydrogen(self, atom, b_length): """ """ c2 = atom.bonds[0].atom1 if c2==atom: c2 = atom.bonds[0].atom2 if not addedH: c3 = atom.bonds[1].atom1 if c3==atom: c3 = atom.bonds[1].atom2 c3 = c3.coords else: c3 = addedH[0] c = atom.coords v = vec3(c2.coords, c) v1 = vec3(c3, c) s = [ v[0]+v1[0], v[1]+v1[1], v[2]+v1[2] ] n = [ v[1]*v1[2] - v1[1]*v[2], v1[0]*v[2] - v[0]*v1[2], v[0]*v1[1] - v1[0]*v[1] ] s = [ s[0]*ONE_OVER_SQRT3, s[1]*ONE_OVER_SQRT3, s[2]*ONE_OVER_SQRT3 ] n = [ n[0]*SQRT_TWO_THIRDS, n[1]*SQRT_TWO_THIRDS,n[2]*SQRT_TWO_THIRDS ] h1 = [ s[0]+n[0], s[1]+n[1], s[2]+n[2] ] mag= b_length / math.sqrt( h1[0]*h1[0] + h1[1]*h1[1] + h1[2]*h1[2]) cH1 = [c[0] + (h1[0]*mag), c[1] + (h1[1]*mag), c[2] + (h1[2]*mag)] atomic_number, type = self.type_added_hydrogen(atom) return [(cH1, atom, atomic_number, type)] def add_methyl_hydrogen(self, atom, b_length): """ """ b = atom.bonds[0] c = atom.coords # find atom2 such that (1) atom2 is bonded to atom, and # (2) atom2 != atom atom2 = b.atom1 c2 = b.atom1.coords if b.atom1 == atom: atom2 = b.atom2 c2 = b.atom2.coords # find c3 such that (1) atom3 is bonded to atom2, and # (2) atom3 != atom2, and # (3) atom3 != atom if atom2.bonds[0].atom1 == atom: # atom has been located among the bonds of atom2, so # move onto the next bond c3 = atom2.bonds[1].atom1.coords if atom2.bonds[1].atom1==atom2: # since atom was part of bonds[0], the other atom of # this bond is safe to use (ie. not atom or atom2) c3 = atom2.bonds[1].atom2.coords else: c3 = atom2.bonds[0].atom1.coords if atom2.bonds[0].atom1==atom2: c3 = atom2.bonds[0].atom2.coords # but atom2.bonds[0].atom2 might be atom, so check if atom2.bonds[0].atom2==atom: # same logic as above... c3 = atom2.bonds[1].atom1.coords if atom2.bonds[1].atom1==atom2: c3 = atom2.bonds[1].atom2.coords # FIX ME: this only works if atom2 has reasonable sp3 geometry!!! v = vec3(c3, c2, b_length) coordsH = [ c[0]+v[0], c[1]+v[1], c[2]+v[2] ] atomic_number, type = self.type_added_hydrogen(atom) return [(coordsH, atom, atomic_number, type)] def add_tertiary_hydrogen(self, atom, b_length): """ """ c2 = atom.bonds[0].atom1 if c2==atom: c2 = atom.bonds[0].atom2 c3 = atom.bonds[1].atom1 if c3==atom: c3 = atom.bonds[1].atom2 c4 = atom.bonds[2].atom1 if c4==atom: c4 = atom.bonds[2].atom2 c = atom.coords v1 = vec3(c2.coords, c) v2 = vec3(c3.coords, c) v3 = vec3(c4.coords, c) m = invert_3x3( (v1,v2,v3) ) s = [ m[0][0] + m[0][1] + m[0][2], m[1][0] + m[1][1] + m[1][2], m[2][0] + m[2][1] + m[2][2] ] mag= b_length / math.sqrt( s[0]*s[0] + s[1]*s[1] + s[2]*s[2]) cH = [c[0]+ (s[0]*mag), c[1] + (s[1]*mag), c[2] + (s[2]*mag)] atomic_number, type = self.type_added_hydrogen(atom) return [(cH, atom, atomic_number, type)] def add_methylene_hydrogens(self, atom, b_length, addedH=None): """ """ c2 = atom.bonds[0].atom1 if c2==atom: c2 = atom.bonds[0].atom2 if not addedH: c3 = atom.bonds[1].atom1 if c3==atom: c3 = atom.bonds[1].atom2 c3 = c3.coords else: c3 = addedH[0] c = atom.coords v = vec3(c2.coords, c) v1 = vec3(c3, c) s = [ v[0]+v1[0], v[1]+v1[1], v[2]+v1[2] ] n = [ v[1]*v1[2] - v1[1]*v[2], v1[0]*v[2] - v[0]*v1[2], v[0]*v1[1] - v1[0]*v[1] ] s = [ s[0]*ONE_OVER_SQRT3, s[1]*ONE_OVER_SQRT3, s[2]*ONE_OVER_SQRT3 ] n = [ n[0]*SQRT_TWO_THIRDS, n[1]*SQRT_TWO_THIRDS,n[2]*SQRT_TWO_THIRDS ] h1 = [ s[0]+n[0], s[1]+n[1], s[2]+n[2] ] mag= b_length / math.sqrt( h1[0]*h1[0] + h1[1]*h1[1] + h1[2]*h1[2]) cH1 = [c[0] + (h1[0]*mag), c[1] + (h1[1]*mag), c[2] + (h1[2]*mag)] h2 = [ s[0]-n[0], s[1]-n[1], s[2]-n[2] ] mag= b_length / math.sqrt( h2[0]*h2[0] + h2[1]*h2[1] + h2[2]*h2[2]) cH2 = [c[0] + (h2[0]*mag), c[1] + (h2[1]*mag), c[2] + (h2[2]*mag)] atomic_number, type = self.type_added_hydrogen(atom) return [(cH1, atom, atomic_number, type), (cH2, atom, atomic_number, type)] def add_sp2_hydrogen(self, atom, b_length): """ """ c2 = atom.bonds[0].atom1 if c2==atom: c2 = atom.bonds[0].atom2 c3 = atom.bonds[1].atom1 if c3==atom: c3 = atom.bonds[1].atom2 c = atom.coords v = vec3(c2.coords, c ) v1 = vec3(c3.coords, c ) s = [ v[0]+v1[0], v[1]+v1[1], v[2]+v1[2] ] mag= b_length / math.sqrt( s[0]*s[0] + s[1]*s[1] + s[2]*s[2]) coordsH = [c[0] + (s[0]*mag), c[1] + (s[1]*mag), c[2] + (s[2]*mag)] atomic_number, type = self.type_added_hydrogen(atom) return [(coordsH, atom, atomic_number, type)] def add_sp_hydrogen(self, atom, b_length): """ """ b = atom.bonds[0] c = atom.coords if b.atom1 == atom: c2 = b.atom2.coords else: c2 = b.atom1.coords v = vec3(c2, c, b_length) coordsH = [ c[0]+v[0], c[1]+v[1], c[2]+v[2] ] atomic_number, type = self.type_added_hydrogen(atom) return [(coordsH, atom, atomic_number, type)] def add_vinyl_hydrogens(self, atom, b_length): """ """ # c2 is neigbour of c1 c2 = atom.bonds[0].atom1 if c2==atom: c2= atom.bonds[0].atom2 # c3 is neigbour of c2 different from c1 c3 = c2.bonds[0].atom1 if c3==c2: c3 = c2.bonds[0].atom2 if c3==atom: c3 = c2.bonds[1].atom1 if c3 == c2: c3 = c2.bonds[1].atom2 # c4 is neighbor of c2 different from c1 and c3 c4 = c2.bonds[0].atom1 if c4==c2: c4 = c2.bonds[0].atom2 if c4 == atom or c4 == c3: c4 = c2.bonds[1].atom1 if c4 == c2: c4 = c2.bonds[1].atom2 if c4==atom or c4 == c3: if len(c2.bonds)>2: c4 = c2.bonds[2].atom1 if c4==c2: c4 = c2.bonds[2].atom2 else: c4 = None # here we diverge from Babel1.6 because they use H atoms # that might have laready been added. We will only add them # later. Therefore c2 might not have 3 neighbors c = atom.coords v = vec3(c3.coords, c2.coords, b_length) cH1 = [ c[0]+v[0], c[1]+v[1], c[2]+v[2] ] if c4 is not None and len(c2.bonds)==3: v1 = vec3(c4.coords, c2.coords, b_length) cH2 = [ c[0]+v1[0], c[1]+v1[1], c[2]+v1[2]] else: # we build second H like a sp2_hydrogen using c2,c,H v = vec3(c2.coords, c) v1 = vec3(cH1, c, b_length ) s = [ v[0]+v1[0], v[1]+v1[1], v[2]+v1[2] ] mag= b_length / math.sqrt( s[0]*s[0] + s[1]*s[1] + s[2]*s[2]) cH2 = [c[0] + (s[0]*mag), c[1] + (s[1]*mag), c[2] + (s[2]*mag)] atomic_number, htype = self.type_added_hydrogen(atom) return [ (cH1, atom, atomic_number, htype), (cH2, atom, atomic_number, htype) ] def count_missing_hydrogens(self, atoms): """ """ missing = 0 converter = TypeConverter("HAD") for a in atoms: temp_type = converter.convert(a.babel_type, 'zero') if temp_type == 0: print "Unable to assign valence to atom %s type = %s" % \ (a.full_name(), a.babel_type) type_valence = int(temp_type) val = len(a.bonds) if val < type_valence and val > 0: missing = missing + type_valence - val return missing def count_missing_bo_hydrogens(self, atoms): """ """ missing = 0 for a in atoms: type_valence = 0 if a.babel_atomic_number==6: type_valence = 4 elif a.babel_atomic_number==7: if a.babel_type=='N2' and len(a.bonds)==1: type_valence = 2 elif a.babel_type=='N3+': type_valence = 4 else: type_valence = 3 elif a.babel_atomic_number==8: if a.babel_type=="O-" or a.babel_type=="O2": type_valence = 1 else: type_valence = 2 attached = self.count_attached_bonds(a) a._redo = 0 to_add = 0 if len(a.bonds) < type_valence and len(a.bonds) > 0: to_add = type_valence - attached if to_add > 0: a._redo = to_add missing = missing + to_add return missing def count_attached_bonds(self, atom): """ """ bonds = 0.0; for b in atom.bonds: if b.bondOrder == 5: bonds = bonds + 1.5 elif b.bondOrder == 'aromatic': bonds = bonds + 1.5 elif b.bondOrder == 'amide': bonds = bonds + 1.5 else: bonds = bonds + b.bondOrder return int(bonds) if __name__ == '__main__': import pdb, sys from cycle import RingFinder from bo import BondOrder from atomTypes import AtomHybridization from aromatic import Aromatic from MolKit.pdbParser import NewPdbParser parser = NewPdbParser("/tsri/pdb/struct/%s.pdb"%sys.argv[1]) mols = parser.parse() mol = mols[0] mol.buildBondsByDistance() allAtoms = mol.chains.residues.atoms bonds = allAtoms.bonds[0] print "assigning atom types" babel = AtomHybridization() babel.assignHybridization(allAtoms) print "looking for rings" rings = RingFinder() rings.findRings(allAtoms, bonds) print "assigning bond order" bo = BondOrder() #pdb.run("bo.assignBondOrder(allAtoms, bonds)") bo.assignBondOrder(allAtoms, bonds) print "looking for aromatic rings" arom = Aromatic(rings) arom.find_aromatic_atoms(allAtoms) print "done" ## db = filter(lambda x:x.bondOrder==2, bonds) ## for b in db: ## print b addh = AddHydrogens() #pdb.run("hat = addh.addHydrogens(allAtoms)") hat = addh.addHydrogens(allAtoms) from MolKit.molecule import Atom, Bond for a in hat: atom = Atom('H', a[1].parent, top=a[1].top) atom._coords = [ a[0] ] atom.segID = a[1].segID atom.hetatm = 0 atom.alternate = [] atom.element = 'H' atom.number = -1 atom.occupancy = 1.0 atom.conformation = 0 atom.temperatureFactor = 0.0 atom.babel_atomic_number = a[2] atom.babel_type = a[3] atom.babel_organic=1 bond = Bond( a[1], atom ) from Pmv.moleculeViewer import MoleculeViewer mv = MoleculeViewer() mv.addMolecule(mol) mv.lines( mol ) mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/source.list0000644000175000017500000000025207262424343022367 0ustar debiandebianSOURCE= ./__init__.py ./atomTypes.py ./cycle.py ./bo.py ./aromatic.py \ ./addh.py ./gasteiger.py ./util.py ./tools.py ./babelAtomTypes.py \ ./babelElements.py mgltools-pybabel-1.5.7~rc1~cvs.20130519/PyBabel/aromatic.py0000644000175000017500000003770111107412160022337 0ustar debiandebian############################################################################# # # Author: Michel F. SANNER # Reimplemented from Babel v1.6 from Pat Walters and Math Stahl # # Copyright: M. Sanner TSRI 2000 # ############################################################################# # # $Header: /opt/cvs/python/packages/share1.5/PyBabel/aromatic.py,v 1.3 2008/11/15 00:14:40 sargis Exp $ # # $Id: aromatic.py,v 1.3 2008/11/15 00:14:40 sargis Exp $ # """ This file implements the Aromatic class. Before this Aromatic object can be used to identify aromatic rings, 1 - atoms must have been assigned a type see (AtomHybridization in types.py) 2 - bond orders must have been defined 3 - rings must have been identified (see RingFinder in cycle.py) example: >>> atype = AtomHybridization() >>> atype.assignHybridization(atoms) >>> rings = RingFinder() >>> rings.findRings(atoms, bonds) >>> bo = BondOrder() >>> bo.assignBondOrder(atoms, bonds, rings) >>> arom = Aromatic(rings) >>> arom.find_aromatic_atoms(atoms) atoms has to be a list of atom objects Atom: a.coords : 3-sequence of floats a.bonds : list of Bond objects babel_type: string babel_atomic_number: int Bond: b.atom1 : instance of Atom b.atom2 : instance of Atom After completion reimplmentation of Babel1.6 in Python by Michel Sanner April 2000 Original code by W. Patrick Walters and Matthew T. Stahl """ import math from atomTypes import TypeConverter from util import distance, bond_angle class Aromatic: """ """ def __init__(self, rings): """ """ self.rings = rings def find_aromatic_atoms(self, atoms): """ """ info = self.setup_ring_info( atoms ) for r in self.rings.rings: for a in r['atoms']: if a.arom_atm: # atom is aromatic if a.babel_atomic_number == 6: a.babel_type = "Car" elif a.babel_atomic_number == 7: a.babel_type = "Nar" for b in r['bonds']: if b.atom1.arom_atm and b.atom2.arom_atm: b.bondOrder = 'aromatic' for r in self.rings.rings: for a in r['atoms']: if hasattr(a, 'arom_atm'): delattr(a, 'arom_atm') def find_aromatic_rings(self): """ """ converter = TypeConverter("HYB") for r in self.rings.rings: is_aromatic = 0 if len(r['atoms']) == 5 or len(r['atoms']) == 6: is_aromatic = 1 for a in r['atoms']: # check to see if the atom is sp2 # if not, the ring isn't aromatic hyb_str = converter.convert(a.babel_type, 'all_caps') hyb = int(hyb_str) if hyb != 2: is_aromatic = 0 break # check to see if the atom has 3 bonds to # heavy atoms in the same ring. # If not, the ring isn't aromatic if self.count_arom_atm_bonds(a, r) != 3: is_aromatic = 0 break if is_aromatic: r['aromatic'] = 1 for a in r['atoms']: a.arom_atm = 1 def find_aromatic_rings2(self): """ """ converter = TypeConverter("HYB") for r in self.rings.rings: is_aromatic = 0 if len(r['atoms']) == 5 or len(r['atoms']) == 6: is_aromatic = 1 for a in r['atoms']: # check to see if the atom is sp2 # if not, the ring isn't aromatic hyb_str = converter.convert(a.babel_type, 'all_caps') hyb = int(hyb_str) if hyb != 2: is_aromatic = 0 break # check to see if the atom has 3 bonds to # heavy atoms in the same ring. # If not, the ring isn't aromatic # if not a.arom_atm: # if self.count_arom_atm_bonds(a, r) != 3: # is_aromatic = 0 # break if is_aromatic: r['aromatic'] = 1 for a in r['atoms']: a.arom_atm = 1 def setup_ring_info(self, atoms): """ """ for r in self.rings.rings: r['aromatic'] = 0 for a in r['atoms']: a.arom_atm = 0 self.find_aromatic_rings() self.find_aromatic_rings2() for r in self.rings.rings: # compute cycle center center = [0,0,0] sca = 1.0/len(r['atoms']) for a in r['atoms']: c = a.coords center[0] = center[0] + c[0]*sca center[1] = center[1] + c[1]*sca center[2] = center[2] + c[2]*sca r['center'] = center # compute cycle radius b = r['bonds'][0] c1 = b.atom1.coords c2 = b.atom2.coords mid = ( (c1[0]+c2[0])*0.5, (c1[1]+c2[1])*0.5, (c1[2]+c2[2])*0.5) r['radius'] = 0.9 * distance(center, mid) # compute cycle normal vector n_avg = [0,0,0] for i in range(len(r['bonds'])-1): b = r['bonds'][i] c1 = b.atom1.coords c2 = b.atom2.coords a3 = r['bonds'][i+1].atom1 if a3==b.atom1 or a3==b.atom2: a3 = r['bonds'][i+1].atom2 c3 = a3.coords v = (c2[0]-c1[0], c2[1]-c1[1], c2[2]-c1[2]) v1 = (c3[0]-c1[0], c3[1]-c1[1], c3[2]-c1[2]) n = [ v[1]*v1[2] - v1[1]*v[2], v1[0]*v[2] - v[0]*v1[2], v[0]*v1[1] - v1[0]*v[1] ] sca = 1.0 / math.sqrt(n[0]*n[0] + n[1]*n[1] + n[2]*n[2]) n_avg = (n[0]*sca, n[1]*sca, n[2]*sca) r['normal'] = n_avg def count_arom_atm_bonds(self, atom, ring): """ """ hvy_bonds = 0 for b in atom.bonds: conn = b.atom1 if conn==atom: conn=b.atom2 if conn in ring['atoms']: if conn.babel_atomic_number != 1: # add bond order of bonds to non hydrogen atoms hvy_bonds = hvy_bonds+b.bondOrder return hvy_bonds if __name__ == '__main__': import pdb, sys from atomTypes import AtomHybridization from cycle import RingFinder from bo import BondOrder from aromatic import Aromatic from addh import AddHydrogens from MolKit.pdbParser import PdbqParser #parser = NewPdbqParser("./txp_noh.pdbq") # doesn't work #parser = NewPdbqParser("./txp.pdbq") # OK #parser = NewPdbqParser("./gmmtest.pdbq") # from MolKit.mol2Parser import NewMol2Parser #mols = parser.parse() #mol = mols[0] #mol.buildBondsByDistance() parser = NewMol2Parser("./mtx.mol2") # OK mols = parser.parse() mol = mols[0] allAtoms = mol.chains.residues.atoms print "assigning atom types" babel = AtomHybridization() babel.assignHybridization(allAtoms) print "looking for rings" bonds = allAtoms.bonds[0] rings = RingFinder() rings.findRings(allAtoms, bonds) print "assigning bond order" bo = BondOrder() #pdb.run("bo.assignBondOrder(allAtoms, bonds)") bo.assignBondOrder(allAtoms, bonds) def countMissingBonds(atoms): converter = TypeConverter('HYB') needDBatoms = [] canHaveDBatoms = [] for a in atoms: a._needsDB = 0 a._canHaveDB = 0 hyb = int(converter.convert(a.babel_type, 'all_caps')) if hyb != 2: continue if a.babel_type[0] == 'C': sum = 0 for b in a.bonds: sum = sum + b.bondOrder if sum == 3: if len(a.bonds)==3: a._needsDB = 1 needDBatoms.append(a) elif len(a.bonds)==2: # ==C-- or ==C/ a1 = a.bonds[0].atom1 if a1==a: a1 = a.bonds[0].atom2 a3 = a.bonds[1].atom1 if a3==a: a3 = a.bonds[1].atom2 ang = bond_angle( a1.coords, a.coords, a3.coords ) if math.fabs(ang-180) < 10: # ==C-- a._needDB = 1 needDBatoms.append(a) elif sum == 2: if len(a.bonds)==2: a1 = a.bonds[0].atom1 if a1==a: a1 = a.bonds[0].atom2 a3 = a.bonds[1].atom1 if a3==a: a3 = a.bonds[1].atom2 ang = bond_angle( a1.coords, a.coords, a3.coords ) if math.fabs(ang-180) < 10: a._needsDB = 2 needDBatoms.append(a) else: a._needsDB = 1 needDBatoms.append(a) elif sum == 1: a._needsDB = 1 needDBatoms.append(a) elif a.babel_type[0] == 'N': sum = 0 for b in a.bonds: sum = sum + b.bondOrder if sum == 2 and len(a.bonds)==2: canHaveDBatoms.append(a) a._canHaveDB = 1 elif a.babel_type[0] == 'O': sum = 0 for b in a.bonds: sum = sum + b.bondOrder if sum == 1: canHaveDBatoms.append(a) a._canHaveDB = 1 return needDBatoms, canHaveDBatoms def fixMissingBonds(pbatoms): i = 0 while (len(pbatoms) and i 1: nb = b.atom1.bonds[1] else: nb = b.atom2.bonds[1] a3 = nb.atom1 if a3==b.atom1: a3 = nb.atom2 c3 = a3.coords v = (c2[0]-c1[0], c2[1]-c1[1], c2[2]-c1[2]) v1 = (c3[0]-c1[0], c3[1]-c1[1], c3[2]-c1[2]) n = [ v[1]*v1[2] - v1[1]*v[2], v1[0]*v[2] - v[0]*v1[2], v[0]*v1[1] - v1[0]*v[1] ] nn = [ n[1]*v[2] - v[1]*n[2], v[0]*n[2] - n[0]*v[2], n[0]*v[1] - v[0]*n[1] ] sca = 0.15 / math.sqrt(nn[0]*nn[0] + nn[1]*nn[1] + nn[2]*nn[2]) b.dispVec = (nn[0]*sca, nn[1]*sca, nn[2]*sca) addDispVector() ## addh = AddHydrogens() ## hat = addh.addHydrogens(allAtoms) ## from MolKit.molecule import Atom, Bond ## for a in hat: ## atom = Atom('H', a[1].parent, top=a[1].top) ## atom._coords = [ a[0] ] ## if hasattr(atom, 'segID'): ## atom.segID = a[1].segID ## atom.hetatm = 0 ## atom.alternate = [] ## atom.element = 'H' ## atom.number = -1 ## atom.occupancy = 1.0 ## atom.conformation = 0 ## atom.temperatureFactor = 0.0 ## atom.babel_atomic_number = a[2] ## atom.babel_type = a[3] ## atom.babel_organic=1 ## bond = Bond( a[1], atom ) from Pmv.moleculeViewer import MoleculeViewer mv = MoleculeViewer() mv.addMolecule(mol) mol.bondsflag = 1 mv.lines( mol ) v = [] l = [] g = mv.Mols[0].geomContainer.geoms['lines'] vc = len(g.vertexSet) scale = [0, 1, -1, 2, -2, 3, -3, 4, -4] add = -1 ## for b in bonds: ## if b.bondOrder>1: ## b.bondOrder = 5 ## break for b in bonds: n = b.bondOrder if n=='aromatic': continue for i in range(1, n): print i, scale[i] l.append( (vc,vc+1) ) c1 = b.atom1.coords v.append( c1[0]+(scale[i]*b.dispVec[0]), c1[1]+(scale[i]*b.dispVec[1]), c1[2]+(scale[i]*b.dispVec[2]) ) vc = vc+1 c1 = b.atom2.coords v.append( c1[0]+(scale[i]*b.dispVec[0]), c1[1]+(scale[i]*b.dispVec[1]), c1[2]+(scale[i]*b.dispVec[2]) ) vc = vc+1 g = mv.Mols[0].geomContainer.geoms['lines'] g.Add(vertices = v, faces=l) from DejaVu.Arcs3D import Arcs3D aromC = [] aromR = [] aromN = [] for r in rings.rings: if r['aromatic']: aromC.append(r['center']) aromR.append(r['radius']) aromN.append(r['normal']) c = Arcs3D('aromCircles', vertices = aromC, vnormals = aromN, materials = ( (0,1,0), ), radius = aromR, angles = ( 360, ), stippleLines = 1, lineWidth=2) mv.Mols[0].geomContainer.geoms['aromCircles'] = c mv.GUI.VIEWER.AddObject(c, parent = mv.Mols[0].geomContainer.masterGeom) mgltools-pybabel-1.5.7~rc1~cvs.20130519/setup.py0000644000175000017500000000626410254604013020364 0ustar debiandebian#!/usr/bin/env python from distutils.core import setup from distutils.command.sdist import sdist from distutils.command.install_data import install_data from glob import glob import os ######################################################################## # Had to overwrite the prunrefile_list method of sdist to not # remove automatically the RCS/CVS directory from the distribution. ######################################################################## class modified_sdist(sdist): def prune_file_list(self): """ Prune off branches that might slip into the file list as created by 'read_template()', but really don't belong there: * the build tree (typically 'build') * the release tree itself (only an issue if we ran 'sdist previously with --keep-temp, or it aborted) """ build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname() self.filelist.exclude_pattern(None, prefix=build.build_base) self.filelist.exclude_pattern(None, prefix=base_dir) class modified_install_data(install_data): def run(self): install_cmd = self.get_finalized_command('install') self.install_dir = getattr(install_cmd, 'install_lib') return install_data.run(self) ######################################################################## # list of the python packages to be included in this distribution. # sdist doesn't go recursively into subpackages so they need to be # explicitaly listed. # From these packages only the python modules will be taken packages = ['PyBabel', 'PyBabel.Tests'] # list of the python modules not part of a package. Give the path and the # filename without the extension. i.e you want to add the # test.py module which is located in MyPack/Tests/ you give # 'MyPack/Tests/test' py_modules = [] # list of the files that are not python packages but are included in the # distribution and need to be installed at the proper place by distutils. # The list in MANIFEST.in lists is needed for including those files in # the distribution, data_files in setup.py is needed to install them # at the right place. data_files = [] for dir in ['PyBabel', 'PyBabel/Tests/Data', 'PyBabel/CVS', 'PyBabel/Tests/CVS', 'PyBabel/Tests/Data/CVS']: files = [] for f in glob(os.path.join(dir, '*')): if f[-3:] != '.py' and f[-4:-1] != '.py' and os.path.isfile(f): files.append(f) data_files.append((dir, files)) # description of what is going to be included in the distribution and # installed. from version import VERSION setup (name = 'PyBabel', version = VERSION, description = "an OpenGL based 3D geometry viewer python package", author = 'Molecular Graphics Laboratory', author_email = 'sanner@scripps.edu', download_url = 'http://www.scripps.edu/~sanner/software/packager.html', url = 'http://www.scripps.edu/~sanner/software/index.html', packages = packages, py_modules = py_modules, data_files = data_files, cmdclass = {'sdist': modified_sdist, 'install_data': modified_install_data }, ) mgltools-pybabel-1.5.7~rc1~cvs.20130519/version.py0000644000175000017500000000002011475262371020706 0ustar debiandebianVERSION="1.5.6" mgltools-pybabel-1.5.7~rc1~cvs.20130519/MANIFEST.in0000644000175000017500000000074511033236643020414 0ustar debiandebian# This list all other files to be included in the distribution # which are not python modules # include, exclude.... which are not described in the setup.py. include MANIFEST.in # list of the non python module to be included in the distribution include PyBabel/Tests/Data/* include PyBabel/RELNOTES # include all the CVS directories include PyBabel/CVS/* include PyBabel/Tests/CVS/* include PyBabel/Tests/Data/CVS/* include version.py include PyBabel/doc.tar.gz include PyBabel/LICENSE