Saturday, March 18, 2006

 

Reading a PDB file in C

Attempted to read a PDB file in C? Got frustrated? Hope not, but if so, here's a small key for reading the PDB's ATOM fields:


First and second line represent the positions of the array you have to access to read that field. For example:

char tempString[80];
for(fgets(tempString,80,pdbfile);!(strstr(tempString,"ATOM "));fgets(tempString,80,pdbfile)); //Search for the first ATOM card
x = atof(&tempString[31]); /* Scan the coordinates for the first atom */
y = atof(&tempString[39]);
z = atof(&tempString[47]);

Good luck!

This page is powered by Blogger. Isn't yours?