2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 // Requested by David M Garcia (v3)
22 // very messy script to output the scores in annotation rows
23 // for the first sequence in a selection on the topmost alignment
25 // thanks to this thread for cut'n'paste code
26 // http://comments.gmane.org/gmane.comp.lang.groovy.user/53010
28 // Jalview issue at http://issues.jalview.org/browse/JAL-1516
30 import java.awt.datatransfer.StringSelection
31 import static java.awt.Toolkit.*
34 def curviewport = Jalview.getAlignFrames()[Jalview.getAlignFrames().length-1].getViewport();
36 // TSV output by default.
37 // change "\t" to "," to output CSV file
40 if (curviewport.getSelectionGroup()) {
41 // gets selection for topmost alignment
42 def selreg = curviewport.getSelectionGroup();
43 // get aligned positions of first sequence selected
44 def gaps = selreg.getSequenceAt(0).gapMap();
48 curviewport.getAlignment().getAlignmentAnnotation().eachWithIndex{ aa, apos ->
51 gaps.eachWithIndex{col,spos -> if (col>=selreg.getStartRes() && col<=selreg.getEndRes()) {
52 // add sequence for debugging
53 if (count>sseq.length()) {
54 sseq+=sep+selreg.getSequenceAt(0).getCharAt(col); count=sseq.length()+1;
56 // output height of histogram
58 def annot = aa.annotations[col];
60 csv+=aa.annotations[col].value;
62 // Uncomment to output string shown in tooltip
63 // csv+=sep+aa.annotations[col].description;
66 csvfile+=aa.label+csv+"\n"
69 defaultToolkit.systemClipboard.setContents(new StringSelection(selreg.getSequenceAt(0).getName()+sseq+"\n"+csvfile), null)
70 print "Sequence"+sseq+"\n";
72 print "\nAlignment Annotation for first selected sequence copied to the clipboard.\n"
74 "Select a region in the alignment window.";