package pl.org.ptbi; import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.biojava.bio.structure.Atom; import org.biojava.bio.structure.Calc; import org.biojava.bio.structure.Chain; import org.biojava.bio.structure.Group; import org.biojava.bio.structure.SVDSuperimposer; import org.biojava.bio.structure.Structure; import org.biojava.bio.structure.StructureException; import org.biojava.bio.structure.io.PDBFileReader; public class Main { public static void main(String[] args) { PDBFileReader reader = new PDBFileReader(); reader.setAutoFetch(true); reader.setPath(System.getProperty("java.io.tmpdir")); try { Structure left = reader.getStructureById("1EHZ"); Structure right = reader.getStructureById("1EVV"); List listLeft = getPhosphorus(left.getChainByPDB("A")); List listRight = getPhosphorus(right.getChainByPDB("A")); Atom[] atomSet1 = listLeft.toArray(new Atom[listLeft.size()]); Atom[] atomSet2 = listRight.toArray(new Atom[listRight.size()]); SVDSuperimposer superimposer = new SVDSuperimposer(atomSet1, atomSet2); Calc.rotate(right, superimposer.getRotation()); Calc.shift(right, superimposer.getTranslation()); double rmsd = SVDSuperimposer.getRMS(atomSet1, atomSet2); System.out.println(rmsd); } catch (IOException | StructureException e) { e.printStackTrace(); } } private static List getPhosphorus(Chain chain) { List list = new ArrayList<>(); for (Group group : chain.getAtomGroups()) { try { Atom atom = group.getAtom("P"); list.add(atom); } catch (StructureException e) { System.err.println(e.getMessage()); } } return list; } }