use of org.biojava.nbio.structure.align.StructureAlignment in project mm-dev by sbl-sdsc.
the class BiojavaAligner method getAlignment.
/**
* Calculates a structural alignment and returns alignment metrics.
*
* @param alignmentAlgorithm name of the algorithm
* @param key unique identifier for protein chain pair
* @param points1 C-alpha positions of chain 1
* @param points2 C-alpha positions of chain 2
* @return
*/
public static List<Row> getAlignment(String alignmentAlgorithm, String key, Point3d[] points1, Point3d[] points2) {
// create input for BioJava alignment method
Atom[] ca1 = getCAAtoms(points1);
Atom[] ca2 = getCAAtoms(points2);
// calculate the alignment
AFPChain afp = null;
try {
StructureAlignment algorithm = StructureAlignmentFactory.getAlgorithm(alignmentAlgorithm);
afp = algorithm.align(ca1, ca2);
double tmScore = AFPChainScorer.getTMScore(afp, ca1, ca2);
afp.setTMScore(tmScore);
} catch (StructureException e) {
e.printStackTrace();
return Collections.emptyList();
}
// TODO add alignments as arrays to results
// int[][] alignment = afp.getAfpIndex();
// for (int i = 0; i < alignment.length; i++) {
// System.out.println(alignment[i][0] + " - " + alignment[i][1]);
// }
// record the alignment metrics
Row row = RowFactory.create(key, afp.getOptLength(), afp.getCoverage1(), afp.getCoverage2(), (float) afp.getTotalRmsdOpt(), (float) afp.getTMScore());
return Collections.singletonList(row);
}
Aggregations