2 import jalview.bin.Jalview
3 import jalview.io.gff.GffConstants;
4 import jalview.workers.AnnotationProviderI
5 import jalview.workers.AlignmentAnnotationFactory
6 import jalview.datamodel.*;
9 * Define something that counts each visible feature type
13 getNames: { visibleFeatures as String[] },
14 getDescriptions: { visibleFeatures as String[] },
15 getMinColour: { [0, 255, 255] as int[] }, // cyan
16 getMaxColour: { [0, 0, 255] as int[] }, // blue
23 ProfilesI a_prof=al.getSequenceConsensusHash();
24 al_width = a_prof.getEndColumn();
25 // jalview.datamodel.Annotation ai[] = new jalview.datamodel.Annotation[al_width];
27 al.getGroups().each({group -> sg_profs << group.getSequenceConsensusHash() });
31 annot = new Annotation[al_width];
32 for (int c=0;c<al_width;c++) {
33 def al_p=a_prof.get(c);
35 def al_ng = al_p.getNonGapped()
36 if (al_p.getCounts()!=null) {
37 al_p = al_p.getCounts().getSymbolCounts();
38 def tot_count=[foo:0];
39 for (int a=al_p.values.length-1;a>-1;a--) {
40 tot_count << [(al_p.symbols[a]):(al_p.values[a])]
44 sg_profs.each({sg_prof ->
45 if (sg_prof!=null) {count = sg_prof.get(c);
46 if ((count!=null) && (count.getCounts()!=null)) {
47 g_size = count.getHeight();
48 count = count.getCounts().getSymbolCounts();
49 for (int a=count.values.length-1;a>-1; a--) {
50 Ip+= (count.values[a]/al_ng) * Math.log((count.values[a]*al_ng)/(g_size*tot_count[(count.symbols[a])]));
55 annot[c]=new Annotation((float) Ip);
61 AlignmentAnnotation annotrow = new AlignmentAnnotation("SDPpred","SDP calculation results for groups using displayed sequence logos for each group",annot);
62 annotrow.setCalcId("SDPPRED");
65 ] as AnnotationProviderI
67 def alf = Jalview.getCurrentAlignFrame()
68 alf.viewport.setShowGroupConsensus(true)
69 alf.viewport.setShowSequenceLogo(true)
70 alf.applyAutoAnnotationSettings.setState(true)
71 alf.alignPanel.updateAnnotation(true)
73 * and register the counter
75 AlignmentAnnotationFactory.newCalculator(sdppredCounter)