Esempio n. 1
0
  public static Atom getTranslation(AFPChain afpChain, Atom[] ca1, Atom[] ca2)
      throws StructureException {

    Atom[] a1 = getAlignedAtoms1(afpChain, ca1);
    Atom[] a2 = getAlignedAtoms2(afpChain, ca2);

    SVDSuperimposer svd = new SVDSuperimposer(a1, a2);

    return svd.getTranslation();
  }
Esempio n. 2
0
    @Override
    public double calculate(
        MultipleAlignment reference,
        AFPChain align,
        Atom[] ca1,
        Atom[] ca2,
        Map<String, Object> metaData) {
      try {

        List<Atom[]> structures = new ArrayList<Atom[]>(2);
        structures.add(ca1);
        structures.add(ca2);
        int[][] optAln = reference.getAlignmentMatrix(structures);

        // Create new arrays for the subset of atoms in the alignment.
        Atom[] ca1aligned = new Atom[reference.size()];
        Atom[] ca2aligned = new Atom[reference.size()];
        int pos = 0;
        for (int i = 0; i < optAln[0].length; i++) {
          ca1aligned[pos] = ca1[optAln[0][pos]];
          ca2aligned[pos] = (Atom) ca2[optAln[1][pos]].clone();
          pos++;
        }

        // Superimpose
        SVDSuperimposer svd = new SVDSuperimposer(ca1aligned, ca2aligned);
        Matrix matrix = svd.getRotation();
        Atom shift = svd.getTranslation();

        for (Atom a : ca2aligned) {
          Calc.rotate(a, matrix);
          Calc.shift(a, shift);
        }

        return SVDSuperimposer.getTMScore(ca1aligned, ca2aligned, ca1.length, ca2.length);
      } catch (StructureException e) {
        e.printStackTrace();
        return Double.NaN;
      }
    }