From 3684934fd25c4941bd2d6ec8bc9dc7d760979f4e Mon Sep 17 00:00:00 2001 From: James Procter Date: Fri, 10 Feb 2023 15:19:06 +0000 Subject: [PATCH] JAL-840 generate fragments of clustal.html documentation via ClustalxColurSchemeTest.testDocString() --- src/jalview/schemes/ClustalxColourScheme.java | 61 ++++++++++++++++++++ test/jalview/schemes/ClustalxColourSchemeTest.java | 8 +++ 2 files changed, 69 insertions(+) diff --git a/src/jalview/schemes/ClustalxColourScheme.java b/src/jalview/schemes/ClustalxColourScheme.java index 5a2d5dc..04097a8 100755 --- a/src/jalview/schemes/ClustalxColourScheme.java +++ b/src/jalview/schemes/ClustalxColourScheme.java @@ -21,6 +21,7 @@ package jalview.schemes; import java.awt.Color; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -28,6 +29,7 @@ import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; +import jalview.util.ColorUtils; import jalview.util.Comparison; public class ClustalxColourScheme extends ResidueColourScheme @@ -362,4 +364,63 @@ public class ClustalxColourScheme extends ResidueColourScheme { return false; } + public String toRuleRep() + { + makeColours(); + HashMap cols=new HashMap(); + for (String res:ResidueProperties.aa) { + StringBuilder sb = new StringBuilder(); + + int rnum=ResidueProperties.aaIndex[res.charAt(0)]; + if (rnum<0 || rnum>=residueColour.length) + { + continue; + } + + ConsensusColour cc = residueColour[rnum]; + if (cc==null) + { + continue; + } + //sb.append("Residue "+res+" ("+rnum+")"); + //sb.append("\t"); + sb.append(cc.c.toString()); + double f=0; + sb.append("\t"); + for (Consensus cons: cc.cons) { + if (cons.threshold==0 || f!=cons.threshold) + { + if (f!=0) + { + + sb.append("}, {"); + } else { + sb.append("{"); + } + sb.append(cons.threshold); + sb.append(","); + f=cons.threshold; + } else { + sb.append(","); + } + sb.append(cons.maskstr); + } + sb.append("}"); + String clxrep=sb.toString(); + String xres = cols.get(clxrep); + if (xres==null) { xres = "";} + xres+=res; + cols.put(clxrep, xres); + } + StringBuilder sb = new StringBuilder(); + for (String clxrep:cols.keySet()) + { + sb.append(cols.get(clxrep)); + sb.append("\t"); + sb.append(clxrep); + sb.append("\n"); + + } + return sb.toString(); + } } diff --git a/test/jalview/schemes/ClustalxColourSchemeTest.java b/test/jalview/schemes/ClustalxColourSchemeTest.java index 6731465..d476d6e 100644 --- a/test/jalview/schemes/ClustalxColourSchemeTest.java +++ b/test/jalview/schemes/ClustalxColourSchemeTest.java @@ -151,4 +151,12 @@ public class ClustalxColourSchemeTest // viewport // assertEquals(cs.findColour('C', 0, al.getSequenceAt(0)), clustalPink); } + @Test + public void testDocString() + { + /* verify we have some sort of useful output */ + ClustalxColourScheme x = new ClustalxColourScheme(); + String out = x.toRuleRep(); + System.out.print(out); + } } -- 1.7.10.2