简体   繁体   中英

how can i choose multiple chains as a structure object for structural alignment in biojava

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

you can use :

Structure new_structure = structure.clone();

to get an identical copy of the structure.Then you will be having all chains of first structure in the new_structure too.

probably you should do that after:

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

to have a non null value. Please refer to this documentation.

You can also try:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM