Skip to content

Commit d851f60

Browse files
committed
More checks and a warning in case no aligned atoms found. Also a few minor fixes
1 parent 8b76e96 commit d851f60

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/symmetry/TestQuatSymmetryDetectorExamples.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.biojava.nbio.structure.cluster.SubunitClusterer;
3333
import org.biojava.nbio.structure.cluster.SubunitClustererMethod;
3434
import org.biojava.nbio.structure.cluster.SubunitClustererParameters;
35+
import org.biojava.nbio.structure.io.FileParsingParameters;
3536
import org.biojava.nbio.structure.symmetry.core.QuatSymmetryDetector;
3637
import org.biojava.nbio.structure.symmetry.core.QuatSymmetryParameters;
3738
import org.biojava.nbio.structure.symmetry.core.QuatSymmetryResults;
@@ -369,6 +370,13 @@ public void testPseudoIdentity95() throws IOException, StructureException {
369370

370371
@Test
371372
public void testSymDetectionWithSubunitClusterByEntityId() throws IOException, StructureException {
373+
AtomCache cache = new AtomCache();
374+
cache.setUseMmtf(false);
375+
cache.setUseMmCif(true);
376+
FileParsingParameters params = new FileParsingParameters();
377+
params.setAlignSeqRes(true);
378+
cache.setFileParsingParams(params);
379+
StructureIO.setAtomCache(cache);
372380
Structure pdb = StructureIO.getStructure("BIO:1SMT:1");
373381

374382
SubunitClustererParameters cp = new SubunitClustererParameters();

biojava-structure/src/main/java/org/biojava/nbio/structure/cluster/SubunitCluster.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,11 @@ public boolean mergeIdenticalByEntityId(SubunitCluster other) {
293293

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

296+
if (seqresIndex == -1) {
297+
// this might mean that FileParsingParameters.setAlignSeqRes() wasn't set to true during parsing
298+
continue;
299+
}
300+
296301
Group otherG = otherChain.getSeqResGroups().get(seqresIndex - 1);
297302

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

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

315324
return true;
@@ -743,7 +752,7 @@ public SubunitClustererMethod getClustererMethod() {
743752
*/
744753
public List<Atom[]> getAlignedAtomsSubunits() {
745754

746-
List<Atom[]> alignedAtoms = Collections.emptyList();
755+
List<Atom[]> alignedAtoms = new ArrayList<>();
747756

748757
// Loop through all subunits and add the aligned positions
749758
for (int s = 0; s < subunits.size(); s++)

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/C2RotationSolver.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
* @author Peter
4040
*/
4141
public class C2RotationSolver implements QuatSymmetrySolver {
42-
private QuatSymmetrySubunits subunits = null;
43-
private QuatSymmetryParameters parameters = null;
42+
private QuatSymmetrySubunits subunits;
43+
private QuatSymmetryParameters parameters;
4444
private Vector3d centroid = new Vector3d();
4545
private Matrix4d centroidInverse = new Matrix4d();
4646

@@ -132,7 +132,7 @@ private void solve() {
132132
}
133133

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

146146
/**
147147
* Adds translational component to rotation matrix
148-
* @param rotTrans
149148
* @param rotation
150149
* @return
151150
*/

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/QuatSymmetrySubunits.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
package org.biojava.nbio.structure.symmetry.core;
2222

2323
import org.biojava.nbio.structure.Atom;
24+
import org.biojava.nbio.structure.Calc;
2425
import org.biojava.nbio.structure.Chain;
2526
import org.biojava.nbio.structure.cluster.SubunitCluster;
2627
import org.biojava.nbio.structure.geometry.CalcPoint;
@@ -34,7 +35,7 @@
3435
import java.util.stream.Collectors;
3536

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

48-
private List<Point3d[]> caCoords = new ArrayList<Point3d[]>();
49-
private List<Point3d> originalCenters = new ArrayList<Point3d>();
50-
private List<Point3d> centers = new ArrayList<Point3d>();
51-
private List<Vector3d> unitVectors = new ArrayList<Vector3d>();
49+
private List<Point3d[]> caCoords = new ArrayList<>();
50+
private List<Point3d> originalCenters = new ArrayList<>();
51+
private List<Point3d> centers = new ArrayList<>();
52+
private List<Vector3d> unitVectors = new ArrayList<>();
5253

53-
private List<Integer> folds = new ArrayList<Integer>();
54-
private List<Integer> clusterIds = new ArrayList<Integer>();
54+
private List<Integer> folds = new ArrayList<>();
55+
private List<Integer> clusterIds = new ArrayList<>();
5556
private List<SubunitCluster> clusters;
5657

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

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

8381
caCoords.add(points);
8482
}

0 commit comments

Comments
 (0)