def mol22atom(line): "Reads a mol2 atom line and returns the atoms indexes and bond order" """ex:\ ' 1 O1 -0.5240 -0.4910 -0.1630 os 1 MOL -0.196235\n' """ words = line.strip().split() # basic atom info element = words[5].split('.')[0] x, y, z = words[2:5] # mm info atom_type = words[1] if len(words) == 9: charge = words[8] name = words[1] atom_type = words[5] #changes the info of the atom_type if mol2 has # 9 fields else: charge = None atom = atoms.Atom(atom_type,(float(x), float(y), float(z))) mm_obj = atoms.MM(atom_type, charge) atom.set_mm(mm_obj) #resinfo if mol2 has 9 fields if len(words) == 9: resinfo_obj = atoms.RESinfo(name, words[7], words[6], 'X') atom.set_resinfo(resinfo_obj) return atom
def pdb2atom(line): # start atom el = line [76:78].strip() if el == '': el = ''.join(i for i in line[12:16].strip() if not i.isdigit())[0] #get from atom name #after eliminating numbers x = float(line[30:38]) y = float(line[38:46]) z = float(line[46:54]) atom = atoms.Atom(el, (x,y,z)) # residue info name = line [12:16].strip() # atom name resName = line [17:20].strip() # Residue name resNum = spaceint(line[22:26]) # Residue number chain = line [21:22].strip() # chain resinfo = atoms.RESinfo(name, resName, resNum, chain) # pdb info keyword = line[ 0: 6] serial = spaceint(line[ 6:11]) pdbinfo = atoms.PDBinfo(keyword, serial, occupancy = spacefloat(line[54:60]), bfact = spacefloat(line[60:66]), altloc = line[16:17], icode = line[26:27], formalcharge = line[78:80].strip()) # return atom.set_resinfo(resinfo) atom.set_pdbinfo(pdbinfo) return atom
def _gen_zmat(self, inpcrd_name): text = '' chargelist = self.read_flag('CHARGE') if 'ATOMIC_NUMBER' in self._flags: # old amboniom_elements.py (glycam) elements = self._guess_elements() else: elements = self._read_elements() total_charge = 0 X, Y, Z = self._coords_from_inpcrd(inpcrd_name) j = 0 for i in self.atom_sel_idx: name = self.pdb_atom_name[i].replace('-', '').replace('+', '') residue_name = self.pdb_resname[i].replace('-', '').replace('+', '') residue_number = self.pdb_resid[i] mm_type = self.upper_atom_types[i] charge = chargelist[i] / 18.2223 total_charge += charge mask = '0' x = X[i] y = Y[i] z = Z[i] chain = '' layer = 'L' element = elements[j] j += 1 link_element = link_mm_type = link_bound_to = link_scale1 = None # create atom this_atom = atoms.Atom(element, (x, y, z)) resinfo = atoms.RESinfo(name, residue_name, residue_number, chain) this_atom.set_resinfo(resinfo) oniominfo = atoms.Oniom(mask, layer) this_atom.set_oniom(oniominfo) mm = atoms.MM(mm_type, charge) this_atom.set_mm(mm) # print z-matrix for atom text += iolines.atom2zmat(this_atom) # Add stuff to text header = '' #header += '%nproc=4\n' #header += '%mem=2GB\n' #header += '%chk=chk.chk\n' header += '# amber=softonly geom=connectivity\n\n' header += 'Se amanha nao chover vai estar um lindo dia de sol\n\n' header += 'Sum of partial charges: %f\n' % (total_charge) return header + text
def _parse_resinfo(resinfo): """interpret (PDBName=x,ResName=y,ResNum=0)""" name, resname, resnum, chain = '', '', '', '' for info in resinfo.split(','): if 'PDBName' in info: name = info.split("=")[1].strip() if 'ResName' in info: resname = info.split("=")[1].strip() if 'ResNum' in info: resnum = info.split("=")[1].strip() if '_' in resnum : # looks like "123_A" resnum, chain = resnum.split("_") resnum = int(resnum) # TODO Will crash if "" return atoms.RESinfo(name, resname, resnum, chain)
def pdbqt2atom(line): # start atom atype = line[77:79].strip() x = float(line[30:38]) y = float(line[38:46]) z = float(line[46:54]) ad2el = {'H':'H', 'HD':'H', 'HS':'H', 'C':'C', 'A':'C', 'N':'N', 'NA':'N', 'NS':'N', 'OA':'O', 'OS':'O', 'F':'F', 'Mg':'Mg', 'MG':'Mg', 'P':'P', 'SA':'S', 'S':'S', 'Cl':'Cl', 'CL':'Cl', 'Ca':'Ca', 'CA':'Ca', 'Mn':'Mn', 'MN':'Mn', 'Fe':'Fe', 'FE':'Fe', 'Zn':'Zn', 'ZN':'Zn', 'Br':'Br', 'BR':'Br', 'I':'I', 'W':'O'} atom = atoms.Atom(ad2el[atype], (x,y,z)) # residue info name = line [12:16].strip() # atom name resName = line [17:20].strip() # Residue name resNum = spaceint(line[22:26]) # Residue number chain = line [21:22].strip() # chain resinfo = atoms.RESinfo(name, resName, resNum, chain) # pdb info keyword = line[ 0: 6] serial = spaceint(line[ 6:11]) pdbinfo = atoms.PDBinfo(keyword, serial, occupancy = spacefloat(line[54:60]), bfact = spacefloat(line[60:66]), altloc = line[16:17], icode = line[26:27], formalcharge = ' ') # atype, charge mm = atoms.MM(atype, float(line[70:76])) # return atom.set_mm(mm) atom.set_resinfo(resinfo) atom.set_pdbinfo(pdbinfo) return atom