2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
\r
3 * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
25 import jalview.analysis.*;
\r
26 import jalview.datamodel.*;
\r
27 import jalview.schemes.*;
\r
29 public class AnnotationFile
\r
31 StringBuffer text = new StringBuffer("JALVIEW_ANNOTATION\n"
\r
32 + "# Created: " + new java.util.Date() + "\n\n");
\r
35 * convenience method for pre-2.4 feature files which have no view, hidden
\r
36 * columns or hidden row keywords.
\r
38 * @param annotations
\r
41 * @return feature file as a string.
\r
43 public String printAnnotations(AlignmentAnnotation[] annotations,
\r
44 Vector groups, Hashtable properties)
\r
46 return printAnnotations(annotations, groups, properties, null);
\r
51 * hold all the information about a particular view definition read from or
\r
52 * written out in an annotations file.
\r
54 public class ViewDef
\r
56 public String viewname;
\r
58 public HiddenSequences hidseqs;
\r
60 public ColumnSelection hiddencols;
\r
62 public Vector visibleGroups;
\r
63 public Hashtable hiddenRepSeqs;
\r
65 public ViewDef(String viewname, HiddenSequences hidseqs,
\r
66 ColumnSelection hiddencols, Hashtable hiddenRepSeqs)
\r
68 this.viewname = viewname;
\r
69 this.hidseqs = hidseqs;
\r
70 this.hiddencols = hiddencols;
\r
71 this.hiddenRepSeqs = hiddenRepSeqs;
\r
75 public String printAnnotations(AlignmentAnnotation[] annotations,
\r
76 Vector groups, Hashtable properties, ViewDef[] views)
\r
78 if (annotations != null)
\r
80 boolean oneColour = true;
\r
81 AlignmentAnnotation row;
\r
83 SequenceI refSeq = null;
\r
85 StringBuffer colours = new StringBuffer();
\r
86 StringBuffer graphLine = new StringBuffer();
\r
88 Hashtable graphGroup = new Hashtable();
\r
90 java.awt.Color color;
\r
92 for (int i = 0; i < annotations.length; i++)
\r
94 row = annotations[i];
\r
96 if (!row.visible && !row.hasScore())
\r
104 if (row.sequenceRef == null)
\r
106 if (refSeq != null)
\r
108 text.append("\nSEQUENCE_REF\tALIGNMENT\n");
\r
114 else if (refSeq == null || refSeq != row.sequenceRef)
\r
116 refSeq = row.sequenceRef;
\r
117 text.append("\nSEQUENCE_REF\t" + refSeq.getName() + "\n");
\r
120 if (row.graph == AlignmentAnnotation.NO_GRAPH)
\r
122 text.append("NO_GRAPH\t");
\r
126 if (row.graph == AlignmentAnnotation.BAR_GRAPH)
\r
128 text.append("BAR_GRAPH\t");
\r
130 else if (row.graph == AlignmentAnnotation.LINE_GRAPH)
\r
132 text.append("LINE_GRAPH\t");
\r
135 if (row.getThreshold() != null)
\r
138 .append("GRAPHLINE\t"
\r
141 + row.getThreshold().value
\r
143 + row.getThreshold().label
\r
145 + jalview.util.Format.getHexString(row
\r
146 .getThreshold().colour) + "\n");
\r
149 if (row.graphGroup > -1)
\r
151 String key = String.valueOf(row.graphGroup);
\r
152 if (graphGroup.containsKey(key))
\r
154 graphGroup.put(key, graphGroup.get(key) + "\t" + row.label);
\r
158 graphGroup.put(key, row.label);
\r
163 text.append(row.label + "\t");
\r
164 if (row.description != null)
\r
166 text.append(row.description + "\t");
\r
169 for (int j = 0; row.annotations != null
\r
170 && j < row.annotations.length; j++)
\r
173 && jalview.util.Comparison.isGap(refSeq.getCharAt(j)))
\r
178 if (row.annotations[j] != null)
\r
181 if (row.annotations[j].secondaryStructure != ' ')
\r
183 text.append(comma + row.annotations[j].secondaryStructure);
\r
186 if (row.annotations[j].displayCharacter != null
\r
187 && row.annotations[j].displayCharacter.length() > 0
\r
188 && !row.annotations[j].displayCharacter.equals(" "))
\r
190 text.append(comma + row.annotations[j].displayCharacter);
\r
194 if (row.annotations[j] != null)
\r
196 if (color != null && !color.equals(row.annotations[j].colour))
\r
201 color = row.annotations[j].colour;
\r
202 if (row.annotations[j].value != 0f
\r
203 && row.annotations[j].value != Float.NaN)
\r
205 text.append(comma + row.annotations[j].value);
\r
209 if (row.annotations[j].colour != null
\r
210 && row.annotations[j].colour != java.awt.Color.black)
\r
214 + jalview.util.Format
\r
215 .getHexString(row.annotations[j].colour)
\r
222 if (row.hasScore())
\r
223 text.append("\t" + row.score);
\r
227 if (color != null && color != java.awt.Color.black && oneColour)
\r
229 colours.append("COLOUR\t" + row.label + "\t"
\r
230 + jalview.util.Format.getHexString(color) + "\n");
\r
237 text.append(colours.toString());
\r
238 text.append(graphLine.toString());
\r
239 if (graphGroup.size() > 0)
\r
241 text.append("COMBINE\t");
\r
242 Enumeration en = graphGroup.elements();
\r
243 while (en.hasMoreElements())
\r
245 text.append(en.nextElement() + "\n");
\r
250 if (groups != null)
\r
252 printGroups(groups);
\r
255 if (properties != null)
\r
257 text.append("\n\nALIGNMENT");
\r
258 Enumeration en = properties.keys();
\r
259 while (en.hasMoreElements())
\r
261 String key = en.nextElement().toString();
\r
262 text.append("\t" + key + "=" + properties.get(key));
\r
264 // TODO: output alignment visualization settings here if required
\r
268 return text.toString();
\r
271 public void printGroups(Vector sequenceGroups)
\r
274 SequenceI seqrep=null;
\r
275 for (int i = 0; i < sequenceGroups.size(); i++)
\r
277 sg = (SequenceGroup) sequenceGroups.elementAt(i);
\r
278 if (!sg.hasSeqrep())
\r
280 text.append("SEQUENCE_GROUP\t" + sg.getName() + "\t"
\r
281 + (sg.getStartRes() + 1) + "\t" + (sg.getEndRes() + 1) + "\t"
\r
285 seqrep = sg.getSeqrep();
\r
286 text.append("SEQUENCE_REF\t"+seqrep.getName()+"\n");
\r
287 text.append("SEQUENCE_GROUP\t" + sg.getName() + "\t"
\r
288 + (seqrep.findPosition(sg.getStartRes())) + "\t" + (seqrep.findPosition(sg.getEndRes())) + "\t"
\r
291 for (int s = 0; s < sg.getSize(); s++)
\r
293 text.append(sg.getSequenceAt(s).getName() + "\t");
\r
296 text.append("\nPROPERTIES\t" + sg.getName() + "\t");
\r
298 if (sg.getDescription() != null)
\r
300 text.append("description=" + sg.getDescription() + "\t");
\r
304 text.append("colour=" + ColourSchemeProperty.getColourName(sg.cs)
\r
306 if (sg.cs.getThreshold() != 0)
\r
308 text.append("pidThreshold=" + sg.cs.getThreshold());
\r
310 if (sg.cs.conservationApplied())
\r
312 text.append("consThreshold=" + sg.cs.getConservationInc() + "\t");
\r
315 text.append("outlineColour="
\r
316 + jalview.util.Format.getHexString(sg.getOutlineColour())
\r
319 text.append("displayBoxes=" + sg.getDisplayBoxes() + "\t");
\r
320 text.append("displayText=" + sg.getDisplayText() + "\t");
\r
321 text.append("colourText=" + sg.getColourText() + "\t");
\r
322 text.append("showUnconserved="+sg.getShowunconserved()+"\t");
\r
323 if (sg.textColour != java.awt.Color.black)
\r
325 text.append("textCol1="
\r
326 + jalview.util.Format.getHexString(sg.textColour) + "\t");
\r
328 if (sg.textColour2 != java.awt.Color.white)
\r
330 text.append("textCol2="
\r
331 + jalview.util.Format.getHexString(sg.textColour2) + "\t");
\r
333 if (sg.thresholdTextColour != 0)
\r
335 text.append("textColThreshold=" + sg.thresholdTextColour+"\t");
\r
337 if (sg.idColour != null)
\r
339 text.append("idColour="
\r
340 + jalview.util.Format.getHexString(sg.idColour) + "\t");
\r
342 if (sg.isHidereps())
\r
344 text.append("hide=true\t");
\r
346 if (sg.isHideCols())
\r
348 text.append("hidecols=true\t");
\r
352 // terminate the last line and clear the sequence ref for the group
\r
353 text.append("\nSEQUENCE_REF");
\r
355 text.append("\n\n");
\r
360 SequenceI refSeq = null;
\r
362 String refSeqId = null;
\r
364 public boolean readAnnotationFile(AlignmentI al, String file,
\r
369 BufferedReader in = null;
\r
370 if (protocol.equals(AppletFormatAdapter.FILE))
\r
372 in = new BufferedReader(new FileReader(file));
\r
374 else if (protocol.equals(AppletFormatAdapter.URL))
\r
376 URL url = new URL(file);
\r
377 in = new BufferedReader(new InputStreamReader(url.openStream()));
\r
379 else if (protocol.equals(AppletFormatAdapter.PASTE))
\r
381 in = new BufferedReader(new StringReader(file));
\r
383 else if (protocol.equals(AppletFormatAdapter.CLASSLOADER))
\r
385 java.io.InputStream is = getClass().getResourceAsStream("/" + file);
\r
388 in = new BufferedReader(new java.io.InputStreamReader(is));
\r
392 String line, label, description, token;
\r
393 int graphStyle, index;
\r
394 int refSeqIndex = 1;
\r
395 int existingAnnotations = 0;
\r
396 if (al.getAlignmentAnnotation() != null)
\r
398 existingAnnotations = al.getAlignmentAnnotation().length;
\r
401 int alWidth = al.getWidth();
\r
403 StringTokenizer st;
\r
404 Annotation[] annotations;
\r
405 AlignmentAnnotation annotation = null;
\r
407 // First confirm this is an Annotation file
\r
408 boolean jvAnnotationFile = false;
\r
409 while ((line = in.readLine()) != null)
\r
411 if (line.indexOf("#") == 0)
\r
416 if (line.indexOf("JALVIEW_ANNOTATION") > -1)
\r
418 jvAnnotationFile = true;
\r
423 if (!jvAnnotationFile)
\r
429 while ((line = in.readLine()) != null)
\r
431 if (line.indexOf("#") == 0
\r
432 || line.indexOf("JALVIEW_ANNOTATION") > -1
\r
433 || line.length() == 0)
\r
438 st = new StringTokenizer(line, "\t");
\r
439 token = st.nextToken();
\r
440 if (token.equalsIgnoreCase("COLOUR"))
\r
442 // TODO: use graduated colour def'n here too
\r
443 colourAnnotations(al, st.nextToken(), st.nextToken());
\r
447 else if (token.equalsIgnoreCase("COMBINE"))
\r
449 combineAnnotations(al, st);
\r
453 else if (token.equalsIgnoreCase("GRAPHLINE"))
\r
459 else if (token.equalsIgnoreCase("SEQUENCE_REF"))
\r
461 if (st.hasMoreTokens())
\r
463 refSeq = al.findName(refSeqId = st.nextToken());
\r
464 if (refSeq == null)
\r
470 refSeqIndex = Integer.parseInt(st.nextToken());
\r
471 if (refSeqIndex < 1)
\r
475 .println("WARNING: SEQUENCE_REF index must be > 0 in AnnotationFile");
\r
477 } catch (Exception ex)
\r
490 else if (token.equalsIgnoreCase("SEQUENCE_GROUP"))
\r
496 else if (token.equalsIgnoreCase("PROPERTIES"))
\r
498 addProperties(al, st);
\r
502 else if (token.equalsIgnoreCase("BELOW_ALIGNMENT"))
\r
504 setBelowAlignment(al, st);
\r
507 else if (token.equalsIgnoreCase("ALIGNMENT"))
\r
509 addAlignmentDetails(al, st);
\r
513 graphStyle = AlignmentAnnotation.getGraphValueFromString(token);
\r
514 label = st.nextToken();
\r
517 annotations = new Annotation[alWidth];
\r
518 description = null;
\r
519 float score = Float.NaN;
\r
521 if (st.hasMoreTokens())
\r
523 line = st.nextToken();
\r
525 if (line.indexOf("|") == -1)
\r
527 description = line;
\r
528 if (st.hasMoreTokens())
\r
529 line = st.nextToken();
\r
532 if (st.hasMoreTokens())
\r
534 // This must be the score
\r
535 score = Float.valueOf(st.nextToken()).floatValue();
\r
538 st = new StringTokenizer(line, "|", true);
\r
540 boolean emptyColumn = true;
\r
541 boolean onlyOneElement = (st.countTokens() == 1);
\r
543 while (st.hasMoreElements() && index < alWidth)
\r
545 token = st.nextToken().trim();
\r
547 if (onlyOneElement)
\r
551 score = Float.valueOf(token).floatValue();
\r
553 } catch (NumberFormatException ex)
\r
558 if (token.equals("|"))
\r
565 emptyColumn = true;
\r
569 annotations[index++] = parseAnnotation(token);
\r
570 emptyColumn = false;
\r
576 annotation = new AlignmentAnnotation(label, description,
\r
577 (index == 0) ? null : annotations, 0, 0, graphStyle);
\r
579 annotation.score = score;
\r
581 if (refSeq != null)
\r
583 annotation.belowAlignment = false;
\r
584 // make a copy of refSeq so we can find other matches in the alignment
\r
585 SequenceI referedSeq = refSeq;
\r
588 // copy before we do any mapping business.
\r
589 // TODO: verify that undo/redo with 1:many sequence associated
\r
590 // annotations can be undone correctly
\r
591 AlignmentAnnotation ann = new AlignmentAnnotation(annotation);
\r
592 annotation.createSequenceMapping(referedSeq, refSeqIndex, false);
\r
593 annotation.adjustForAlignment();
\r
594 referedSeq.addAlignmentAnnotation(annotation);
\r
595 al.addAnnotation(annotation);
\r
596 al.setAnnotationIndex(annotation,
\r
597 al.getAlignmentAnnotation().length
\r
598 - existingAnnotations - 1);
\r
599 // and recover our virgin copy to use again if necessary.
\r
602 } while (refSeqId != null
\r
603 && (referedSeq = al.findName(referedSeq, refSeqId, true)) != null);
\r
607 al.addAnnotation(annotation);
\r
608 al.setAnnotationIndex(annotation,
\r
609 al.getAlignmentAnnotation().length - existingAnnotations
\r
614 } catch (Exception ex)
\r
616 ex.printStackTrace();
\r
617 System.out.println("Problem reading annotation file: " + ex);
\r
623 Annotation parseAnnotation(String string)
\r
625 String desc = null, displayChar = null;
\r
626 char ss = ' '; // secondaryStructure
\r
628 boolean parsedValue = false;
\r
630 // find colour here
\r
631 java.awt.Color colour = null;
\r
632 int i = string.indexOf("[");
\r
633 int j = string.indexOf("]");
\r
634 if (i > -1 && j > -1)
\r
636 UserColourScheme ucs = new UserColourScheme();
\r
638 colour = ucs.getColourFromString(string.substring(i + 1, j));
\r
640 string = string.substring(0, i) + string.substring(j + 1);
\r
643 StringTokenizer st = new StringTokenizer(string, ",");
\r
645 while (st.hasMoreTokens())
\r
647 token = st.nextToken().trim();
\r
648 if (token.length() == 0)
\r
657 displayChar = token;
\r
658 value = new Float(token).floatValue();
\r
659 parsedValue = true;
\r
661 } catch (NumberFormatException ex)
\r
666 if (token.equals("H") || token.equals("E"))
\r
668 // Either this character represents a helix or sheet
\r
669 // or an integer which can be displayed
\r
670 ss = token.charAt(0);
\r
671 if (displayChar.equals(token.substring(0, 1)))
\r
676 else if (desc == null)
\r
683 if (displayChar != null && displayChar.length() > 1 && desc != null
\r
684 && desc.length() == 1)
\r
686 String tmp = displayChar;
\r
687 displayChar = desc;
\r
691 * In principle, this code will ensure that the Annotation element generated
\r
692 * is renderable by any of the applet or application rendering code but
\r
693 * instead we check for null strings when the display character is rendered.
\r
694 * if (displayChar==null) { displayChar=""; }
\r
696 Annotation anot = new Annotation(displayChar, desc, ss, value);
\r
698 anot.colour = colour;
\r
703 void colourAnnotations(AlignmentI al, String label, String colour)
\r
705 UserColourScheme ucs = new UserColourScheme(colour);
\r
706 Annotation[] annotations;
\r
707 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
709 if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(label))
\r
711 annotations = al.getAlignmentAnnotation()[i].annotations;
\r
712 for (int j = 0; j < annotations.length; j++)
\r
714 if (annotations[j] != null)
\r
716 annotations[j].colour = ucs.findColour('A');
\r
723 void combineAnnotations(AlignmentI al, StringTokenizer st)
\r
725 int graphGroup = -1;
\r
726 String group = st.nextToken();
\r
727 // First make sure we are not overwriting the graphIndex
\r
728 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
730 if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(group))
\r
732 graphGroup = al.getAlignmentAnnotation()[i].graphGroup + 1;
\r
733 al.getAlignmentAnnotation()[i].graphGroup = graphGroup;
\r
738 // Now update groups
\r
739 while (st.hasMoreTokens())
\r
741 group = st.nextToken();
\r
742 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
744 if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(group))
\r
746 al.getAlignmentAnnotation()[i].graphGroup = graphGroup;
\r
753 void addLine(AlignmentI al, StringTokenizer st)
\r
755 String group = st.nextToken();
\r
756 AlignmentAnnotation annotation = null;
\r
758 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
760 if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(group))
\r
762 annotation = al.getAlignmentAnnotation()[i];
\r
767 if (annotation == null)
\r
771 float value = new Float(st.nextToken()).floatValue();
\r
772 String label = st.hasMoreTokens() ? st.nextToken() : null;
\r
773 java.awt.Color colour = null;
\r
774 if (st.hasMoreTokens())
\r
776 UserColourScheme ucs = new UserColourScheme(st.nextToken());
\r
777 colour = ucs.findColour('A');
\r
780 annotation.setThreshold(new GraphLine(value, label, colour));
\r
782 void addGroup(AlignmentI al, StringTokenizer st)
\r
784 SequenceGroup sg = new SequenceGroup();
\r
785 sg.setName(st.nextToken());
\r
788 rng = st.nextToken();
\r
789 if (rng.length()>0 && !rng.startsWith("*"))
\r
791 sg.setStartRes(Integer.parseInt(rng) - 1);
\r
795 rng = st.nextToken();
\r
796 if (rng.length()>0 && !rng.startsWith("*"))
\r
798 sg.setEndRes(Integer.parseInt(rng) - 1);
\r
800 sg.setEndRes(al.getWidth()-1);
\r
802 } catch (Exception e)
\r
804 System.err.println("Couldn't parse Group Start or End Field as '*' or a valid column or sequence index: '"+rng+"' - assuming alignment width for group.");
\r
805 // assume group is full width
\r
807 sg.setEndRes(al.getWidth()-1);
\r
810 String index = st.nextToken();
\r
811 if (index.equals("-1"))
\r
813 while (st.hasMoreElements())
\r
815 sg.addSequence(al.findName(st.nextToken()), false);
\r
820 StringTokenizer st2 = new StringTokenizer(index, ",");
\r
822 while (st2.hasMoreTokens())
\r
824 String tmp = st2.nextToken();
\r
825 if (tmp.equals("*"))
\r
827 for (int i = 0; i < al.getHeight(); i++)
\r
829 sg.addSequence(al.getSequenceAt(i), false);
\r
832 else if (tmp.indexOf("-") >= 0)
\r
834 StringTokenizer st3 = new StringTokenizer(tmp, "-");
\r
836 int start = (Integer.parseInt(st3.nextToken()));
\r
837 int end = (Integer.parseInt(st3.nextToken()));
\r
841 for (int i = start; i <= end; i++)
\r
843 sg.addSequence(al.getSequenceAt(i - 1), false);
\r
850 .addSequence(al.getSequenceAt(Integer.parseInt(tmp) - 1),
\r
856 if (refSeq != null)
\r
858 sg.setStartRes(refSeq.findIndex(sg.getStartRes() + 1) - 1);
\r
859 sg.setEndRes(refSeq.findIndex(sg.getEndRes() + 1) - 1);
\r
860 sg.setSeqrep(refSeq);
\r
863 if (sg.getSize() > 0)
\r
869 void addProperties(AlignmentI al, StringTokenizer st)
\r
872 // So far we have only added groups to the annotationHash,
\r
873 // the idea is in the future properties can be added to
\r
874 // alignments, other annotations etc
\r
875 if (al.getGroups() == null)
\r
879 SequenceGroup sg = null;
\r
881 String name = st.nextToken();
\r
883 Vector groups = al.getGroups();
\r
884 for (int i = 0; i < groups.size(); i++)
\r
886 sg = (SequenceGroup) groups.elementAt(i);
\r
887 if (sg.getName().equals(name))
\r
899 String keyValue, key, value;
\r
900 ColourSchemeI def = sg.cs;
\r
902 while (st.hasMoreTokens())
\r
904 keyValue = st.nextToken();
\r
905 key = keyValue.substring(0, keyValue.indexOf("="));
\r
906 value = keyValue.substring(keyValue.indexOf("=") + 1);
\r
908 if (key.equalsIgnoreCase("description"))
\r
910 sg.setDescription(value);
\r
912 else if (key.equalsIgnoreCase("colour"))
\r
914 sg.cs = ColourSchemeProperty.getColour(al, value);
\r
916 else if (key.equalsIgnoreCase("pidThreshold"))
\r
918 sg.cs.setThreshold(Integer.parseInt(value), true);
\r
921 else if (key.equalsIgnoreCase("consThreshold"))
\r
923 sg.cs.setConservationInc(Integer.parseInt(value));
\r
924 Conservation c = new Conservation("Group",
\r
925 ResidueProperties.propHash, 3, sg.getSequences(null), sg
\r
926 .getStartRes(), sg.getEndRes() + 1);
\r
929 c.verdict(false, 25);
\r
931 sg.cs.setConservation(c);
\r
934 else if (key.equalsIgnoreCase("outlineColour"))
\r
936 sg.setOutlineColour(new UserColourScheme(value).findColour('A'));
\r
938 else if (key.equalsIgnoreCase("displayBoxes"))
\r
940 sg.setDisplayBoxes(Boolean.valueOf(value).booleanValue());
\r
942 else if (key.equalsIgnoreCase("showUnconserved"))
\r
944 sg.setShowunconserved(Boolean.valueOf(value).booleanValue());
\r
946 else if (key.equalsIgnoreCase("displayText"))
\r
948 sg.setDisplayText(Boolean.valueOf(value).booleanValue());
\r
950 else if (key.equalsIgnoreCase("colourText"))
\r
952 sg.setColourText(Boolean.valueOf(value).booleanValue());
\r
954 else if (key.equalsIgnoreCase("textCol1"))
\r
956 sg.textColour = new UserColourScheme(value).findColour('A');
\r
958 else if (key.equalsIgnoreCase("textCol2"))
\r
960 sg.textColour2 = new UserColourScheme(value).findColour('A');
\r
962 else if (key.equalsIgnoreCase("textColThreshold"))
\r
964 sg.thresholdTextColour = Integer.parseInt(value);
\r
966 else if (key.equalsIgnoreCase("idColour"))
\r
968 // consider warning if colour doesn't resolve to a real colour
\r
969 sg.setIdColour((def = new UserColourScheme(value))
\r
972 else if (key.equalsIgnoreCase("hide"))
\r
974 // see bug https://mantis.lifesci.dundee.ac.uk/view.php?id=25847
\r
975 sg.setHidereps(true);
\r
977 else if (key.equalsIgnoreCase("hidecols"))
\r
979 // see bug https://mantis.lifesci.dundee.ac.uk/view.php?id=25847
\r
980 sg.setHideCols(true);
\r
982 sg.recalcConservation();
\r
991 void setBelowAlignment(AlignmentI al, StringTokenizer st)
\r
994 AlignmentAnnotation aa;
\r
995 while (st.hasMoreTokens())
\r
997 token = st.nextToken();
\r
998 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
1000 aa = al.getAlignmentAnnotation()[i];
\r
1001 if (aa.sequenceRef == refSeq && aa.label.equals(token))
\r
1003 aa.belowAlignment = true;
\r
1009 void addAlignmentDetails(AlignmentI al, StringTokenizer st)
\r
1011 String keyValue, key, value;
\r
1012 while (st.hasMoreTokens())
\r
1014 keyValue = st.nextToken();
\r
1015 key = keyValue.substring(0, keyValue.indexOf("="));
\r
1016 value = keyValue.substring(keyValue.indexOf("=") + 1);
\r
1017 al.setProperty(key, value);
\r
1022 * Write annotations as a CSV file of the form 'label, value, value, ...' for
\r
1025 * @param annotations
\r
1026 * @return CSV file as a string.
\r
1028 public String printCSVAnnotations(AlignmentAnnotation[] annotations)
\r
1030 StringBuffer sp = new StringBuffer();
\r
1031 for (int i = 0; i < annotations.length; i++)
\r
1033 String atos = annotations[i].toString();
\r
1037 int cp = atos.indexOf("\n", p);
\r
1038 sp.append(annotations[i].label);
\r
1042 sp.append(atos.substring(p, cp + 1));
\r
1046 sp.append(atos.substring(p));
\r
1052 return sp.toString();
\r