def parsepdb(self,lines): import PDBparser Y=PDBparser.fast_PDBparser(lines,self.parse_terms) Y.parse() self.atoms=Y.atoms self.Update() self.attribute=Y.attribute return
def parsepdb(self,lines): """ Parses a PDB file, which is contained in lines (a list of lines) """ import PDBparser Y=PDBparser.PDBparser(lines,self.parse_terms) Y.parse() self.atoms=Y.atoms self.Update() self.attribute=Y.attribute return
def readpdb(self,filename=None,data=None,parse=1,readmodels=1,use_NMRnumber=True): """ # Reads a pdb file and lets PDBparser.parse do the parsing """ import os if data != None: import StringIO stream = StringIO.StringIO(data) self.lines = stream.readlines() elif os.path.isfile(filename): if not silent: print 'Reading: ',filename fd=open(filename) self.lines=fd.readlines() fd.close() else: raise FileNotFoundError(filename) if parse: import PDBparser Y=PDBparser.PDBparser(self.lines,self.parse_terms) Y.readmodels=readmodels if not use_NMRnumber: Y.ignore_NMRmodel=True # Y.parse() self.atoms=Y.atoms if hasattr(Y,'spacegroup'): self.spacegroup=Y.spacegroup # Transfer spacegroup info else: self.spacegroup='Unknown' self.header='' if hasattr(Y,'header'): self.header=Y.header # # Transfer crystal symmetry info # self.scale=Y.scale self.orig=Y.orig self.cryst=Y.cryst # # Update # self.Update() self.attribute=Y.attribute if not silent: print 'Read file with %3d residues and %5d atoms' %(len(self.residues.keys()),len(self.atoms.keys())) return
def readpdb(self,filename,parse=1): # # Reads a pdb file and lets PDBparser.parse do the parsing # import os if os.path.isfile(filename): fd=open(filename) self.lines=fd.readlines() fd.close() if parse: import PDBparser Y=PDBparser.fast_PDBparser(self.lines,self.parse_terms) Y.parse() self.atoms=Y.atoms self.Update() self.attribute=Y.attribute return else: raise FileNotFoundError,filename
def addpdblines(self,lines): """Add the atoms in lines to the current set of atoms""" import PDBparser Y=PDBparser.PDBparser(lines,self.parse_terms) Y.parse() error=False for atom in Y.atoms.keys(): if not self.atoms.has_key(atom): self.atoms[atom]=Y.atoms[atom] else: print 'Name clash for',atom error=True if not error: self.Update() self.attribute=Y.attribute return else: print 'Protool does not allow name clashes' import os os._exit(0)
print("No grid file", pdb_id, site_id) continue elif os.path.isfile("%s/%s_ElectFeatures.txt"%(root_dir, pdb_id)) == False: #is there bluues electrostatics data? print("No electro file", pdb_id, site_id) continue elif os.path.isfile("%s/%s.findgeo"%(root_dir, pdb_id)) == False: #is there findgeo/CMM data? print("No geom file", pdb_id, site_id) continue else: print(pdb_id, site_id) chain = entry.chainID if relax == True: pdb_file = "%s_Relaxed.pdb"%pdb_id else: pdb_file = "%s.pdb"%pdb_id residues, res_nums, header = pdbp.create_res("%s/%s"%(root_dir, pdb_file)) #print(res_nums) this_protein = pdbp.Protein(residues, res_nums, header) center_of_mass = np.mean(this_protein.Coords, axis = 0) #print(center_of_mass) metals = set([str(entry.seqNum1), str(entry.seqNum2), str(entry.seqNum3), str(entry.seqNum4)]) metal_res = [] for x in metals: if x != "0": metal_res.append(str(round(float(x))) + chain ) metals = [entry.resName1, entry.resName2, entry.resName3, entry.resName4] site_atom_count = 0 for x in metals: if x != "0": site_atom_count += metal_size[x] #general SITE info
import os import subprocess import numpy as np import PDBparser as pdbp import PDBmanip as pdbm pdbs = {} with open("PDBsToCheck.txt", "r") as inData: for line in inData: line = line.strip() pdbs[line[0:4]] = line[5] print(pdbs) pdbp.download_pdbs(list(pdbs.keys()), output_path="CompPDBs/") for key in pdbs: pdbm.one_chain_pdb("CompPDBs/%s.pdb" % key, key, chainID=pdbs[key], remove_tags=False) with open("PDBsToCheck_NoChain.txt", "w+") as outData: outData.write("\n".join(list(pdbs.keys())))
if relaxed == "Relaxed": pdb_id = pdb_id + "_Relaxed" if os.path.isfile( "/panfs/pfs.local/work/slusky/MSEAL/data/PDB_chains/%s/%s/%s/%s/%s.pdb" % (pdb_id[0], pdb_id[1], pdb_id[0:6], relaxed, pdb_id)) == False: #pdb_id[0], pdb_id[1], #if os.path.isfile("SampleData/%s/UnRelaxed/%s.pdb"%(pdb_id, pdb_id) ) == False: #pdb_id[0], pdb_id[1], continue else: print(pdb_id, metals) chain = pdb_id[5] metal_res = [str(x) + chain for x in metals] #residues, res_nums, header = pdbp.create_res("SampleData/%s/UnRelaxed/%s.pdb"%(pdb_id, pdb_id)) #test on local residues, res_nums, header = pdbp.create_res( "/panfs/pfs.local/work/slusky/MSEAL/data/PDB_chains/%s/%s/%s/%s/%s.pdb" % (pdb_id[0], pdb_id[1], pdb_id[0:6], relaxed, pdb_id)) #for production run on CRC #print(res_nums) this_protein = pdbp.Protein(residues, res_nums, header) SITE_center_pt = SITE_center(metal_res, this_protein) index = entry.Index site_list.loc[index, "X"] = SITE_center_pt[0] site_list.loc[index, "Y"] = SITE_center_pt[1] site_list.loc[index, "Z"] = SITE_center_pt[2] site_list.loc[index, "NearNeigh"] = nearest_neigh(SITE_center_pt, metal_res, this_protein) #print(site_list.loc[index,:]) site_list.to_csv("SITECenters_%s.txt" % relaxed, sep="\t", index=False)
if "ATOM" == line[0:4] and check_lines == False: #print(line[22:26]) check_lines = True if check_lines == False: print(filename) for filename in glob.glob("PDBFiles/*.pdb"): pdb_id = filename.split("/") pdb_id = pdb_id[-1][:-4] print(pdb_id) if pdb_id == "3jc8_Qd" or pdb_id == "4v6m_AZ": continue with open(filename, "r") as pdb_file: pdb_lines = pdb_file.readlines() sequence = pdbp.pdb_to_seq(pdb_lines, filename[-5]) pdb_seq = pdbp.seq_from_struct(pdb_lines, filename[-5]) #print(sequence) if "PDB chain" in pdb_lines[0]: print("pdb has been adjusted") else: print("Checking file %s, chain is %s" % (pdb_id, filename[-5])) with open("PDBFiles/%s.pdb" % pdb_id, "w+") as pdb_file: atom_records = pdbp.one_chain_pdb(pdb_lines, filename[-5]) if pdb_seq[0:20] == sequence[0:20]: #print("Same seq") atom_records = pdbp.renumber_pdb_inplace(atom_records, 1) else: interupt = sequence.split(pdb_seq[0:20]) #print(len(interupt[0])) atom_records = pdbp.renumber_pdb_inplace(