Difference between revisions of "Task 9 - Journal (PKU)"

From Bioinformatikpedia
(Created page with "==Renumbering Atoms in PDB file== To compare structures in normal mode analysis, the sequence and atom numbering has to be identical. We used a very simple python script to renu…")
 
 
(2 intermediate revisions by the same user not shown)
Line 13: Line 13:
 
for line in open(filename):
 
for line in open(filename):
 
if line.startswith("ATOM"):
 
if line.startswith("ATOM"):
tail = line[11:]
+
head = line[:11].split()
head = line[:11]
+
at = int(head[1])-offset
l = head.split()
 
at = int(l[1])-offset
 
 
i = 7-len(str(at))
 
i = 7-len(str(at))
head = l[0]+" "*i+str(at)
+
head = head[0]+" "*i+str(at)
print head+tail,
+
print head+line[11:],
 
else:
 
else:
 
print line,
 
print line,
  +
</source>
  +
  +
[[Category: Phenylketonuria 2012]]

Latest revision as of 11:58, 29 August 2012

Renumbering Atoms in PDB file

To compare structures in normal mode analysis, the sequence and atom numbering has to be identical. We used a very simple python script to renumber a PDB file after we deleted an extra residue:

<source lang="python">

  1. !/usr/bin/env python
  2. first argument: the pdb file
  3. second argument: the number of deleted atoms (would be nice if no number means "start with 1", but that's an effort..)

import sys

filename = sys.argv[1] offset = int(sys.argv[2]) for line in open(filename):

   if line.startswith("ATOM"):
       head = line[:11].split()
       at = int(head[1])-offset
       i = 7-len(str(at))
       head = head[0]+" "*i+str(at)
       print head+line[11:],
   else:
       print line,

</source>