I am new to perl and this may seem a vague question. I have a PDB file and I just want to add 10 to all X coordinates of the file. can anyone please help me with the code??
Basically, what you're asking is how to access the coordinate section of a PDB file. Lots of answers to this question.
Without writing the code for you, here's an outline of what your code needs to do:
So the main Perl concepts that you need to learn are:
A lot of this is covered by answers to a previous question. But really, it's probably better to use an existing parser which will have considered the difficult cases (see Bosco's comment).
alas, space-delimited arrays fails with PDB files, several gotchas:
- there's a column for insertions, alternate conformations
- chain id's can sometimes be a space or a letter/number
- there are no defined spaces between the x,y,z coordinates. there are accidental spaces if not all significant figures are used
to parse pdb, you must read specific positions on the line.
All true, answer amended accordingly.
if you're using a XML-PDB file, you can use the following xslt stylesheet to add 10 to all the elements Cartn_x:
<xsl:stylesheet xmlns:xsl="<a href="http://www.w3.org/1999/XSL/Transform" "="" rel="nofollow">http://www.w3.org/1999/XSL/Transform'
<xsl:value-of select="10 + number(.)"/>
xsltproc stylesheet.xsl pdb.xml
Login before adding your answer.
Use of this site constitutes acceptance of our User Agreement and Privacy