use of de.bioforscher.jstructure.model.structure.Atom in project jstructure by JonStargaryen.
the class AccessibleSurfaceAreaCalculator method calcSingleAsa.
/**
* Calculates the accessible surface area (ASA) of an individual atom.
* @param atom the atom to processUniProtId
* @return this atom's ASA
*/
private double calcSingleAsa(Atom atom, List<Atom> nonHydrogenAtoms) {
List<Atom> neighborAtoms = findNeighbors(atom, nonHydrogenAtoms);
double radius = probeSize + atom.getFeatureContainer().getFeature(AtomRadius.class).getRadius();
int accessiblePoints = 0;
for (double[] point : spherePoints) {
boolean isAccessible = true;
double[] testPoint = LinearAlgebra.on(point).multiply(radius).add(atom.getCoordinates()).getValue();
for (Atom neighborAtom : neighborAtoms) {
double neighborAtomRadius = neighborAtom.getFeatureContainer().getFeature(AtomRadius.class).getRadius() + probeSize;
double differenceSquared = LinearAlgebra.on(testPoint).distanceFast(neighborAtom.getCoordinates());
if (differenceSquared < neighborAtomRadius * neighborAtomRadius) {
isAccessible = false;
break;
}
}
if (isAccessible) {
accessiblePoints++;
}
}
return cons * accessiblePoints * radius * radius;
}
use of de.bioforscher.jstructure.model.structure.Atom in project jstructure by JonStargaryen.
the class AtomLinearAlgebraTest method transform.
@Test
public void transform() throws Exception {
// example from http://stackoverflow.com/questions/34050929/3d-point-rotation-algorithm
double[] point = { 1, 0, 0 };
final double[] expectedPoint = { 0, -1, 0 };
System.out.printf("rotating %s by -90 degree yields ", Arrays.toString(point));
// describes a rotation by 90°
double[][] rotation = { { 0, -1, 0 }, { 1, 0, 0 }, { 0, 0, 1 } };
Transformation transformation = new Transformation(rotation);
Atom atom = new Atom(point);
transformation.transformCoordinates(atom);
System.out.println(Arrays.toString(atom.getCoordinates()));
Assert.assertArrayEquals(expectedPoint, atom.getCoordinates(), 0.0);
double[] point2 = { 3, 0, 0 };
final double[] expectedPoint2 = { -2, -3, 0 };
double[] translation2 = { -2, 0, 0 };
System.out.printf("translating %s by 2 length units toward origin and rotating it by -90 degree yields ", Arrays.toString(point2));
// describes a rotation by 90°
double[][] rotation2 = { { 0, -1, 0 }, { 1, 0, 0 }, { 0, 0, 1 } };
Transformation transformation2 = new Transformation(translation2, rotation2);
Atom atom2 = new Atom(point2);
transformation2.transformCoordinates(atom2);
System.out.println(Arrays.toString(atom2.getCoordinates()));
Assert.assertArrayEquals(expectedPoint2, atom2.getCoordinates(), 0.0);
}
Aggregations