|
From: Jordan W. <jwi...@gm...> - 2013-01-21 18:51:42
|
Does it have to be a pymol script. Renumbering pdbs is the bread and butter of biopython pdb module:
#!/blue/meilerlab/apps/Linux2/x86_64/bin/python2.5
import sys
from Bio.PDB import *
from optparse import OptionParser
import warnings
def main():
usage = "%prog input.pdb output.pdb"
parser= OptionParser(usage)
parser.add_option("-n",dest="start",help="residue number to start with, default is 1",default=1)
parser.add_option("--preserve",dest="preserve",help="preserve insertion code and heteroflags",default=False, action="store_true")
parser.add_option("--norestart",dest="norestart",help="don't start renumbering at each chain, default=False",default=False, action="store_true")
(options, args) = parser.parse_args()
warnings.simplefilter('ignore',PDBExceptions.PDBConstructionWarning)
PDBparse = PDBParser(PERMISSIVE=1)
struct = PDBparse.get_structure(args[0][0:3],args[0])
residue_id = int(options.start)
chain_id = ""
for residue in struct.get_residues():
chain = residue.get_parent()
if(chain_id != chain.get_id() and not options.norestart):
chain_id = chain.get_id()
residue_id=int(options.start)
if(options.preserve):
hetero = residue.id[0]
insert = residue.id[2]
residue.id=(hetero,residue_id,insert)
else:
residue.id=(' ',residue_id,' ')
residue_id +=1
io=PDBIO()
io.set_structure(struct)
io.save(args[1])
if __name__ == "__main__":
main()
Jordan
On Jan 21, 2013, at 12:21 PM, Alex Truong <at...@bu...> wrote:
> Hi All,
>
> I've been having a bit of trouble recently with the renumber script. I have a pdb file that I'm trying to renumber, but unlike the other times I've used it, it is renumbering incorrectly. The numbers are usually spaced out 5 residues apart, but I have one number right near the beginning that is 6 residues down from the previous one. Needless to say, this is screwing up the rest of the count. Is there any idea why? I've provided a screenshot.
>
> Thanks,
> Alex
> <renumbererror.png>------------------------------------------------------------------------------
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. SALE $99.99 this month only -- learn more at:
> http://p.sf.net/sfu/learnmore_122412_______________________________________________
> PyMOL-users mailing list (PyM...@li...)
> Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
> Archives: http://www.mail-archive.com/pym...@li...
|
|
From: Thomas H. <tho...@sc...> - 2013-01-21 20:50:54
|
Hi Jordan, nice script, but it does not do the same like the renumber script from the PyMOLWiki (http://pymolwiki.org/index.php/Renumber). Try this: set all residue numbers to 1, the renumber script will not care because it walks along the bonds and increases the count whenever it passes a peptide bond. The Biopython parser however will read just one residue. Cheers, Thomas Jordan Willis wrote, On 01/21/13 19:53: > Does it have to be a pymol script. Renumbering pdbs is the bread and butter of biopython pdb module: > > #!/blue/meilerlab/apps/Linux2/x86_64/bin/python2.5 > import sys > from Bio.PDB import * > from optparse import OptionParser > import warnings > def main(): > usage = "%prog input.pdb output.pdb" > parser= OptionParser(usage) > parser.add_option("-n",dest="start",help="residue number to start with, default is 1",default=1) > parser.add_option("--preserve",dest="preserve",help="preserve insertion code and heteroflags",default=False, action="store_true") > parser.add_option("--norestart",dest="norestart",help="don't start renumbering at each chain, default=False",default=False, action="store_true") > (options, args) = parser.parse_args() > > warnings.simplefilter('ignore',PDBExceptions.PDBConstructionWarning) > PDBparse = PDBParser(PERMISSIVE=1) > struct = PDBparse.get_structure(args[0][0:3],args[0]) > residue_id = int(options.start) > chain_id = "" > for residue in struct.get_residues(): > chain = residue.get_parent() > if(chain_id != chain.get_id() and not options.norestart): > chain_id = chain.get_id() > residue_id=int(options.start) > if(options.preserve): > hetero = residue.id[0] > insert = residue.id[2] > residue.id=(hetero,residue_id,insert) > else: > residue.id=(' ',residue_id,' ') > residue_id +=1 > > > io=PDBIO() > io.set_structure(struct) > io.save(args[1]) > > if __name__ == "__main__": > main() -- Thomas Holder PyMOL Developer Schrödinger Contractor |