Search in sources :

Example 1 with Atom

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;
}
Also used : Chain(org.biojava.nbio.structure.Chain) AFPChain(org.biojava.nbio.structure.align.model.AFPChain) Group(org.biojava.nbio.structure.Group) ChainImpl(org.biojava.nbio.structure.ChainImpl) AtomImpl(org.biojava.nbio.structure.AtomImpl) AminoAcidImpl(org.biojava.nbio.structure.AminoAcidImpl) Atom(org.biojava.nbio.structure.Atom)

Example 2 with Atom

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;
        }
    }
}
Also used : MomentsOfInertia(org.biojava.nbio.structure.geometry.MomentsOfInertia) Atom(org.biojava.nbio.structure.Atom)

Example 3 with Atom

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);
}
Also used : AFPChain(org.biojava.nbio.structure.align.model.AFPChain) StructureException(org.biojava.nbio.structure.StructureException) StructureAlignment(org.biojava.nbio.structure.align.StructureAlignment) Row(org.apache.spark.sql.Row) Atom(org.biojava.nbio.structure.Atom)

Aggregations

Atom (org.biojava.nbio.structure.Atom)3 AFPChain (org.biojava.nbio.structure.align.model.AFPChain)2 Row (org.apache.spark.sql.Row)1 AminoAcidImpl (org.biojava.nbio.structure.AminoAcidImpl)1 AtomImpl (org.biojava.nbio.structure.AtomImpl)1 Chain (org.biojava.nbio.structure.Chain)1 ChainImpl (org.biojava.nbio.structure.ChainImpl)1 Group (org.biojava.nbio.structure.Group)1 StructureException (org.biojava.nbio.structure.StructureException)1 StructureAlignment (org.biojava.nbio.structure.align.StructureAlignment)1 MomentsOfInertia (org.biojava.nbio.structure.geometry.MomentsOfInertia)1