/** * 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; }
public Axis(RotationAxis rot) { theta = (float) rot.getAngle(); x = (float) rot.getRotationAxis().getX(); y = (float) rot.getRotationAxis().getY(); z = (float) rot.getRotationAxis().getZ(); screw = (float) (Calc.amount(rot.getScrewTranslation()) / Calc.amount(rot.getRotationAxis())); orthogonal = (float) (Calc.amount(rot.getOtherTranslation()) / Calc.amount(rot.getRotationAxis())); }
/** * 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); } }
@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; } }
/** * Returns list of indices of atoms within probe distance to atom k. * * @param k index of atom for which we want neighbor indices */ private ArrayList<Integer> findNeighborIndices(int k) { // looking at a typical protein case, number of neighbours are from ~10 to ~50, with an average // of ~30 // Thus 40 seems to be a good compromise for the starting capacity ArrayList<Integer> neighbor_indices = new ArrayList<Integer>(40); double radius = radii[k] + probe + probe; for (int i = 0; i < atoms.length; i++) { if (i == k) continue; double dist = 0; dist = Calc.getDistance(atoms[i], atoms[k]); if (dist < radius + radii[i]) { neighbor_indices.add(i); } } return neighbor_indices; }