Skip to content

Commit 3037f70

Browse files
committed
Port the getReasons method from symmetry project
Now included into CeSymmResults.
1 parent 125faf8 commit 3037f70

3 files changed

Lines changed: 68 additions & 5 deletions

File tree

biojava-structure-gui/src/main/java/org/biojava/nbio/structure/symmetry/gui/SymmetryDisplay.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
import org.biojava.nbio.structure.symmetry.jmolScript.JmolSymmetryScriptGenerator;
4444
import org.biojava.nbio.structure.symmetry.jmolScript.JmolSymmetryScriptGeneratorPointGroup;
4545
import org.biojava.nbio.structure.symmetry.utils.SymmetryTools;
46-
import org.jmol.util.Logger;
46+
47+
import org.slf4j.Logger;
48+
import org.slf4j.LoggerFactory;
4749

4850
/**
4951
* Class that provides visualizations methods for symmetry alignments. Call the
@@ -54,6 +56,9 @@
5456
*
5557
*/
5658
public class SymmetryDisplay {
59+
60+
private static final Logger logger = LoggerFactory
61+
.getLogger(SymmetryDisplay.class);
5762

5863
/**
5964
* Displays a multiple alignment of the symmetry repeats.
@@ -115,7 +120,7 @@ public static AbstractAlignmentJmol display(CeSymmResult symmResult)
115120
return jmol;
116121
} else {
117122
// Show the optimal self-alignment
118-
Logger.info("Showing optimal self-alignment");
123+
logger.info("Showing optimal self-alignment");
119124
Atom[] cloned = StructureTools
120125
.cloneAtomArray(symmResult.getAtoms());
121126
AbstractAlignmentJmol jmol = StructureAlignmentDisplay.display(

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/CeSymm.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,12 @@ protected static CeSymmResult align(Atom[] atoms, CESymmParameters params)
300300
atoms);
301301
break;
302302
}
303+
result.setSymmOrder(order);
304+
303305
// REFINEMENT
304306
SymmetryRefiner refiner = null;
305307
switch (params.getRefineMethod()) {
306308
case NOT_REFINED:
307-
result.setSymmOrder(order);
308309
return result;
309310
case SEQUENCE_FUNCTION:
310311
// Does not work for OPEN alignments
@@ -330,7 +331,7 @@ protected static CeSymmResult align(Atom[] atoms, CESymmParameters params)
330331
return result;
331332
}
332333

333-
// STEP4: determine the symmetry axis and its repeat dependencies
334+
// STEP 4: determine the symmetry axis and its repeat dependencies
334335
SymmetryAxes axes = new SymmetryAxes();
335336
int order = result.getMultipleAlignment().size();
336337
Matrix4d axis = result.getMultipleAlignment().getBlockSet(0)

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/CeSymmResult.java

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ public String getSymmGroup() {
213213
else
214214
symmGroup = "R";
215215
}
216-
} else // case asymmetric
216+
} else
217+
// case asymmetric
217218
symmGroup = "C1";
218219
}
219220
return symmGroup;
@@ -255,4 +256,60 @@ public void setStructureId(StructureIdentifier structureId) {
255256
this.structureId = structureId;
256257
}
257258

259+
/**
260+
* Return a String describing the reasons for the CE-Symm final decision
261+
* in this particular result.
262+
*
263+
* @return String decision reason
264+
*/
265+
public String getReason() {
266+
// Cases:
267+
// 1. Asymmetric because insignificant self-alignment (1itb.A_1-100)
268+
double tm = selfAlignment.getTMScore();
269+
if (tm < params.getUnrefinedScoreThreshold()) {
270+
return String.format("Insignificant self-alignment (TM=%.2f)", tm);
271+
}
272+
// 2. Asymmetric because order detector returned 1
273+
if (symmOrder == 1) {
274+
return String.format("Order detector found asymmetric alignment (TM=%.2f)", tm);
275+
}
276+
277+
// Check that the user requested refinement
278+
if (params.getRefineMethod() != RefineMethod.NOT_REFINED) {
279+
// 3. Asymmetric because refinement failed
280+
if (!refined) {
281+
return "Refinement failed";
282+
}
283+
tm = multipleAlignment.getScore(
284+
MultipleAlignmentScorer.AVGTM_SCORE);
285+
// 4. Asymmetric because refinement & optimization were not
286+
// significant
287+
if (!isSignificant()) {
288+
return String.format(
289+
"Refinement was not significant (TM=%.2f)", tm);
290+
}
291+
} else {
292+
// 4. Not refined, but result was not significant
293+
if (!isSignificant()) {
294+
return String
295+
.format("Result was not significant (TM=%.2f)", tm);
296+
}
297+
}
298+
299+
String hierarchical = "";
300+
if (symmLevels > 1) {
301+
hierarchical = String.format("; Contains %d levels of symmetry",
302+
symmLevels);
303+
}
304+
// 5. Symmetric.
305+
// a. Open. Give # repeats (1n0r.A)
306+
if (type == SymmetryType.OPEN) {
307+
return String.format("Contains %d open repeats (TM=%.2f)%s",
308+
getSymmOrder(), tm, hierarchical);
309+
}
310+
// b. Closed, non-hierarchical (1itb.A)
311+
// c. Closed, heirarchical (4gcr)
312+
return String.format("Significant (TM=%.2f)%s", tm, hierarchical);
313+
}
314+
258315
}

0 commit comments

Comments
 (0)