Merge branch 'develop' into features/JAL-2393customMatrices
[jalview.git] / test / jalview / analysis / scoremodels / ScoreModelsTest.java
index c5c8673..f63843d 100644 (file)
@@ -60,4 +60,51 @@ public class ScoreModelsTest
     assertFalse(sm instanceof PairwiseDistanceModel);
     assertEquals(sm.getName(), "PID");
   }
+
+  /**
+   * 'Test' that prints out score matrices in tab-delimited format. This test is
+   * intentionally not assigned to any group so would not be run as part of a
+   * suite. It makes no assertions and is just provided as a utility method for
+   * printing out matrices. Relocated here from ScoreMatrixPrinter.
+   */
+  @Test
+  public void printAllMatrices_tabDelimited()
+  {
+    printAllMatrices(false);
+  }
+
+  /**
+   * 'Test' that prints out score matrices in html format. This test is
+   * intentionally not assigned to any group so would not be run as part of a
+   * suite. It makes no assertions and is just provided as a utility method for
+   * printing out matrices. Relocated here from ScoreMatrixPrinter.
+   */
+  @Test
+  public void printAllMatrices_asHtml()
+  {
+    printAllMatrices(true);
+  }
+
+  /**
+   * Print all registered ScoreMatrix as plain or html tables
+   * 
+   * @param asHtml
+   */
+  protected void printAllMatrices(boolean asHtml)
+  {
+    for (DistanceModelI dm : ScoreModels.getInstance().getModels())
+    {
+      if (dm instanceof PairwiseDistanceModel)
+      {
+        PairwiseScoreModelI psm = ((PairwiseDistanceModel) dm)
+                .getScoreModel();
+        if (psm instanceof ScoreMatrix)
+        {
+          ScoreMatrix sm = (ScoreMatrix) psm;
+          System.out.println("ScoreMatrix " + sm.getName());
+          System.out.println(sm.outputMatrix(asHtml));
+        }
+      }
+    }
+  }
 }