/** * * @param atom1 the first {@link Atom} in structure. * @param atom2 the second {@link Atom} in structure. * @return the distance between the two atoms in Angstrom. */ public static double getAtomDistance(Atom atom1, Atom atom2) { double distance; distance = Calc.getDistance(atom1, atom2); return distance; }
/** rotate and shift atoms with currentRotMatrix and current Tranmatrix * * @param ca */ private void rotateShiftAtoms(Atom[] ca){ for (int i = 0 ; i < ca.length; i++){ Atom c = ca[i]; Calc.rotate(c,currentRotMatrix); Calc.shift(c,currentTranMatrix); //System.out.println("after " + c); ca[i] = c; } //System.out.println("after " + ca[0]); }
/** * Projects a given point onto the axis of rotation * @param point * @return An atom which lies on the axis, or null if the RotationAxis is purely translational */ public Atom getProjectedPoint(Atom point) { if(rotationPos == null) { // translation only return null; } Atom localPoint = Calc.subtract(point, rotationPos); double dot = Calc.scalarProduct(localPoint, rotationAxis); Atom localProjected = Calc.scale(rotationAxis, dot); Atom projected = Calc.add(localProjected, rotationPos); return projected; }
/** * Center the atoms at the Centroid. * * @param atomSet * a set of Atoms * @return an Atom representing the Centroid of the set of atoms * @throws StructureException * */ public static final Atom[] centerAtoms(Atom[] atomSet) throws StructureException { Atom centroid = getCentroid(atomSet); return centerAtoms(atomSet, centroid); }
Matrix4d trans = SuperPositions.superpose(Calc.atomsToPoints(ca1aligned), Calc.atomsToPoints(ca2aligned)); Atom shift = Calc.getTranslationVector(trans); Calc.rotate(a, matrix); Calc.shift(a, shift); double rmsd = Calc.rmsd(ca1aligned, ca2aligned); double tmScore = Calc.getTMScore(ca1aligned, ca2aligned, ca1.length, ca2.length); afpChain.setTotalRmsdOpt(rmsd); afpChain.setTMScore(tmScore); Matrix4d transb = SuperPositions.superpose(Calc.atomsToPoints(ca1block), Calc.atomsToPoints(ca2block)); blockShifts[k] = Calc.getTranslationVector(trans); Calc.transform(ca2block, transb); double rmsdb = Calc.rmsd(ca1block, ca2block); double tmScoreb = Calc.getTMScore(ca1block, ca2block, ca1.length, ca2.length); blockRMSD[k] = rmsdb; blockScore[k] = tmScoreb;
/** superimpose and get rmsd * * @param pro1 * @param pro2 * @param strLen Number of atoms from pro1 and pro2 to use * @param storeTransform Store rotation and shift matrices locally * @return RMSD * @throws StructureException */ public double calc_rmsd(Atom[] pro1, Atom[] pro2, int strLen, boolean storeTransform) throws StructureException { Atom[] cod1 = getAtoms(pro1, strLen,false); Atom[] cod2 = getAtoms(pro2, strLen,true); Matrix4d trans = SuperPositions.superpose(Calc.atomsToPoints(cod1), Calc.atomsToPoints(cod2)); Matrix matrix = Matrices.getRotationJAMA(trans); Atom shift = Calc.getTranslationVector(trans); if ( storeTransform) { r = matrix; t = shift; } for (Atom a : cod2) Calc.transform(a.getGroup(), trans); return Calc.rmsd(cod1, cod2); }
for (int p = 0; p < optAln[b][0].length; p++) { Atom ca2clone = ca2[optAln[b][1][p]]; Calc.rotate(ca2clone, afpChain.getBlockRotationMatrix()[b]); Calc.shift(ca2clone, afpChain.getBlockShiftVector()[b]); double distance = Calc.getDistance(ca1[optAln[b][0][p]], ca2clone); if (distance > maxDistance) {
Atom centr1 = Calc.getCentroid(atoms1); Atom centr2 = Calc.getCentroid(atoms2); Calc.transform(centr2, transform); double dCentroid = Calc.getDistance(centr1, centr2); if (dCentroid > aParams.getdCutoff()) { logger.debug(String.format("Subunit matching %d " Calc.transform(atoms2c, transform); Calc.atomsToPoints(atoms1), Calc.atomsToPoints(atoms2c), false); qOrient = Math.min(Math.abs(2*Math.PI - qOrient), qOrient); if (qOrient > aParams.getMaxOrientationAngle()) { double rmsd = Calc.rmsd(atoms1, atoms2c); if (rmsd > aParams.getMaxRmsd()) { logger.debug(String.format("Subunit matching %d "
return Calc.getDistance(ca1,ca2); dist = Calc.getDistance(cb1,cb2); dist = Calc.getDistance(ca1,ca2); Atom c1 = Calc.subtract(cb1, ca1); Atom c2 = Calc.subtract(cb2, ca2); Atom newA = Calc.subtract(c2, c1); dist = Calc.amount(newA); } else { Atom cacb1 = Calc.subtract(cb1, ca1); Atom cacb2 = Calc.subtract(cb2, ca2); Atom newA = Calc.subtract(cacb2, cacb1); dist += Calc.amount(newA); dist += Calc.getDistance(ca1,ca2); if ( cb1 != null && cb2 != null) { dist = Calc.getDistance(cb1,cb2); dist = Calc.getDistance(ca1,ca2); return Calc.getDistance(ca1,ca2);
public void rotate(Atom[] atoms, double theta) { Matrix rot = getRotationMatrix(theta); if(rotationPos == null) { // Undefined rotation axis; do nothing return; } Atom negPos; negPos = Calc.invert(rotationPos); for(Atom a: atoms) { Calc.shift(a, negPos); } Calc.rotate(atoms, rot); for(Atom a: atoms) { Calc.shift(a, rotationPos); } }
Atom N = groups[index+1].getN(); if (Calc.getDistance(C, N) > MAX_PEPTIDE_BOND_LENGTH){ bonded = false; break; Atom caminus2 = Calc.subtract(caim2,cag); Atom caplus2 = Calc.subtract(cag,caip2); double angle = Calc.angle(caminus2, caplus2);
Matrix4d transform = svd.superpose(Calc.atomsToPoints(arr1), Calc.atomsToPoints(arr2)); Matrix rotMatrix = Matrices.getRotationJAMA(transform); Atom tranMatrix = getTranslationVector(transform); Calc.rotate(aCB,rotMatrix); Atom virtualCB = Calc.add(aCB,tranMatrix); virtualCB.setName("CB");
/** * Get the RMS of the JointFragments pair frag * * @param ca1 the array of all atoms of structure1 * @param ca2 the array of all atoms of structure1 * @param frag the JointFragments object that contains the list of identical positions * @return the rms */ public static double getRMS(Atom[] ca1, Atom[]ca2,JointFragments frag) throws StructureException { // now svd ftmp and check if the rms is < X ... AlternativeAlignment ali = new AlternativeAlignment(); ali.apairs_from_idxlst(frag); double rms = 999; int[] idx1 = ali.getIdx1(); int[] idx2 = ali.getIdx2(); Atom[] ca1subset = AlignUtils.getFragmentFromIdxList(ca1, idx1); Atom[] ca2subset = AlignUtils.getFragmentFromIdxList(ca2,idx2); ali.calculateSuperpositionByIdx(ca1,ca2); Matrix rot = ali.getRotationMatrix(); Atom atom = ali.getShift(); for (Atom a : ca2subset) { Calc.rotate(a, rot); Calc.shift(a, atom); } rms = Calc.rmsd(ca1subset,ca2subset); return rms; }
Matrix4d trans = SuperPositions.superpose(Calc.atomsToPoints(catmp1), Calc.atomsToPoints(catmp2)); Calc.transform(catmp2, trans); return Calc.rmsd(catmp1,catmp2);
/** this is probably useless * * @param ca1subset * @param ca2subset * @return a double * @throws StructureException */ private double getDensity(Atom[] ca1subset, Atom[] ca2subset ) throws StructureException{ Atom centroid1 = Calc.getCentroid(ca1subset); Atom centroid2 = Calc.getCentroid(ca2subset); // get Average distance to centroid ... double d1 = 0; double d2 = 0; for ( int i = 0 ; i < ca1subset.length;i++){ double dd1 = Calc.getDistance(centroid1, ca1subset[i]); double dd2 = Calc.getDistance(centroid2, ca2subset[i]); d1 += dd1; d2 += dd2; } double avd1 = d1 / ca1subset.length; double avd2 = d2 / ca2subset.length; return Math.min(avd1,avd2); }
Atom ab = subtract(a,b); Atom cb = subtract(c,b); Atom bc = subtract(b,c); Atom dc = subtract(d,c); Atom abc = vectorProduct(ab,cb); Atom bcd = vectorProduct(bc,dc); double angl = angle(abc,bcd) ; Atom vecprod = vectorProduct(abc,bcd); double val = scalarProduct(cb,vecprod); if (val < 0.0) angl = -angl;
public static void rotate(Atom[] ca, Matrix matrix) { for (Atom atom : ca) Calc.rotate(atom, matrix); }
private static Atom calcSimple_H(Atom c, Atom o, Atom n) { Atom h = Calc.subtract(c,o); double dist = Calc.getDistance(o,c); //System.out.println(dist); double x = n.getX() + h.getX() / dist; double y = n.getY() + h.getY() / dist; double z = n.getZ() + h.getZ() / dist; h.setX(x); h.setY(y); h.setZ(z); h.setName("H"); return h; }
/** * Use unit vectors NC and NCalpha Add them. Calc unit vector and * substract it from N. * C coordinates are from amino acid i-1 * N, CA atoms from amino acid i * * @link http://openbioinformatics.blogspot.com/ * 2009/08/how-to-calculate-h-atoms-for-nitrogens.html */ @SuppressWarnings("unused") private static Atom calc_H(Atom C, Atom N, Atom CA) throws StructureException { Atom nc = Calc.subtract(N,C); Atom nca = Calc.subtract(N,CA); Atom u_nc = Calc.unitVector(nc) ; Atom u_nca = Calc.unitVector(nca); Atom added = Calc.add(u_nc,u_nca); Atom U = Calc.unitVector(added); // according to Creighton distance N-H is 1.03 +/- 0.02A Atom H = Calc.add(N,U); H.setName("H"); // this atom does not have a pdbserial number ... return H; }