Skip to content

Commit 640b2ac

Browse files
committed
Create method to update symmetry scores
Remove repeated code and move it to a single method
1 parent d76c8ed commit 640b2ac

3 files changed

Lines changed: 43 additions & 27 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static AFPChain refineSymmetry(AFPChain afpChain, Atom[] ca1, Atom[] ca2,
9191
return refinedAFP;
9292
} catch (IndexOutOfBoundsException e){
9393
// This Exception is thrown when the refined alignment is not consistent
94-
throw new RefinerFailedException("Refiner failure", e);
94+
throw new RefinerFailedException("Refiner failure: non-consistent result", e);
9595
}
9696
}
9797

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private void initialize() throws StructureException, RefinerFailedException {
165165
}
166166
checkGaps();
167167

168-
// Set the MC score and RMSD of the initial state (seed alignment)
168+
// Set the MC score of the initial state (seed alignment)
169169
updateMultipleAlignment();
170170
mcScore = MultipleAlignmentScorer.getMCScore(msa, Gopen, Gextend,
171171
dCutoff);
@@ -280,17 +280,11 @@ public MultipleAlignment optimize() throws StructureException,
280280

281281
i++;
282282
}
283-
// Superimpose and calculate scores
283+
// Superimpose and calculate final scores
284284
updateMultipleAlignment();
285285
mcScore = MultipleAlignmentScorer.getMCScore(msa, Gopen, Gextend,
286286
dCutoff);
287-
double tmScore = MultipleAlignmentScorer.getAvgTMScore(msa) * order;
288-
double rmsd = MultipleAlignmentScorer.getRMSD(msa);
289-
290-
// Set the scores
291287
msa.putScore(MultipleAlignmentScorer.MC_SCORE, mcScore);
292-
msa.putScore(MultipleAlignmentScorer.AVGTM_SCORE, tmScore);
293-
msa.putScore(MultipleAlignmentScorer.RMSD, rmsd);
294288

295289
// Save the history to the results folder of the symmetry project
296290
if (history) {

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/utils/SymmetryTools.java

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
* <p>
7373
* Methods include: blank out regions of DP Matrix, build symmetry graphs, get
7474
* rotation symmetry angles, split repeats in quaternary structure chains,
75-
* convert between symmetry formats (full, repeats, rotations), determine if
76-
* two symmetry axes are equivalent, get groups from representative Atoms.
75+
* convert between symmetry formats (full, repeats, rotations), determine if two
76+
* symmetry axes are equivalent, get groups from representative Atoms.
7777
*
7878
* @author Spencer Bliven
7979
* @author Aleix Lafita
@@ -517,7 +517,7 @@ public static Structure getQuaternaryStructure(CeSymmResult symmetry) {
517517

518518
// Create new structure containing the repeat atoms
519519
for (int i = 0; i < symmetry.getSymmOrder(); i++) {
520-
520+
521521
Chain newCh = new ChainImpl();
522522

523523
Block align = symmetry.getMultipleAlignment().getBlock(0);
@@ -526,16 +526,16 @@ public static Structure getQuaternaryStructure(CeSymmResult symmetry) {
526526
int res1 = align.getStartResidue(i);
527527
int res2 = align.getFinalResidue(i);
528528

529-
Atom[] repeat = Arrays.copyOfRange(atoms, res1, res2+1);
530-
529+
Atom[] repeat = Arrays.copyOfRange(atoms, res1, res2 + 1);
530+
531531
for (int k = 0; k < repeat.length; k++) {
532532
Group g = (Group) repeat[k].getGroup().clone();
533533
newCh.addGroup(g);
534534
}
535535
newCh.setChainID(chainID + "");
536536
chainID++;
537537
symm.addChain(newCh);
538-
538+
539539
}
540540
return symm;
541541
}
@@ -629,8 +629,8 @@ public static MultipleAlignment toRepeatsAlignment(CeSymmResult result)
629629
/**
630630
* Converts a refined symmetry AFPChain alignment into the standard
631631
* representation of symmetry in a MultipleAlignment, that contains the
632-
* entire Atom array of the strcuture and the symmetric repeats are
633-
* orgaized in different rows in a single Block.
632+
* entire Atom array of the strcuture and the symmetric repeats are orgaized
633+
* in different rows in a single Block.
634634
*
635635
* @param symm
636636
* AFPChain created with a symmetry algorithm and refined
@@ -678,7 +678,7 @@ public static MultipleAlignment fromAFP(AFPChain symm, Atom[] atoms)
678678

679679
CoreSuperimposer imposer = new CoreSuperimposer();
680680
imposer.superimpose(result);
681-
MultipleAlignmentScorer.calculateScores(result);
681+
updateSymmetryScores(result);
682682

683683
return result;
684684
}
@@ -737,8 +737,8 @@ public static QuatSymmetryResults getQuaternarySymmetry(CeSymmResult result)
737737
// Obtain the clusters of aligned Atoms and repeat variables
738738
MultipleAlignment repeats = SymmetryTools.toRepeatsAlignment(result);
739739
List<Atom[]> alignedCA = repeats.getAtomArrays();
740-
List<Integer> corePos = MultipleAlignmentTools
741-
.getCorePositions(repeats.getBlock(0));
740+
List<Integer> corePos = MultipleAlignmentTools.getCorePositions(repeats
741+
.getBlock(0));
742742

743743
List<Point3d[]> caCoords = new ArrayList<Point3d[]>();
744744
List<Integer> folds = new ArrayList<Integer>();
@@ -884,15 +884,16 @@ public static List<Group> getGroups(Atom[] rAtoms) {
884884
}
885885
return groups;
886886
}
887-
887+
888888
/**
889889
* Calculates the set of symmetry operation Matrices (transformations) of
890890
* the new alignment, based on the symmetry relations in the SymmetryAxes
891-
* object. It sets the transformations to the input MultipleAlignment and
892-
* SymmetryAxes objects.
891+
* object. It sets the transformations to the input MultipleAlignment and
892+
* SymmetryAxes objects. If the SymmetryAxes object is null, the
893+
* superposition of the repeats is done without symmetry constraints.
893894
* <p>
894-
* If the SymmetryAxes object is null, the superposition of the repeats is
895-
* done without symmetry constraints.
895+
* This method also sets the scores (RMSD and TM-score) after the new
896+
* superposition has been updated.
896897
*
897898
* @param axes
898899
* SymmetryAxes object. It will be modified.
@@ -941,7 +942,7 @@ public static void updateSymmetryTransformation(SymmetryAxes axes,
941942
axis = svd.getTransformation();
942943
axes.updateAxis(t, axis);
943944
}
944-
945+
945946
// Get the transformations from the SymmetryAxes
946947
List<Matrix4d> transformations = new ArrayList<Matrix4d>();
947948
for (int su = 0; su < msa.size(); su++) {
@@ -953,6 +954,27 @@ public static void updateSymmetryTransformation(SymmetryAxes axes,
953954
MultipleSuperimposer imposer = new CoreSuperimposer();
954955
imposer.superimpose(msa);
955956
}
957+
updateSymmetryScores(msa);
958+
}
959+
960+
/**
961+
* Update the scores (TM-score and RMSD) of a symmetry multiple alignment.
962+
* This method does not redo the superposition of the alignment.
963+
*
964+
* @param symm
965+
* Symmetry Multiple Alignment of Repeats
966+
* @throws StructureException
967+
*/
968+
public static void updateSymmetryScores(MultipleAlignment symm)
969+
throws StructureException {
970+
971+
// Multiply by the order of symmetry to normalize score
972+
double tmScore = MultipleAlignmentScorer.getAvgTMScore(symm)
973+
* symm.size();
974+
double rmsd = MultipleAlignmentScorer.getRMSD(symm);
975+
976+
symm.putScore(MultipleAlignmentScorer.AVGTM_SCORE, tmScore);
977+
symm.putScore(MultipleAlignmentScorer.RMSD, rmsd);
956978
}
957-
979+
958980
}

0 commit comments

Comments
 (0)