44import java .util .Arrays ;
55import java .util .List ;
66
7- import javax .vecmath .Matrix4d ;
8-
97import org .biojava .nbio .structure .Atom ;
108import org .biojava .nbio .structure .Calc ;
119import org .biojava .nbio .structure .SVDSuperimposer ;
@@ -23,12 +21,12 @@ public class MultipleAlignmentScorer {
2321
2422 //Names for commonly used properties
2523 public static final String PROBABILITY = "Probability" ; //AFPChain conversion
26- public static final String CE_SCORE = "CEscore " ; //AFPChain conversion
24+ public static final String CE_SCORE = "CE-score " ; //AFPChain conversion
2725 public static final String RMSD = "RMSD" ;
28- public static final String AVG_TMSCORE = "Avg-TMscore " ;
29- public static final String CEMC_SCORE = "CEMCscore " ;
26+ public static final String AVGTM_SCORE = "AvgTM-score " ;
27+ public static final String MC_SCORE = "MultipleMC-score " ;
3028 public static final String REF_RMSD = "Ref-RMSD" ;
31- public static final String REF_TMSCORE = "Ref-TMscore " ;
29+ public static final String REFTM_SCORE = "RefTM-score " ;
3230
3331 /**
3432 * Calculates and puts the RMSD and the average TM-Score of the MultipleAlignment.
@@ -49,7 +47,7 @@ public static void calculateScores(MultipleAlignment alignment) throws Structure
4947 for (Atom [] atoms : alignment .getEnsemble ().getAtomArrays ()) {
5048 lengths .add (atoms .length );
5149 }
52- alignment .putScore (AVG_TMSCORE , getAvgTMScore (transformed ,lengths ));
50+ alignment .putScore (AVGTM_SCORE , getAvgTMScore (transformed ,lengths ));
5351 }
5452
5553 /**
@@ -279,45 +277,57 @@ private static double getRefTMScore(List<Atom[]> transformed, List<Integer> leng
279277 }
280278
281279 /**
282- * Calculates the CEMC score, specific for the MultipleAlignment algorithm.
280+ * Calculates the MC score, specific for the MultipleAlignment algorithm.
283281 * The score function is modified from the original CEMC paper, making it
284- * continuous and differentiable.<p>
282+ * continuous and differentiable.
283+ * <p>
284+ * The maximum score of a match is 20, and the penalties for gaps are part of
285+ * the input. The half-score distance, d0, is chosen as in the TM-score.
286+ * <p>
285287 * Complexity: T(n,l) = O(l*n^2), if n=number of structures and l=alignment length.
286288 *
287289 * @param alignment
290+ * @param gapOpen penalty for gap opening (reasonable values are in the range (1.0-20.0)
291+ * @param gapExtension penalty for extending a gap (reasonable values are in the range (0.5-10)
288292 * @return
289293 * @throws StructureException
290294 */
291- public static double getCEMCScore (MultipleAlignment alignment ) throws StructureException {
295+ public static double getMultipleMCScore (MultipleAlignment alignment , double gapOpen , double gapExtension ) throws StructureException {
292296 //Transform Atoms
293297 List <Atom []> transformed = MultipleAlignmentTools .transformAtoms (alignment );
294298 //Calculate d0
295299 int minLen = Integer .MAX_VALUE ;
296300 for (Atom [] atoms : alignment .getEnsemble ().getAtomArrays ())
297301 if (atoms .length < minLen ) minLen = atoms .length ;
298302 double d0 = 1.24 * Math .cbrt ((minLen ) - 15. ) - 1.8 ; //d0 is calculated as in the TM-score
299- return getCEMCScore (transformed , d0 );
303+ return getMultipleMCScore (transformed , d0 , gapOpen , gapExtension );
300304 }
301305
302306 /**
303- * Calculates the CEMC score, specific for the MultipleAlignment algorithm.
307+ * Calculates the MC score, specific for the MultipleAlignment algorithm.
304308 * The score function is modified from the original CEMC paper, making it
305- * continuous and differentiable.<p>
309+ * continuous and differentiable.
310+ * <p>
311+ * The maximum score of a match is 20, and the penalties for gaps are part of
312+ * the input.
313+ * <p>
306314 * Complexity: T(n,l) = O(l*n^2), if n=number of structures and l=alignment length.
307315 *
308316 * @param transformed List of transformed Atom arrays
309- * @param d0 parameter for the distance evaluation
317+ * @param d0 parameter for the half-score distance
318+ * @param gapOpen penalty for gap opening (reasonable values are in the range (1.0-20.0)
319+ * @param gapExtension penalty for extending a gap (reasonable values are in the range (0.5-10)
310320 * @return
311321 * @throws StructureException
312322 */
313- private static double getCEMCScore (List <Atom []> transformed , double d0 ) throws StructureException {
323+ private static double getMultipleMCScore (List <Atom []> transformed , double d0 , double gapOpen , double gapExtension ) throws StructureException {
314324
315325 int size = transformed .size ();
316326 int length = transformed .get (0 ).length ;
317327 Matrix residueDistances = new Matrix (size ,length ,-1 ); //A residue distance is the average distance to all others
318328 double scoreMC = 0.0 ;
319- int gapOpen = 0 ;
320- int gapExtend = 0 ;
329+ int gapsOpen = 0 ;
330+ int gapsExtend = 0 ;
321331
322332 //Calculate the average residue distances
323333 for (int r1 =0 ; r1 <size ; r1 ++){
@@ -326,10 +336,10 @@ private static double getCEMCScore(List<Atom[]> transformed, double d0) throws S
326336 Atom refAtom = transformed .get (r1 )[c ];
327337 //Calculate the gap extension and opening on the fly
328338 if (refAtom == null ) {
329- if (gapped ) gapExtend ++;
339+ if (gapped ) gapsExtend ++;
330340 else {
331341 gapped = true ;
332- gapOpen ++;
342+ gapsOpen ++;
333343 }
334344 continue ;
335345 } else gapped = false ;
@@ -366,6 +376,6 @@ private static double getCEMCScore(List<Atom[]> transformed, double d0) throws S
366376 }
367377 }
368378 //Apply the Gap penalty and return
369- return scoreMC - (gapOpen * 10.0 + gapExtend * 5.0 );
379+ return scoreMC - (gapsOpen * gapOpen + gapsExtend * gapExtension );
370380 }
371381}
0 commit comments