X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FScoreMatrix.java;h=895ee86c5f56684a7446d88240610889dfb319a3;hb=213bb03dc91ef5af6aacbfc641d82420d0bdbb5a;hp=f5d30a940e06b2135cf1af1b81d503617456c8bb;hpb=3f406564745090b30c2d7cba7342547d7ddd7965;p=jalview.git diff --git a/src/jalview/schemes/ScoreMatrix.java b/src/jalview/schemes/ScoreMatrix.java index f5d30a9..895ee86 100644 --- a/src/jalview/schemes/ScoreMatrix.java +++ b/src/jalview/schemes/ScoreMatrix.java @@ -83,4 +83,58 @@ public class ScoreMatrix return pog; } + /** + * pretty print the matrix + */ + public String toString() + { + return outputMatrix(false); + } + public String outputMatrix(boolean html) + { + StringBuffer sb=new StringBuffer(); + int[] symbols=(type==0) ? ResidueProperties.aaIndex : ResidueProperties.nucleotideIndex; + int symMax = (type==0) ? ResidueProperties.maxProteinIndex :ResidueProperties.maxNucleotideIndex; + boolean header=true; + if (html) + { + sb.append(""); + } + for (char sym='A';sym<='Z';sym++) + { + if (symbols[sym]>=0 && symbols[sym]" : ""); + for (char sym2='A';sym2<='Z';sym2++) + { + if (symbols[sym2]>=0 && symbols[sym2] " : "\t")+sym2 +(html ? " ": "")); + } + } + header=false; + sb.append(html ? "\n" : "\n"); + } + if (html) + { + sb.append(""); + } + sb.append((html ? "" : "")); + for (char sym2='A';sym2<='Z';sym2++) + { + if (symbols[sym2]>=0 && symbols[sym2]" : "\t")+matrix[symbols[sym]][symbols[sym2]]+(html ? "" : "")); + } + } + sb.append(html ? "\n" : "\n"); + } + } + if (html) + { + sb.append("
" : "")+sym+(html ? "
"); + } + return sb.toString(); + } }