Skip to content
Prev Previous commit
Next Next commit
More checks and a warning in case no aligned atoms found. Also a few …
…minor fixes
  • Loading branch information
josemduarte committed Jan 22, 2020
commit d851f6078b50e7fbe5ffde3ff23d7bf16d4a211a
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.biojava.nbio.structure.cluster.SubunitClusterer;
import org.biojava.nbio.structure.cluster.SubunitClustererMethod;
import org.biojava.nbio.structure.cluster.SubunitClustererParameters;
import org.biojava.nbio.structure.io.FileParsingParameters;
import org.biojava.nbio.structure.symmetry.core.QuatSymmetryDetector;
import org.biojava.nbio.structure.symmetry.core.QuatSymmetryParameters;
import org.biojava.nbio.structure.symmetry.core.QuatSymmetryResults;
Expand Down Expand Up @@ -369,6 +370,13 @@ public void testPseudoIdentity95() throws IOException, StructureException {

@Test
public void testSymDetectionWithSubunitClusterByEntityId() throws IOException, StructureException {
AtomCache cache = new AtomCache();
cache.setUseMmtf(false);
cache.setUseMmCif(true);
FileParsingParameters params = new FileParsingParameters();
params.setAlignSeqRes(true);
cache.setFileParsingParams(params);
StructureIO.setAtomCache(cache);
Structure pdb = StructureIO.getStructure("BIO:1SMT:1");

SubunitClustererParameters cp = new SubunitClustererParameters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,11 @@ public boolean mergeIdenticalByEntityId(SubunitCluster other) {

int seqresIndex = entityInfo.getAlignedResIndex(g, thisChain);

if (seqresIndex == -1) {
// this might mean that FileParsingParameters.setAlignSeqRes() wasn't set to true during parsing
continue;
}

Group otherG = otherChain.getSeqResGroups().get(seqresIndex - 1);

if (!otherChain.getAtomGroups().contains(otherG)) {
Expand All @@ -310,6 +315,10 @@ public boolean mergeIdenticalByEntityId(SubunitCluster other) {
}
}

if (thisAligned.size() == 0 && otherAligned.size() == 0) {
logger.warn("No equivalent aligned atoms found between SubunitClusters {}-{} via entity seqres alignment. Is FileParsingParameters.setAlignSeqRes() set?", thisName, otherName);
}

updateEquivResidues(other, thisAligned, otherAligned);

return true;
Expand Down Expand Up @@ -743,7 +752,7 @@ public SubunitClustererMethod getClustererMethod() {
*/
public List<Atom[]> getAlignedAtomsSubunits() {

List<Atom[]> alignedAtoms = Collections.emptyList();
List<Atom[]> alignedAtoms = new ArrayList<>();

// Loop through all subunits and add the aligned positions
for (int s = 0; s < subunits.size(); s++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
* @author Peter
*/
public class C2RotationSolver implements QuatSymmetrySolver {
private QuatSymmetrySubunits subunits = null;
private QuatSymmetryParameters parameters = null;
private QuatSymmetrySubunits subunits;
private QuatSymmetryParameters parameters;
private Vector3d centroid = new Vector3d();
private Matrix4d centroidInverse = new Matrix4d();

Expand Down Expand Up @@ -132,7 +132,7 @@ private void solve() {
}

private void addEOperation() {
List<Integer> permutation = Arrays.asList(new Integer[]{0,1});
List<Integer> permutation = Arrays.asList(0,1);
Matrix4d transformation = new Matrix4d();
transformation.setIdentity();
combineWithTranslation(transformation);
Expand All @@ -145,7 +145,6 @@ private void addEOperation() {

/**
* Adds translational component to rotation matrix
* @param rotTrans
* @param rotation
* @return
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.biojava.nbio.structure.symmetry.core;

import org.biojava.nbio.structure.Atom;
import org.biojava.nbio.structure.Calc;
import org.biojava.nbio.structure.Chain;
import org.biojava.nbio.structure.cluster.SubunitCluster;
import org.biojava.nbio.structure.geometry.CalcPoint;
Expand All @@ -34,7 +35,7 @@
import java.util.stream.Collectors;

/**
* A bean to represent information about the set of {@link Subunit} being
* A bean to represent information about the set of {@link org.biojava.nbio.structure.cluster.Subunit}s being
* considered for symmetry detection. This class is a helper for the
* {@link QuatSymmetryDetector} algorithm, since it calculates and caches the
* {@link MomentsOfInertia} and the centroids of each Subunit.
Expand All @@ -45,13 +46,13 @@
*/
public class QuatSymmetrySubunits {

private List<Point3d[]> caCoords = new ArrayList<Point3d[]>();
private List<Point3d> originalCenters = new ArrayList<Point3d>();
private List<Point3d> centers = new ArrayList<Point3d>();
private List<Vector3d> unitVectors = new ArrayList<Vector3d>();
private List<Point3d[]> caCoords = new ArrayList<>();
private List<Point3d> originalCenters = new ArrayList<>();
private List<Point3d> centers = new ArrayList<>();
private List<Vector3d> unitVectors = new ArrayList<>();

private List<Integer> folds = new ArrayList<Integer>();
private List<Integer> clusterIds = new ArrayList<Integer>();
private List<Integer> folds = new ArrayList<>();
private List<Integer> clusterIds = new ArrayList<>();
private List<SubunitCluster> clusters;

private Point3d centroid;
Expand All @@ -75,10 +76,7 @@ public QuatSymmetrySubunits(List<SubunitCluster> clusters) {
clusterIds.add(c);
Atom[] atoms = clusters.get(c).getAlignedAtomsSubunit(s);

// Convert atoms to points
Point3d[] points = new Point3d[atoms.length];
for (int i = 0; i < atoms.length; i++)
points[i] = atoms[i].getCoordsAsPoint3d();
Point3d[] points = Calc.atomsToPoints(atoms);

caCoords.add(points);
}
Expand Down