def setAtomsDictionary(self, atoms=None, pdbfile=None): """ set reference to the atoms dictionary atoms = dictionary with atom objects to make the protein from, i.e. atoms[chainID][resName] """ if atoms != None: self.atoms = atoms elif pdbfile != None: self.atoms = pdb.readPDB(filename=pdbfile) else: print("need either an atoms dictionary or pdbfile to create a protein") sys.exit(9) return
def makeCompositeAtomsDictionary(protein=None, pdbfiles=None, options=None): """ This routine creates a composite 'atoms' dictionary. """ if options.mutations == None: # not making mutations, we don't need 'atoms-dictionary' return None elif options.mutator.label in ["alignment", "overlap"]: atoms = {protein.name: protein.atoms} if options.thermophiles == None: # read the pdbcode from mutations and get the pdb atoms for mutation in options.mutations: if isinstance(mutation, str): # keeping string notation of mutation pdbcode = mutation[:4] if pdbcode not in atoms: atoms[pdbcode] = pdb.readPDB(filename=pdbcode) else: # extracting pdbcode if mutation is in dictionary format for key in mutation.keys(): pdbcode = mutation[key]['pdb'] if pdbcode not in atoms: atoms[pdbcode] = pdb.readPDB(filename=pdbcode) else: # Match thermophile pdb files to the mutation code if len(options.thermophiles) != 0: import re for pdbname in options.thermophiles: for mutation in options.mutations: code, rest = splitStringMutationInTwo(mutation) print(mutation, code, rest) if re.search(code, pdbname): atoms[code] = pdb.readPDB(filename=pdbname) return atoms else: # not using alignment or overlap mutator, we don't need 'atoms dictionary' return None
% (element, d)) a = a.rescale(d) return a if __name__ == '__main__': import protein, pdb, sys, os arguments = sys.argv if len(arguments) != 2: print('Usage: protonate.py <pdb_file>') sys.exit(0) filename = arguments[1] if not os.path.isfile(filename): print('Error: Could not find \"%s\"' % filename) sys.exit(1) p = Protonate() pdblist = pdb.readPDB(filename) my_protein = protein.Protein(pdblist, 'test.pdb') p.remove_all_hydrogen_atoms_from_protein(my_protein) my_protein.writePDB('before_protonation.pdb') p.protonate_protein(my_protein) ## write out protonated file my_protein.writePDB('protonated.pdb')
a = a.rescale(d) return a if __name__ == '__main__': import protein, pdb, sys,os arguments = sys.argv if len(arguments) != 2: print('Usage: protonate.py <pdb_file>') sys.exit(0) filename = arguments[1] if not os.path.isfile(filename): print('Error: Could not find \"%s\"'%filename) sys.exit(1) p = Protonate() pdblist = pdb.readPDB(filename) my_protein = protein.Protein(pdblist,'test.pdb') p.remove_all_hydrogen_atoms_from_protein(my_protein) my_protein.writePDB('before_protonation.pdb') p.protonate_protein(my_protein) ## write out protonated file my_protein.writePDB('protonated.pdb')