[BioRuby] How to renumber a PDB file using BioRuby ?
Alex Gutteridge
alexg at ruggedtextile.com
Thu Apr 10 08:13:59 UTC 2008
On 10 Apr 2008, at 07:32, K. Shameer wrote:
> Dear All,
>
> I have a pdb file ( in perfect pdb format, no hetatm, no solvent,
> single
> chain file). I need to renumber the whole pdb file, for example if my
> input file is 1CRN.pdb and it starts with residue number 1, I need to
> renumber them so that first resiude number will be 12, next 13,
> 14... like
> that. I want to know if I can specifically access the residue number
> and
> increment it from first residue using my new number (here it will be
> residue_number + 12)and regenerate the file.
>
> Anybody had tried this before,
>
> Thanks in advance for any help,
> K. Shameer
hi,
You have to alter the number by atom rather than by residue. Altering
the residue object directly used to work, but has been broken. Anyway,
this seems to work for your purpose:
require 'bio'
pdb = Bio::PDB.new(File.read(ARGV[0]))
pdb.each_atom do |atom|
atom.resSeq += 12
end
puts pdb
It would be good (IMHO) to have:
require 'bio'
pdb = Bio::PDB.new(File.read(ARGV[0]))
pdb.each_residue do |residue|
residue.resSeq += 10
end
puts pdb
Do the same thing, but currently changes to residue objects don't
propagate back down to the atoms so the above code doesn't do anything
useful.
Alex Gutteridge
Department of Biochemistry
University of Cambridge
More information about the BioRuby
mailing list