Krishan, Here is a simple stand-alone python script that should do what you want. Greg
#!/usr/bin/python # # rechainpdb.py # usage: # python rechainpdb.py mypdbfile1.pdb mypdbfile2.pdb mypdbfile3.pdb # # This will generate a new file with all pdbfile (ATOMs and HETATMs) in a single # file, with each pdbfile having a different chain id. Max pdbs is 26. # #ATOM 1 N ASP W 175 24.971 27.228 -12.398 1.00161.17 N #12345678901234567890123456789012345678901234567890123456789012345678901234567890 # 1 2 3 4 5 6 7 8 # # chain id is char 22 import sys if (len(sys.argv)==1): # no arguments were given print "+++++++++++++++++++++++++++++++++++++++++++++++++++++++" print "YOU NEED TO SUPPLY A LIST OF PDB FILES." print "e.g." print "python rechainpdb.py mypdbfile1.pdb mypdbfile2.pdb" print "" print "This will generate a single new file with each pdb in" print "the list having a different chain id." print "+++++++++++++++++++++++++++++++++++++++++++++++++++++++" sys.exit("\nExiting...\n") #possible chain ids CHAINLIST="ABCDEFGHIJKLMNOPQRSTUVWXYZ" filelist=[] #OUTPUT file name - default is to use the name of first pdb outputfilename=sys.argv[1][:-4]+"_allfiles.pdb" # generate a list of lists, where each file listed after the script # is a list of strings (lines) for x in range(1,len(sys.argv)): currentfile = open(sys.argv[x],'r') crudefile=currentfile.readlines() currentfile.close() cleanfile=[] for line in crudefile: cleanfile.append(line.strip()) filelist.append(cleanfile) # set up output file outputfile = open(outputfilename,'w') # write out one large pdbfile with each having a unique chain id for x in range(0,len(filelist)): for line in filelist[x]: if ((line[0:4]=="ATOM") or (line[0:6]=="HETATM")): print >>outputfile, line[:21]+CHAINLIST[x]+line[22:] print print "# # # # # # # # # # # # # # # # # # # # # # #" print print "The following chain ids were given to the input pdbfiles:" print for i in range(1,len(sys.argv)): print "chain id given:", CHAINLIST[i-1],sys.argv[i] print "- - - - - - - - - - - - - - - - - - - - - - - -" print print "Final file created:",outputfilename print print "# # # # # # # # # # # # # # # # # # # # # # #"
On Apr 8, 2011, at 7:17 AM, krishan wrote: > Dear CCP4BB members, > We are using a script written in python to generate symmetry mates for a > given pdb file using PYMOL. After generating symmetry mates we want to > combine all the symmetry molecules in a single PDB file with all the chains > having unique chain IDs. Since all the symmetry mates have same chain ID's I > was wondering if some one knows a script that can give unique chain ID for > each symmetry mate. We are interested in script because that dataset that we > are handling is large. > I thank you all in advance for your help. > Best, > > Krishan -- Department of Biophysics Johns Hopkins University 302 Jenkins Hall 3400 N. Charles St. Baltimore, MD 21218 Phone: (410) 516-7850 (office) Phone: (410) 516-3476 (lab) Fax: (410) 516-4118 gdbow...@jhu.edu