Esempio n. 1
0
  /**
   * creates a virtual C-beta atom. this might be needed when working with GLY
   *
   * <p>thanks to Peter Lackner for a python template of this method.
   *
   * @param amino the amino acid for which a "virtual" CB atom should be calculated
   * @return a "virtual" CB atom
   * @throws StructureException
   */
  public static final Atom createVirtualCBAtom(AminoAcid amino) throws StructureException {

    AminoAcid ala = StandardAminoAcid.getAminoAcid("ALA");
    Atom aN = ala.getN();
    Atom aCA = ala.getCA();
    Atom aC = ala.getC();
    Atom aCB = ala.getCB();

    Atom[] arr1 = new Atom[3];
    arr1[0] = aN;
    arr1[1] = aCA;
    arr1[2] = aC;

    Atom[] arr2 = new Atom[3];
    arr2[0] = amino.getN();
    arr2[1] = amino.getCA();
    arr2[2] = amino.getC();

    // ok now we got the two arrays, do a SVD:

    SVDSuperimposer svd = new SVDSuperimposer(arr2, arr1);

    Matrix rotMatrix = svd.getRotation();
    Atom tranMatrix = svd.getTranslation();

    Calc.rotate(aCB, rotMatrix);

    Atom virtualCB = Calc.add(aCB, tranMatrix);
    virtualCB.setName("CB");
    virtualCB.setFullName(" CB ");

    return virtualCB;
  }
Esempio n. 2
0
  /**
   * Rotate a structure object.
   *
   * @param structure the structure to be rotated
   * @param m rotation matrix to be applied
   */
  public static final void rotate(Structure structure, Matrix m) {

    AtomIterator iter = new AtomIterator(structure);

    while (iter.hasNext()) {
      Atom atom = (Atom) iter.next();
      rotate(atom, m);
    }
  }
Esempio n. 3
0
  /**
   * Rotate a group object.
   *
   * @param group a group to be rotated
   * @param m a Matrix object representing the translation matrix
   */
  public static final void rotate(Group group, Matrix m) {

    AtomIterator iter = new AtomIterator(group);

    while (iter.hasNext()) {
      Atom atom = (Atom) iter.next();
      rotate(atom, m);
    }
  }
Esempio n. 4
0
 /**
  * Rotate a structure.
  *
  * @param structure a Structure object
  * @param rotationmatrix an array (3x3) of double representing the rotation matrix.
  * @throws StructureException ...
  */
 public static final void rotate(Structure structure, double[][] rotationmatrix)
     throws StructureException {
   double[][] m = rotationmatrix;
   if (m.length != 3) {
     throw new StructureException("matrix does not have size 3x3 !");
   }
   AtomIterator iter = new AtomIterator(structure);
   while (iter.hasNext()) {
     Atom atom = (Atom) iter.next();
     Calc.rotate(atom, rotationmatrix);
   }
 }
Esempio n. 5
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;
      }
    }