Skip to content

Commit 14f94a7

Browse files
authored
Merge pull request biojava#710 from josemduarte/issue708
Fixes for quaternary symmetry code
2 parents 96c6816 + 730d6b4 commit 14f94a7

8 files changed

Lines changed: 64 additions & 34 deletions

File tree

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,13 @@ public void testDihedral() throws IOException, StructureException {
8787
// D3 symmetry non pseudosymmetric
8888
assertEquals("D3", symmetry.getSymmetry());
8989
assertEquals("A6B6", symmetry.getStoichiometry());
90+
assertFalse(symmetry.isPseudoStoichiometric());
91+
9092

9193
}
9294

9395
/**
9496
* Hemoglobin has both symmetry and pseudosymmetry: 4HHB
95-
* TODO pseudosymmetry in hemoglobin fails
9697
*
9798
* @throws StructureException
9899
* @throws IOException
@@ -121,6 +122,7 @@ public void testPseudosymmetry() throws IOException, StructureException {
121122
// D2 pseudo-symmetry
122123
assertEquals("D2", symmetry.getSymmetry());
123124
assertEquals("A4", symmetry.getStoichiometry());
125+
assertTrue(symmetry.isPseudoStoichiometric());
124126
}
125127

126128
/**
@@ -232,4 +234,27 @@ public void testHelicalLocal() throws IOException, StructureException {
232234
assertEquals("A5", results.get(0).getStoichiometry());
233235

234236
}
237+
238+
/**
239+
* A structure with very similar entities (clustering at 95% seq id): 4DZ8
240+
* @throws IOException
241+
* @throws StructureException
242+
*/
243+
@Test
244+
public void testPseudoIdentity95() throws IOException, StructureException {
245+
Structure pdb = StructureIO.getStructure("BIO:4DZ8:1");
246+
247+
SubunitClustererParameters cp = new SubunitClustererParameters();
248+
cp.setClustererMethod(SubunitClustererMethod.IDENTITY);
249+
QuatSymmetryParameters symmParams = new QuatSymmetryParameters();
250+
251+
QuatSymmetryResults symmetry = QuatSymmetryDetector.calcGlobalSymmetry(
252+
pdb, symmParams, cp);
253+
254+
assertEquals("C2", symmetry.getSymmetry());
255+
assertEquals("A2", symmetry.getStoichiometry());
256+
assertFalse(symmetry.isPseudoStoichiometric());
257+
assertEquals(SubunitClustererMethod.IDENTITY, symmetry.getSubunitClusters().get(0).getClustererMethod());
258+
259+
}
235260
}

‎biojava-structure-gui/src/main/java/demo/DemoQuatSymmetryJmol.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private static void showResults(Structure s, String name,
9494
String title = name + ": " + results.getStoichiometry()
9595
+ ", " + results.getSymmetry();
9696

97-
if (results.isPseudosymmetric())
97+
if (results.isPseudoStoichiometric())
9898
title += ", pseudosymmetric";
9999

100100
if (results.isLocal())

‎biojava-structure/src/main/java/demo/DemoSymmetry.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private static void findQuatSym(Structure bioAssembly) throws StructureException
4545

4646

4747

48-
System.out.println(globalResults.getSymmetry() + (globalResults.isPseudosymmetric()?"(pseudo)":""));
48+
System.out.println(globalResults.getSymmetry() + (globalResults.isPseudoStoichiometric()?"(pseudo)":""));
4949

5050
System.out.println("There are "+globalResults.getSubunitClusters().size()+" subunit clusters");
5151
int i = 1;
@@ -68,7 +68,7 @@ private static void findQuatSym(Structure bioAssembly) throws StructureException
6868

6969

7070

71-
System.out.println(globalResults.getSymmetry() + (globalResults.isPseudosymmetric()?"(pseudo)":""));
71+
System.out.println(globalResults.getSymmetry() + (globalResults.isPseudoStoichiometric()?"(pseudo)":""));
7272

7373
System.out.println("There are "+globalResults.getSubunitClusters().size()+" subunit clusters");
7474
i = 1;

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,29 @@ public boolean mergeIdentical(SubunitCluster other) {
143143
return true;
144144
}
145145

146+
/**
147+
* Merges the other SubunitCluster into this one if their representatives
148+
* sequences are more than 0.95 identical on 0.95 of coverage.
149+
* <p>
150+
* The sequence alignment is performed using Smith Waterman, default linear
151+
* {@link SimpleGapPenalty} and BLOSUM62 as scoring matrix.
152+
*
153+
* @param other
154+
* SubunitCluster
155+
* @return true if the SubunitClusters were merged, false otherwise
156+
* @throws CompoundNotFoundException
157+
*/
158+
public boolean mergeIdentity95(SubunitCluster other) throws CompoundNotFoundException {
159+
boolean merged = mergeSequence(other, 0.95, 0.95,
160+
PairwiseSequenceAlignerType.LOCAL, new SimpleGapPenalty(),
161+
SubstitutionMatrixHelper.getBlosum62());
162+
163+
if (merged) {
164+
this.method = SubunitClustererMethod.IDENTITY;
165+
}
166+
return merged;
167+
}
168+
146169
/**
147170
* Merges the other SubunitCluster into this one if their representatives
148171
* sequences are similar (higher sequence identity and coverage than the

‎biojava-structure/src/main/java/org/biojava/nbio/structure/cluster/SubunitClusterUtils.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static String getStoichiometryString(List<SubunitCluster> clusters) {
5656

5757
/**
5858
* A pseudostoichiometric {@link SubunitCluster} was obtained using the
59-
* {@link SubunitClustererMethod#STRUCTURE} similarity.
59+
* {@link SubunitClustererMethod#STRUCTURE} or {@link SubunitClustererMethod#SEQUENCE} similarity.
6060
*
6161
* @param clusters
6262
* @return true if any of the clusters is pseudostoichiometric, false
@@ -65,7 +65,8 @@ public static String getStoichiometryString(List<SubunitCluster> clusters) {
6565
public static boolean isPseudoStoichiometric(List<SubunitCluster> clusters) {
6666

6767
for (SubunitCluster c : clusters) {
68-
if (c.getClustererMethod() == SubunitClustererMethod.STRUCTURE)
68+
if (c.getClustererMethod() == SubunitClustererMethod.STRUCTURE ||
69+
c.getClustererMethod() == SubunitClustererMethod.SEQUENCE)
6970
return true;
7071
}
7172
return false;

‎biojava-structure/src/main/java/org/biojava/nbio/structure/cluster/SubunitClusterer.java‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,22 @@ public static List<SubunitCluster> cluster(List<Subunit> subunits,
6868
for (Subunit s : subunits)
6969
clusters.add(new SubunitCluster(s));
7070

71-
// Now merge clusters by IDENTITY
71+
// Now merge clusters by 95% IDENTITY
7272
for (int c1 = 0; c1 < clusters.size(); c1++) {
7373
for (int c2 = clusters.size() - 1; c2 > c1; c2--) {
74-
if (clusters.get(c1).mergeIdentical(clusters.get(c2)))
75-
clusters.remove(c2);
74+
try {
75+
if (clusters.get(c1).mergeIdentity95(clusters.get(c2)))
76+
clusters.remove(c2);
77+
} catch (CompoundNotFoundException e) {
78+
logger.warn("Could not merge by Identity95. {}",
79+
e.getMessage());
80+
}
7681
}
7782
}
7883

7984
if (params.getClustererMethod() == SubunitClustererMethod.IDENTITY)
8085
return clusters;
86+
8187

8288
// Now merge clusters by SEQUENCE similarity
8389
for (int c1 = 0; c1 < clusters.size(); c1++) {

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,6 @@ private static QuatSymmetryResults calcQuatSymmetry(
282282

283283
String symmetry = results.getSymmetry();
284284

285-
// asymmetric structures cannot be pseudosymmetric
286-
if (symmetry.equals("C1"))
287-
results.setPseudosymmetric(false);
288-
289285
// Check structures with Cn symmetry (n = 1, ...) for helical symmetry
290286
if (symmetry.startsWith("C")) {
291287
HelixSolver hc = new HelixSolver(subunits,

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public class QuatSymmetryResults {
5656
private SymmetryPerceptionMethod method;
5757
private RotationGroup rotationGroup;
5858
private HelixLayers helixLayers;
59-
private boolean pseudosymmetric = false;
6059

6160
// TODO we should unify rotational and roto-translational results
6261

@@ -212,26 +211,6 @@ void setLocal(boolean local) {
212211
this.local = local;
213212
}
214213

215-
/**
216-
* A symmetry result is pseudosymmetric when using pseudostoichiometry
217-
* extended the symmetry over the
218-
*
219-
* @return true is pseudosymmetric, false otherwise
220-
*/
221-
public boolean isPseudosymmetric() {
222-
return pseudosymmetric;
223-
}
224-
225-
/**
226-
* A symmetry result is pseudosymmetric when using pseudostoichiometry
227-
* extended the symmetry over the
228-
*
229-
* @param pseudosymmetric true if pseudosymmetric, false otherwise
230-
*/
231-
public void setPseudosymmetric(boolean pseudosymmetric) {
232-
this.pseudosymmetric = pseudosymmetric;
233-
}
234-
235214
public Structure getStructure() {
236215
return structure;
237216
}

0 commit comments

Comments
 (0)