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