return pog;\r
}\r
\r
+ /**\r
+ * pretty print the matrix\r
+ */\r
+ public String toString()\r
+ {\r
+ return outputMatrix(false);\r
+ }\r
+ public String outputMatrix(boolean html)\r
+ {\r
+ StringBuffer sb=new StringBuffer();\r
+ int[] symbols=(type==0) ? ResidueProperties.aaIndex : ResidueProperties.nucleotideIndex;\r
+ int symMax = (type==0) ? ResidueProperties.maxProteinIndex :ResidueProperties.maxNucleotideIndex;\r
+ boolean header=true;\r
+ if (html)\r
+ {\r
+ sb.append("<table>");\r
+ }\r
+ for (char sym='A';sym<='Z';sym++)\r
+ {\r
+ if (symbols[sym]>=0 && symbols[sym]<symMax)\r
+ {\r
+ if (header) {\r
+ sb.append(html ? "<tr><td></td>" : "");\r
+ for (char sym2='A';sym2<='Z';sym2++)\r
+ {\r
+ if (symbols[sym2]>=0 && symbols[sym2]<symMax)\r
+ {\r
+ sb.append((html ? "<td> " : "\t")+sym2 +(html ? " </td>": ""));\r
+ }\r
+ }\r
+ header=false;\r
+ sb.append(html ? "</tr>\n" : "\n");\r
+ } \r
+ if (html)\r
+ {\r
+ sb.append("<tr>");\r
+ }\r
+ sb.append((html ? "<td>" : "")+sym+(html ? "</td>" : ""));\r
+ for (char sym2='A';sym2<='Z';sym2++)\r
+ {\r
+ if (symbols[sym2]>=0 && symbols[sym2]<symMax)\r
+ {\r
+ sb.append((html ? "<td>" : "\t")+matrix[symbols[sym]][symbols[sym2]]+(html ? "</td>" : ""));\r
+ }\r
+ }\r
+ sb.append(html ? "</tr>\n" : "\n");\r
+ }\r
+ }\r
+ if (html)\r
+ {\r
+ sb.append("</table>");\r
+ }\r
+ return sb.toString();\r
+ }\r
}\r
--- /dev/null
+package jalview.schemes;
+
+import java.util.Map;
+
+import org.junit.Test;
+
+
+public class ScoreMatrixPrinter
+{
+ @Test
+ public void printAllMatrices()
+ {
+ for (Map.Entry<String,ScoreMatrix> sm:((Map<String, ScoreMatrix>) ResidueProperties.scoreMatrices).entrySet())
+ {
+ System.out.println("Matrix "+sm.getKey());
+ System.out.println(sm.getValue().toString());
+ }
+ }
+ @Test
+ public void printHTMLMatrices()
+ {
+ for (Map.Entry<String,ScoreMatrix> sm:((Map<String, ScoreMatrix>) ResidueProperties.scoreMatrices).entrySet())
+ {
+ System.out.println("Matrix "+sm.getKey());
+ System.out.println(sm.getValue().outputMatrix(true));
+ }
+ }
+
+}