1 // Requested by David M Garcia (v3)
2 // very messy script to output the scores in annotation rows
3 // for the first sequence in a selection on the topmost alignment
5 // thanks to this thread for cut'n'paste code
6 // http://comments.gmane.org/gmane.comp.lang.groovy.user/53010
8 // Jalview issue at http://issues.jalview.org/browse/JAL-1516
10 import java.awt.datatransfer.StringSelection
11 import static java.awt.Toolkit.*
14 def curviewport = Jalview.getAlignFrames()[Jalview.getAlignFrames().length-1].getViewport();
16 // TSV output by default.
17 // change "\t" to "," to output CSV file
20 if (curviewport.getSelectionGroup()) {
21 // gets selection for topmost alignment
22 def selreg = curviewport.getSelectionGroup();
23 // get aligned positions of first sequence selected
24 def gaps = selreg.getSequenceAt(0).gapMap();
28 curviewport.getAlignment().getAlignmentAnnotation().eachWithIndex{ aa, apos ->
31 gaps.eachWithIndex{col,spos -> if (col>=selreg.getStartRes() && col<=selreg.getEndRes()) {
32 // add sequence for debugging
33 if (count>sseq.length()) {
34 sseq+=sep+selreg.getSequenceAt(0).getCharAt(col); count=sseq.length()+1;
36 // output height of histogram
38 def annot = aa.annotations[col];
40 csv+=aa.annotations[col].value;
42 // Uncomment to output string shown in tooltip
43 // csv+=sep+aa.annotations[col].description;
46 csvfile+=aa.label+csv+"\n"
49 defaultToolkit.systemClipboard.setContents(new StringSelection(selreg.getSequenceAt(0).getName()+sseq+"\n"+csvfile), null)
50 print "Sequence"+sseq+"\n";
52 print "\nAlignment Annotation for first selected sequence copied to the clipboard.\n"
54 "Select a region in the alignment window.";