如何选择多个链作为biojava中结构对齐的结构对象

时间:2014-08-09 14:23:30

标签: java biojava

我正在尝试使用BioJava库进行结构对齐。我想逐个从一个结构对象中选择一些链并将它们添加到另一个结构对象中,这样我就可以对它们进行结构对齐,但我还是不知道如何。到目前为止我写的代码如下,但它给出了空指针异常(可能是因为new_structure设置为null)。我还能尝试什么?

 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;
}

1 个答案:

答案 0 :(得分:1)

你可以使用:

Structure new_structure = structure.clone();

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

可能你应该在以下之后这样做:

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

具有非null值。 请参阅this文档。

您也可以尝试:

Structure new_structure = new StructureImpl(); // StructureImpl implements Structure interface.