[Biojava-l] merging structures

Jay Vyas jayunit100 at gmail.com
Wed Nov 3 17:57:01 UTC 2010


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)



More information about the Biojava-l mailing list