0

I am trying to do a structural alignment using BioJava libraries. I want to pick some chains from one structure object one by one and add them to another structure object so I can do structural alignment with them but I couldn't yet figure out how. The code I wrote so far is below, but it gives null pointer exception (probably because new_structure is set to null). What else can I try?

 private static Structure prepareStructures(String structure_name, AtomCache cache){

    Structure structure = null;
    Structure new_structure = null;
    String[] pdbnchain;
    try{
        pdbnchain = structure_name.split("\\.");
        structure = cache.getStructure(pdbnchain[0]);
        for(int i = 0; i < pdbnchain[1].length(); i++){
            String letter = pdbnchain[1].charAt(i)+"";
            new_structure.addChain(structure.getChainByPDB(letter));
        }
    } catch(Exception ex){
        ex.printStackTrace();
    }
    return new_structure;
}
4

1 回答 1

1

您可以使用 :

Structure new_structure = structure.clone();

获得结构的相同副本。然后您将在 new_structure 中拥有所有第一个结构的链。

也许你应该这样做:

structure = cache.getStructure(pdbnchain[0]);
new_structure = structure.clone();

有一个非空值。请参阅文档。

你也可以试试:

Structure new_structure = new StructureImpl(); // StructureImpl implements Structure interface.
于 2014-08-09T15:07:53.323 回答