This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Perl Code For A Beginner...At Least A Start Would Be Really Helpful..Thank You.

First iterate through the PDB file

For each PDB file in list  
Read each atom
  If it is a Donor or Acceptor, store in list

For each Donor
  For each Acceptor
     If there is an H-bond, store Atom IDs and labels of the D/A pair in H-bond list

For each H-bond
  For each other H-bond
     If the nodes of two different bonds are in the same
     residue, add a "covalent" bond to list

For each Bond
  Add both bonded nodes to hash of unique nodes
perl pdb parsing protein homework

Hey! You just described the algorithm you want to use in pseudo-code. From here you only need to translate all the "for each" into a "for(...)" in perl, "if"s into "if (...)", etc.

If it just was that easy ;) Of course the perlcode for e.g. "If there is an H-bond" involves parsing the PDB file. I believe there were several questions about PDB parsing here, but I don't know if any solved this problem.

You are right, Michael. After the question has now been reformatted, it is clear that some parts -- such as "if there is an H-bond" -- are not as trivial as I first thought. I did not spot that beforehand.

3 answers

Whoever gave you this assignment does not understand PDB files very well. A PDB file contains information about the coordinates of atoms in a molecule. It contains no information about donors, acceptors or H-bonds. H-bonds are inferred by calculation, which examines the position of donors and acceptors to determine whether they lie within an acceptable distance of one another.

As WoA suggests in their answer, software is available for H-bond prediction. Two commonly-used tools for this task are DSSP and STRIDE. You may be able to obtain these from the web as standalone programs, or else they are included in some web servers.

Both tools generate delimited output which is quite easy to parse; STRIDE output is somewhat simpler and more straightforward. There are also modules in the Bioperl package that can be used to write parsers; they are named Bio::Structure::SecStr::DSSP::Res and Bio::Structure::SecStr::STRIDE::Res.

I would suggest first predict H-bonds using some software like this and then parse the resulting file

If you working with just proteins - convert the files into mol2 file and you will have all the information needed, but if you want to calculate the H-bonds between the ligand - it will be tricky.

Try Bio3D.

Just to mention...The h-bond donors and acceptors are clearly defined thru the pdb atom types

Log in to answer this question.