Search in sources :

Example 1 with AFPChain

use of org.biojava.nbio.structure.align.model.AFPChain 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);
}
Also used : AFPChain(org.biojava.nbio.structure.align.model.AFPChain) StructureException(org.biojava.nbio.structure.StructureException) StructureAlignment(org.biojava.nbio.structure.align.StructureAlignment) Row(org.apache.spark.sql.Row) Atom(org.biojava.nbio.structure.Atom)

Aggregations

Row (org.apache.spark.sql.Row)1 Atom (org.biojava.nbio.structure.Atom)1 StructureException (org.biojava.nbio.structure.StructureException)1 StructureAlignment (org.biojava.nbio.structure.align.StructureAlignment)1 AFPChain (org.biojava.nbio.structure.align.model.AFPChain)1