2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
\r
3 * Copyright (C) 2008 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 colourAnnotations(al, st.nextToken(), st.nextToken());
\r
446 else if (token.equalsIgnoreCase("COMBINE"))
\r
448 combineAnnotations(al, st);
\r
452 else if (token.equalsIgnoreCase("GRAPHLINE"))
\r
458 else if (token.equalsIgnoreCase("SEQUENCE_REF"))
\r
460 if (st.hasMoreTokens())
\r
462 refSeq = al.findName(refSeqId = st.nextToken());
\r
463 if (refSeq == null)
\r
469 refSeqIndex = Integer.parseInt(st.nextToken());
\r
470 if (refSeqIndex < 1)
\r
474 .println("WARNING: SEQUENCE_REF index must be > 0 in AnnotationFile");
\r
476 } catch (Exception ex)
\r
489 else if (token.equalsIgnoreCase("SEQUENCE_GROUP"))
\r
495 else if (token.equalsIgnoreCase("PROPERTIES"))
\r
497 addProperties(al, st);
\r
501 else if (token.equalsIgnoreCase("BELOW_ALIGNMENT"))
\r
503 setBelowAlignment(al, st);
\r
506 else if (token.equalsIgnoreCase("ALIGNMENT"))
\r
508 addAlignmentDetails(al, st);
\r
512 graphStyle = AlignmentAnnotation.getGraphValueFromString(token);
\r
513 label = st.nextToken();
\r
516 annotations = new Annotation[alWidth];
\r
517 description = null;
\r
518 float score = Float.NaN;
\r
520 if (st.hasMoreTokens())
\r
522 line = st.nextToken();
\r
524 if (line.indexOf("|") == -1)
\r
526 description = line;
\r
527 if (st.hasMoreTokens())
\r
528 line = st.nextToken();
\r
531 if (st.hasMoreTokens())
\r
533 // This must be the score
\r
534 score = Float.valueOf(st.nextToken()).floatValue();
\r
537 st = new StringTokenizer(line, "|", true);
\r
539 boolean emptyColumn = true;
\r
540 boolean onlyOneElement = (st.countTokens() == 1);
\r
542 while (st.hasMoreElements() && index < alWidth)
\r
544 token = st.nextToken().trim();
\r
546 if (onlyOneElement)
\r
550 score = Float.valueOf(token).floatValue();
\r
552 } catch (NumberFormatException ex)
\r
557 if (token.equals("|"))
\r
564 emptyColumn = true;
\r
568 annotations[index++] = parseAnnotation(token);
\r
569 emptyColumn = false;
\r
575 annotation = new AlignmentAnnotation(label, description,
\r
576 (index == 0) ? null : annotations, 0, 0, graphStyle);
\r
578 annotation.score = score;
\r
580 if (refSeq != null)
\r
582 annotation.belowAlignment = false;
\r
583 // make a copy of refSeq so we can find other matches in the alignment
\r
584 SequenceI referedSeq = refSeq;
\r
587 // copy before we do any mapping business.
\r
588 // TODO: verify that undo/redo with 1:many sequence associated
\r
589 // annotations can be undone correctly
\r
590 AlignmentAnnotation ann = new AlignmentAnnotation(annotation);
\r
591 annotation.createSequenceMapping(referedSeq, refSeqIndex, false);
\r
592 annotation.adjustForAlignment();
\r
593 referedSeq.addAlignmentAnnotation(annotation);
\r
594 al.addAnnotation(annotation);
\r
595 al.setAnnotationIndex(annotation,
\r
596 al.getAlignmentAnnotation().length
\r
597 - existingAnnotations - 1);
\r
598 // and recover our virgin copy to use again if necessary.
\r
601 } while (refSeqId != null
\r
602 && (referedSeq = al.findName(referedSeq, refSeqId, true)) != null);
\r
606 al.addAnnotation(annotation);
\r
607 al.setAnnotationIndex(annotation,
\r
608 al.getAlignmentAnnotation().length - existingAnnotations
\r
613 } catch (Exception ex)
\r
615 ex.printStackTrace();
\r
616 System.out.println("Problem reading annotation file: " + ex);
\r
622 Annotation parseAnnotation(String string)
\r
624 String desc = null, displayChar = null;
\r
625 char ss = ' '; // secondaryStructure
\r
627 boolean parsedValue = false;
\r
629 // find colour here
\r
630 java.awt.Color colour = null;
\r
631 int i = string.indexOf("[");
\r
632 int j = string.indexOf("]");
\r
633 if (i > -1 && j > -1)
\r
635 UserColourScheme ucs = new UserColourScheme();
\r
637 colour = ucs.getColourFromString(string.substring(i + 1, j));
\r
639 string = string.substring(0, i) + string.substring(j + 1);
\r
642 StringTokenizer st = new StringTokenizer(string, ",");
\r
644 while (st.hasMoreTokens())
\r
646 token = st.nextToken().trim();
\r
647 if (token.length() == 0)
\r
656 displayChar = token;
\r
657 value = new Float(token).floatValue();
\r
658 parsedValue = true;
\r
660 } catch (NumberFormatException ex)
\r
665 if (token.equals("H") || token.equals("E"))
\r
667 // Either this character represents a helix or sheet
\r
668 // or an integer which can be displayed
\r
669 ss = token.charAt(0);
\r
670 if (displayChar.equals(token.substring(0, 1)))
\r
675 else if (desc == null)
\r
682 if (displayChar != null && displayChar.length() > 1 && desc != null
\r
683 && desc.length() == 1)
\r
685 String tmp = displayChar;
\r
686 displayChar = desc;
\r
690 * In principle, this code will ensure that the Annotation element generated
\r
691 * is renderable by any of the applet or application rendering code but
\r
692 * instead we check for null strings when the display character is rendered.
\r
693 * if (displayChar==null) { displayChar=""; }
\r
695 Annotation anot = new Annotation(displayChar, desc, ss, value);
\r
697 anot.colour = colour;
\r
702 void colourAnnotations(AlignmentI al, String label, String colour)
\r
704 UserColourScheme ucs = new UserColourScheme(colour);
\r
705 Annotation[] annotations;
\r
706 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
708 if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(label))
\r
710 annotations = al.getAlignmentAnnotation()[i].annotations;
\r
711 for (int j = 0; j < annotations.length; j++)
\r
713 if (annotations[j] != null)
\r
715 annotations[j].colour = ucs.findColour('A');
\r
722 void combineAnnotations(AlignmentI al, StringTokenizer st)
\r
724 int graphGroup = -1;
\r
725 String group = st.nextToken();
\r
726 // First make sure we are not overwriting the graphIndex
\r
727 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
729 if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(group))
\r
731 graphGroup = al.getAlignmentAnnotation()[i].graphGroup + 1;
\r
732 al.getAlignmentAnnotation()[i].graphGroup = graphGroup;
\r
737 // Now update groups
\r
738 while (st.hasMoreTokens())
\r
740 group = st.nextToken();
\r
741 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
743 if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(group))
\r
745 al.getAlignmentAnnotation()[i].graphGroup = graphGroup;
\r
752 void addLine(AlignmentI al, StringTokenizer st)
\r
754 String group = st.nextToken();
\r
755 AlignmentAnnotation annotation = null;
\r
757 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
759 if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(group))
\r
761 annotation = al.getAlignmentAnnotation()[i];
\r
766 if (annotation == null)
\r
770 float value = new Float(st.nextToken()).floatValue();
\r
771 String label = st.hasMoreTokens() ? st.nextToken() : null;
\r
772 java.awt.Color colour = null;
\r
773 if (st.hasMoreTokens())
\r
775 UserColourScheme ucs = new UserColourScheme(st.nextToken());
\r
776 colour = ucs.findColour('A');
\r
779 annotation.setThreshold(new GraphLine(value, label, colour));
\r
781 void addGroup(AlignmentI al, StringTokenizer st)
\r
783 SequenceGroup sg = new SequenceGroup();
\r
784 sg.setName(st.nextToken());
\r
787 rng = st.nextToken();
\r
788 if (rng.length()>0 && !rng.startsWith("*"))
\r
790 sg.setStartRes(Integer.parseInt(rng) - 1);
\r
794 rng = st.nextToken();
\r
795 if (rng.length()>0 && !rng.startsWith("*"))
\r
797 sg.setEndRes(Integer.parseInt(rng) - 1);
\r
799 sg.setEndRes(al.getWidth()-1);
\r
801 } catch (Exception e)
\r
803 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
804 // assume group is full width
\r
806 sg.setEndRes(al.getWidth()-1);
\r
809 String index = st.nextToken();
\r
810 if (index.equals("-1"))
\r
812 while (st.hasMoreElements())
\r
814 sg.addSequence(al.findName(st.nextToken()), false);
\r
819 StringTokenizer st2 = new StringTokenizer(index, ",");
\r
821 while (st2.hasMoreTokens())
\r
823 String tmp = st2.nextToken();
\r
824 if (tmp.equals("*"))
\r
826 for (int i = 0; i < al.getHeight(); i++)
\r
828 sg.addSequence(al.getSequenceAt(i), false);
\r
831 else if (tmp.indexOf("-") >= 0)
\r
833 StringTokenizer st3 = new StringTokenizer(tmp, "-");
\r
835 int start = (Integer.parseInt(st3.nextToken()));
\r
836 int end = (Integer.parseInt(st3.nextToken()));
\r
840 for (int i = start; i <= end; i++)
\r
842 sg.addSequence(al.getSequenceAt(i - 1), false);
\r
849 .addSequence(al.getSequenceAt(Integer.parseInt(tmp) - 1),
\r
855 if (refSeq != null)
\r
857 sg.setStartRes(refSeq.findIndex(sg.getStartRes() + 1) - 1);
\r
858 sg.setEndRes(refSeq.findIndex(sg.getEndRes() + 1) - 1);
\r
859 sg.setSeqrep(refSeq);
\r
862 if (sg.getSize() > 0)
\r
868 void addProperties(AlignmentI al, StringTokenizer st)
\r
871 // So far we have only added groups to the annotationHash,
\r
872 // the idea is in the future properties can be added to
\r
873 // alignments, other annotations etc
\r
874 if (al.getGroups() == null)
\r
878 SequenceGroup sg = null;
\r
880 String name = st.nextToken();
\r
882 Vector groups = al.getGroups();
\r
883 for (int i = 0; i < groups.size(); i++)
\r
885 sg = (SequenceGroup) groups.elementAt(i);
\r
886 if (sg.getName().equals(name))
\r
898 String keyValue, key, value;
\r
899 ColourSchemeI def = sg.cs;
\r
901 while (st.hasMoreTokens())
\r
903 keyValue = st.nextToken();
\r
904 key = keyValue.substring(0, keyValue.indexOf("="));
\r
905 value = keyValue.substring(keyValue.indexOf("=") + 1);
\r
907 if (key.equalsIgnoreCase("description"))
\r
909 sg.setDescription(value);
\r
911 else if (key.equalsIgnoreCase("colour"))
\r
913 sg.cs = ColourSchemeProperty.getColour(al, value);
\r
915 else if (key.equalsIgnoreCase("pidThreshold"))
\r
917 sg.cs.setThreshold(Integer.parseInt(value), true);
\r
920 else if (key.equalsIgnoreCase("consThreshold"))
\r
922 sg.cs.setConservationInc(Integer.parseInt(value));
\r
923 Conservation c = new Conservation("Group",
\r
924 ResidueProperties.propHash, 3, sg.getSequences(null), sg
\r
925 .getStartRes(), sg.getEndRes() + 1);
\r
928 c.verdict(false, 25);
\r
930 sg.cs.setConservation(c);
\r
933 else if (key.equalsIgnoreCase("outlineColour"))
\r
935 sg.setOutlineColour(new UserColourScheme(value).findColour('A'));
\r
937 else if (key.equalsIgnoreCase("displayBoxes"))
\r
939 sg.setDisplayBoxes(Boolean.valueOf(value).booleanValue());
\r
941 else if (key.equalsIgnoreCase("showUnconserved"))
\r
943 sg.setShowunconserved(Boolean.valueOf(value).booleanValue());
\r
945 else if (key.equalsIgnoreCase("displayText"))
\r
947 sg.setDisplayText(Boolean.valueOf(value).booleanValue());
\r
949 else if (key.equalsIgnoreCase("colourText"))
\r
951 sg.setColourText(Boolean.valueOf(value).booleanValue());
\r
953 else if (key.equalsIgnoreCase("textCol1"))
\r
955 sg.textColour = new UserColourScheme(value).findColour('A');
\r
957 else if (key.equalsIgnoreCase("textCol2"))
\r
959 sg.textColour2 = new UserColourScheme(value).findColour('A');
\r
961 else if (key.equalsIgnoreCase("textColThreshold"))
\r
963 sg.thresholdTextColour = Integer.parseInt(value);
\r
965 else if (key.equalsIgnoreCase("idColour"))
\r
967 // consider warning if colour doesn't resolve to a real colour
\r
968 sg.setIdColour((def = new UserColourScheme(value))
\r
971 else if (key.equalsIgnoreCase("hide"))
\r
973 // see bug https://mantis.lifesci.dundee.ac.uk/view.php?id=25847
\r
974 sg.setHidereps(true);
\r
976 else if (key.equalsIgnoreCase("hidecols"))
\r
978 // see bug https://mantis.lifesci.dundee.ac.uk/view.php?id=25847
\r
979 sg.setHideCols(true);
\r
981 sg.recalcConservation();
\r
990 void setBelowAlignment(AlignmentI al, StringTokenizer st)
\r
993 AlignmentAnnotation aa;
\r
994 while (st.hasMoreTokens())
\r
996 token = st.nextToken();
\r
997 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
999 aa = al.getAlignmentAnnotation()[i];
\r
1000 if (aa.sequenceRef == refSeq && aa.label.equals(token))
\r
1002 aa.belowAlignment = true;
\r
1008 void addAlignmentDetails(AlignmentI al, StringTokenizer st)
\r
1010 String keyValue, key, value;
\r
1011 while (st.hasMoreTokens())
\r
1013 keyValue = st.nextToken();
\r
1014 key = keyValue.substring(0, keyValue.indexOf("="));
\r
1015 value = keyValue.substring(keyValue.indexOf("=") + 1);
\r
1016 al.setProperty(key, value);
\r
1021 * Write annotations as a CSV file of the form 'label, value, value, ...' for
\r
1024 * @param annotations
\r
1025 * @return CSV file as a string.
\r
1027 public String printCSVAnnotations(AlignmentAnnotation[] annotations)
\r
1029 StringBuffer sp = new StringBuffer();
\r
1030 for (int i = 0; i < annotations.length; i++)
\r
1032 String atos = annotations[i].toString();
\r
1036 int cp = atos.indexOf("\n", p);
\r
1037 sp.append(annotations[i].label);
\r
1041 sp.append(atos.substring(p, cp + 1));
\r
1045 sp.append(atos.substring(p));
\r
1051 return sp.toString();
\r