Hi Jay,

what you are doing seems complicated...

after
atoms = StructureTools.getAtomCAArray(s.getChain(0));

you  could do:

for (Atom atom: atoms) {
  Group parent = atom.getGroup();
  ch.addGroup(parent)...

}

the error is caused by this line:
a.setPDBName(new AminoAcidBean(aminoAcids[i]).getThreeLetter());

you could just do
a.setPDBName(atom.getGroup().getPDBName())
if you wanted to create a 2nd copy of the data in memory. Not sure
what the AminoAcidBean is doing. This seems to be some of your own
code, right?

Andreas

On Wed, Nov 3, 2010 at 10:57 AM, Jay Vyas <[email protected]> wrote:
> Hi guys : Im using the biojava structure api to merge some structures .
>
> Ive written the following test method, which I believe should work to merge
> the first chain of several different structures into on Structure object. Im
> only concerned about CA's for now.
>
> is there an easier way to do this ?
>
> public static Structure merge(List<Structure> struc) throws Exception
>
> {
>
> StructureImpl si = new StructureImpl();
>
>         si.setPDBCode("1JAY");
>
> si.setId(0L);
>
> si.setName("Merged");
>
> si.setPDBHeader(new PDBHeader());
>
> si.setNmr(true);
>
>
>  int index=0;
>
> for(Structure s : struc)
>
> {
>
> ChainImpl ch = new ChainImpl();
>
> ch.setName(alphabet.charAt(index++)+"");
>
> ch.setChainID(ch.getName());
>
> //strip atoms of the backbone, add them to a chain.
>
> Atom[] atoms = StructureTools.getAtomCAArray(s.getChain(0));
>
> char[] aminoAcids = s.getChain(0).getAtomSequence().toCharArray();
>
>  for(int i = 0 ; i < atoms.length; i++)
>
> {
>
> AminoAcid a = new AminoAcidImpl();
>
> a.setAminoType(aminoAcids[i]);
>
> a.setPDBName(new AminoAcidBean(aminoAcids[i]).getThreeLetter());
>
> a.setResidueNumber(new ResidueNumber(ch.getChainID(), i, null));
>
> a.getAtoms().add(atoms[i]);
>
> a.setChain(ch);
>
> ch.addGroup(a);
>
> }
>
> Jlog.info("adding chain " + si.getName());
>
> si.addChain(ch);
>
> }
>
> System.out.println(si.toPDB());
>
> return si;
>
> }
>
>
> but it crashes due to a null pointer exception
>
> at org.biojava.bio.structure.io.FileConvert.alignLeft(FileConvert.java:86)
>
> at org.biojava.bio.structure.io.FileConvert.toPDB(FileConvert.java:296)
>
> at org.biojava.bio.structure.StructureImpl.toPDB(StructureImpl.java:566)
>
> at common.Utilities.merge(Utilities.java:92)
>
> at common.Utilities.main(Utilities.java:115)
> _______________________________________________
> Biojava-l mailing list  -  [email protected]
> http://lists.open-bio.org/mailman/listinfo/biojava-l
>



-- 
-----------------------------------------------------------------------
Dr. Andreas Prlic
Senior Scientist, RCSB PDB Protein Data Bank
University of California, San Diego
(+1) 858.246.0526
-----------------------------------------------------------------------

_______________________________________________
Biojava-l mailing list  -  [email protected]
http://lists.open-bio.org/mailman/listinfo/biojava-l

Reply via email to