gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 12:39:50 24 4
gpt4 key购买 nike

我正在尝试使用 BioJava 库进行结构对齐。我想从一个结构对象中一个接一个地挑选一些链,并将它们添加到另一个结构对象中,这样我就可以与它们进行结构对齐,但我还不知道如何做。到目前为止我编写的代码如下,但它给出了空指针异常(可能是因为 new_struct 设置为 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;
}

最佳答案

你可以使用:

Structure new_structure = structure.clone();

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

也许你应该在以下时间之后这样做:

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

具有非空值。请引用this文档。

您还可以尝试:

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

关于java - 我如何选择多个链作为biojava中结构对齐的结构对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25219523/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com