use of org.biojava.nbio.structure.Atom in project mm-dev by sbl-sdsc.
the class BiojavaAligner method getCAAtoms.
/**
* Converts an array of points representing C-alpha position to a minimal BioJava data structure.
*
* @param points coordinates of C-alpha atoms
* @return BioJava atom array
*/
private static Atom[] getCAAtoms(Point3d[] points) {
Chain c = new ChainImpl();
c.setId("A");
// create dummy BioJava atoms for each C-alpha coordinate
Atom[] atoms = new Atom[points.length];
for (int i = 0; i < points.length; i++) {
atoms[i] = new AtomImpl();
atoms[i].setName(CA_NAME);
Group g = new AminoAcidImpl();
g.setPDBName(GROUP_NAME);
g.setResidueNumber("A", i, ' ');
g.addAtom(atoms[i]);
c.addGroup(g);
atoms[i].setX(points[i].x);
atoms[i].setY(points[i].y);
atoms[i].setZ(points[i].z);
}
return atoms;
}
use of org.biojava.nbio.structure.Atom in project mm-dev by sbl-sdsc.
the class ShapeTypeDemo method calcShape.
private static String calcShape(Structure structure) {
// calculate moments of inertia for C-alpha atoms
MomentsOfInertia moi = new MomentsOfInertia();
for (Atom a : StructureTools.getAtomCAArray(structure)) {
moi.addPoint(a.getCoordsAsPoint3d(), 1.0);
}
// calculate symmetry based on the moments of inertia
String s1 = moi.getSymmetryClass(0.05).toString();
if (s1.equals("SYMMETRIC")) {
return s1;
} else {
String s2 = moi.getSymmetryClass(0.2).toString();
if (s2.equals("SYMMETRIC")) {
return "EXCLUDE";
} else {
return s2;
}
}
}
use of org.biojava.nbio.structure.Atom in project mm-dev by sbl-sdsc.
the class BiojavaAligner method getAlignment.
/**
* Calculates a structural alignment and returns alignment metrics.
*
* @param alignmentAlgorithm name of the algorithm
* @param key unique identifier for protein chain pair
* @param points1 C-alpha positions of chain 1
* @param points2 C-alpha positions of chain 2
* @return
*/
public static List<Row> getAlignment(String alignmentAlgorithm, String key, Point3d[] points1, Point3d[] points2) {
// create input for BioJava alignment method
Atom[] ca1 = getCAAtoms(points1);
Atom[] ca2 = getCAAtoms(points2);
// calculate the alignment
AFPChain afp = null;
try {
StructureAlignment algorithm = StructureAlignmentFactory.getAlgorithm(alignmentAlgorithm);
afp = algorithm.align(ca1, ca2);
double tmScore = AFPChainScorer.getTMScore(afp, ca1, ca2);
afp.setTMScore(tmScore);
} catch (StructureException e) {
e.printStackTrace();
return Collections.emptyList();
}
// TODO add alignments as arrays to results
// int[][] alignment = afp.getAfpIndex();
// for (int i = 0; i < alignment.length; i++) {
// System.out.println(alignment[i][0] + " - " + alignment[i][1]);
// }
// record the alignment metrics
Row row = RowFactory.create(key, afp.getOptLength(), afp.getCoverage1(), afp.getCoverage2(), (float) afp.getTotalRmsdOpt(), (float) afp.getTMScore());
return Collections.singletonList(row);
}
Aggregations