pdb file reading

User b339fedd4e

07-12-2007 11:23:43

hi,


i am new to this jchem


Could u pls give me the code for retreiving the triplet code from pdb file


in java.





Thank u





Regards,


richa

ChemAxon efa1591b5a

07-12-2007 12:45:19

Hi Richa, I'm afraid we do not have the capacity to write sample codes for all user requests.


We recommend to study the corresponding API documentation and report us any specific problems or difficulties you experienced.





You may wish to look at these pages:


http://www.chemaxon.com/marvin/doc/api/chemaxon/marvin/modules/MacroMolecule.Polymer.AtomIterator.html.


http://www.chemaxon.com/marvin/doc/api/chemaxon/marvin/modules/MacroMolecule.Polymer.AtomIterator.html#getResidueType()





Please note that we require you to provide valid details in your profile in order to receive further support.





Regards,


Miklos

User b339fedd4e

10-12-2007 08:53:51

Hi,


Here I am pasting my code.





DataOutputStream dos = new DataOutputStream(new FileOutputStream("out.txt"));


PDBReader pdbReader = new PDBReader();


String filename = "./1ZZL.pdb";


InputStream is = new FileInputStream(new File(filename));


MolInputStream mis = new MolInputStream(is);


MacroMolecule macroMol;


AtomProperty ap;


AtomIterator ai;


ComponentIterator compIt;


Component comp;


MolExporter molExp = new MolExporter(os, "sdf");


pdbReader.setInput(mis);


macroMol = pdbReader.read();


compIt = macroMol.getIterator();





int j=0;


while (compIt.hasNext())


{


j++;


comp = compIt.next();


double x = ai.getX();


double y = ai.getY();


double z = ai.getZ();


dos.writeBytes(x +"\t" + y + "\t" + z + "\n");


}








If I run this code I am getting the following exception.





Exception in thread "main" java.lang.ClassCastException: chemaxon.marvin.modules.MoleculeIterators$MoleculeAtomIterator





and if I run this following code





ap = (AtomProperty)comp.getAtomProperty();


for(int i = 0; i<=comp.getAtomCount();i++)


{


double x = ap.getX(i);


double y = ap.getY(i);


double z = ap.getZ(i);


//System.out.println(x);


dos.writeBytes(x +"\t" + y + "\t" + z + "\n");





I am getting some junk data like Infinite as x coordinates and y and z as 0.00





Residue lable as unrecognized command.





My profile is updated.





Could u please rectify my doubt.





Thank you.





Waiting for ur reply.


Regards,


richa.

ChemAxon efa1591b5a

10-12-2007 09:46:10

You should use an AtomIterator fetched from the Polymer by http://www.chemaxon.com/marvin/doc/api/chemaxon/marvin/modules/MacroMolecule.Polymer.html#getAtomIterator(boolean). This iterator, as all Iterators in java should be reset()-ed (http://www.chemaxon.com/marvin/doc/api/chemaxon/marvin/modules/MoleculeIterators.AtomIteratorInterface.html#reset()), then used element by element while is has next element (http://www.chemaxon.com/marvin/doc/api/chemaxon/marvin/modules/MoleculeIterators.AtomIteratorInterface.html#hasNext()).





HTH


Regards


Miklos