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
267 return text.toString();
\r
270 public void printGroups(Vector sequenceGroups)
\r
273 SequenceI seqrep=null;
\r
274 for (int i = 0; i < sequenceGroups.size(); i++)
\r
276 sg = (SequenceGroup) sequenceGroups.elementAt(i);
\r
277 if (!sg.hasSeqrep())
\r
279 text.append("SEQUENCE_GROUP\t" + sg.getName() + "\t"
\r
280 + (sg.getStartRes() + 1) + "\t" + (sg.getEndRes() + 1) + "\t"
\r
284 seqrep = sg.getSeqrep();
\r
285 text.append("SEQUENCE_REF\t"+seqrep.getName()+"\n");
\r
286 text.append("SEQUENCE_GROUP\t" + sg.getName() + "\t"
\r
287 + (seqrep.findPosition(sg.getStartRes())) + "\t" + (seqrep.findPosition(sg.getEndRes())) + "\t"
\r
290 for (int s = 0; s < sg.getSize(); s++)
\r
292 text.append(sg.getSequenceAt(s).getName() + "\t");
\r
295 text.append("\nPROPERTIES\t" + sg.getName() + "\t");
\r
297 if (sg.getDescription() != null)
\r
299 text.append("description=" + sg.getDescription() + "\t");
\r
303 text.append("colour=" + ColourSchemeProperty.getColourName(sg.cs)
\r
305 if (sg.cs.getThreshold() != 0)
\r
307 text.append("pidThreshold=" + sg.cs.getThreshold());
\r
309 if (sg.cs.conservationApplied())
\r
311 text.append("consThreshold=" + sg.cs.getConservationInc() + "\t");
\r
314 text.append("outlineColour="
\r
315 + jalview.util.Format.getHexString(sg.getOutlineColour())
\r
318 text.append("displayBoxes=" + sg.getDisplayBoxes() + "\t");
\r
319 text.append("displayText=" + sg.getDisplayText() + "\t");
\r
320 text.append("colourText=" + sg.getColourText() + "\t");
\r
322 if (sg.textColour != java.awt.Color.black)
\r
324 text.append("textCol1="
\r
325 + jalview.util.Format.getHexString(sg.textColour) + "\t");
\r
327 if (sg.textColour2 != java.awt.Color.white)
\r
329 text.append("textCol2="
\r
330 + jalview.util.Format.getHexString(sg.textColour2) + "\t");
\r
332 if (sg.thresholdTextColour != 0)
\r
334 text.append("textColThreshold=" + sg.thresholdTextColour+"\t");
\r
336 if (sg.idColour != null)
\r
338 text.append("idColour="
\r
339 + jalview.util.Format.getHexString(sg.idColour) + "\t");
\r
341 if (sg.isHidereps())
\r
343 text.append("hide=true\t");
\r
345 if (sg.isHideCols())
\r
347 text.append("hidecols=true\t");
\r
351 // terminate the last line and clear the sequence ref for the group
\r
352 text.append("\nSEQUENCE_REF");
\r
354 text.append("\n\n");
\r
359 SequenceI refSeq = null;
\r
361 String refSeqId = null;
\r
363 public boolean readAnnotationFile(AlignmentI al, String file,
\r
368 BufferedReader in = null;
\r
369 if (protocol.equals(AppletFormatAdapter.FILE))
\r
371 in = new BufferedReader(new FileReader(file));
\r
373 else if (protocol.equals(AppletFormatAdapter.URL))
\r
375 URL url = new URL(file);
\r
376 in = new BufferedReader(new InputStreamReader(url.openStream()));
\r
378 else if (protocol.equals(AppletFormatAdapter.PASTE))
\r
380 in = new BufferedReader(new StringReader(file));
\r
382 else if (protocol.equals(AppletFormatAdapter.CLASSLOADER))
\r
384 java.io.InputStream is = getClass().getResourceAsStream("/" + file);
\r
387 in = new BufferedReader(new java.io.InputStreamReader(is));
\r
391 String line, label, description, token;
\r
392 int graphStyle, index;
\r
393 int refSeqIndex = 1;
\r
394 int existingAnnotations = 0;
\r
395 if (al.getAlignmentAnnotation() != null)
\r
397 existingAnnotations = al.getAlignmentAnnotation().length;
\r
400 int alWidth = al.getWidth();
\r
402 StringTokenizer st;
\r
403 Annotation[] annotations;
\r
404 AlignmentAnnotation annotation = null;
\r
406 // First confirm this is an Annotation file
\r
407 boolean jvAnnotationFile = false;
\r
408 while ((line = in.readLine()) != null)
\r
410 if (line.indexOf("#") == 0)
\r
415 if (line.indexOf("JALVIEW_ANNOTATION") > -1)
\r
417 jvAnnotationFile = true;
\r
422 if (!jvAnnotationFile)
\r
428 while ((line = in.readLine()) != null)
\r
430 if (line.indexOf("#") == 0
\r
431 || line.indexOf("JALVIEW_ANNOTATION") > -1
\r
432 || line.length() == 0)
\r
437 st = new StringTokenizer(line, "\t");
\r
438 token = st.nextToken();
\r
439 if (token.equalsIgnoreCase("COLOUR"))
\r
441 colourAnnotations(al, st.nextToken(), st.nextToken());
\r
445 else if (token.equalsIgnoreCase("COMBINE"))
\r
447 combineAnnotations(al, st);
\r
451 else if (token.equalsIgnoreCase("GRAPHLINE"))
\r
457 else if (token.equalsIgnoreCase("SEQUENCE_REF"))
\r
459 if (st.hasMoreTokens())
\r
461 refSeq = al.findName(refSeqId = st.nextToken());
\r
462 if (refSeq == null)
\r
468 refSeqIndex = Integer.parseInt(st.nextToken());
\r
469 if (refSeqIndex < 1)
\r
473 .println("WARNING: SEQUENCE_REF index must be > 0 in AnnotationFile");
\r
475 } catch (Exception ex)
\r
488 else if (token.equalsIgnoreCase("SEQUENCE_GROUP"))
\r
494 else if (token.equalsIgnoreCase("PROPERTIES"))
\r
496 addProperties(al, st);
\r
500 else if (token.equalsIgnoreCase("BELOW_ALIGNMENT"))
\r
502 setBelowAlignment(al, st);
\r
505 else if (token.equalsIgnoreCase("ALIGNMENT"))
\r
507 addAlignmentDetails(al, st);
\r
511 graphStyle = AlignmentAnnotation.getGraphValueFromString(token);
\r
512 label = st.nextToken();
\r
515 annotations = new Annotation[alWidth];
\r
516 description = null;
\r
517 float score = Float.NaN;
\r
519 if (st.hasMoreTokens())
\r
521 line = st.nextToken();
\r
523 if (line.indexOf("|") == -1)
\r
525 description = line;
\r
526 if (st.hasMoreTokens())
\r
527 line = st.nextToken();
\r
530 if (st.hasMoreTokens())
\r
532 // This must be the score
\r
533 score = Float.valueOf(st.nextToken()).floatValue();
\r
536 st = new StringTokenizer(line, "|", true);
\r
538 boolean emptyColumn = true;
\r
539 boolean onlyOneElement = (st.countTokens() == 1);
\r
541 while (st.hasMoreElements() && index < alWidth)
\r
543 token = st.nextToken().trim();
\r
545 if (onlyOneElement)
\r
549 score = Float.valueOf(token).floatValue();
\r
551 } catch (NumberFormatException ex)
\r
556 if (token.equals("|"))
\r
563 emptyColumn = true;
\r
567 annotations[index++] = parseAnnotation(token);
\r
568 emptyColumn = false;
\r
574 annotation = new AlignmentAnnotation(label, description,
\r
575 (index == 0) ? null : annotations, 0, 0, graphStyle);
\r
577 annotation.score = score;
\r
579 if (refSeq != null)
\r
581 annotation.belowAlignment = false;
\r
582 // make a copy of refSeq so we can find other matches in the alignment
\r
583 SequenceI referedSeq = refSeq;
\r
586 // copy before we do any mapping business.
\r
587 // TODO: verify that undo/redo with 1:many sequence associated
\r
588 // annotations can be undone correctly
\r
589 AlignmentAnnotation ann = new AlignmentAnnotation(annotation);
\r
590 annotation.createSequenceMapping(referedSeq, refSeqIndex, false);
\r
591 annotation.adjustForAlignment();
\r
592 referedSeq.addAlignmentAnnotation(annotation);
\r
593 al.addAnnotation(annotation);
\r
594 al.setAnnotationIndex(annotation,
\r
595 al.getAlignmentAnnotation().length
\r
596 - existingAnnotations - 1);
\r
597 // and recover our virgin copy to use again if necessary.
\r
600 } while (refSeqId != null
\r
601 && (referedSeq = al.findName(referedSeq, refSeqId, true)) != null);
\r
605 al.addAnnotation(annotation);
\r
606 al.setAnnotationIndex(annotation,
\r
607 al.getAlignmentAnnotation().length - existingAnnotations
\r
612 } catch (Exception ex)
\r
614 ex.printStackTrace();
\r
615 System.out.println("Problem reading annotation file: " + ex);
\r
621 Annotation parseAnnotation(String string)
\r
623 String desc = null, displayChar = null;
\r
624 char ss = ' '; // secondaryStructure
\r
626 boolean parsedValue = false;
\r
628 // find colour here
\r
629 java.awt.Color colour = null;
\r
630 int i = string.indexOf("[");
\r
631 int j = string.indexOf("]");
\r
632 if (i > -1 && j > -1)
\r
634 UserColourScheme ucs = new UserColourScheme();
\r
636 colour = ucs.getColourFromString(string.substring(i + 1, j));
\r
638 string = string.substring(0, i) + string.substring(j + 1);
\r
641 StringTokenizer st = new StringTokenizer(string, ",");
\r
643 while (st.hasMoreTokens())
\r
645 token = st.nextToken().trim();
\r
646 if (token.length() == 0)
\r
655 displayChar = token;
\r
656 value = new Float(token).floatValue();
\r
657 parsedValue = true;
\r
659 } catch (NumberFormatException ex)
\r
664 if (token.equals("H") || token.equals("E"))
\r
666 // Either this character represents a helix or sheet
\r
667 // or an integer which can be displayed
\r
668 ss = token.charAt(0);
\r
669 if (displayChar.equals(token.substring(0, 1)))
\r
674 else if (desc == null)
\r
681 if (displayChar != null && displayChar.length() > 1 && desc != null
\r
682 && desc.length() == 1)
\r
684 String tmp = displayChar;
\r
685 displayChar = desc;
\r
689 * In principle, this code will ensure that the Annotation element generated
\r
690 * is renderable by any of the applet or application rendering code but
\r
691 * instead we check for null strings when the display character is rendered.
\r
692 * if (displayChar==null) { displayChar=""; }
\r
694 Annotation anot = new Annotation(displayChar, desc, ss, value);
\r
696 anot.colour = colour;
\r
701 void colourAnnotations(AlignmentI al, String label, String colour)
\r
703 UserColourScheme ucs = new UserColourScheme(colour);
\r
704 Annotation[] annotations;
\r
705 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
707 if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(label))
\r
709 annotations = al.getAlignmentAnnotation()[i].annotations;
\r
710 for (int j = 0; j < annotations.length; j++)
\r
712 if (annotations[j] != null)
\r
714 annotations[j].colour = ucs.findColour('A');
\r
721 void combineAnnotations(AlignmentI al, StringTokenizer st)
\r
723 int graphGroup = -1;
\r
724 String group = st.nextToken();
\r
725 // First make sure we are not overwriting the graphIndex
\r
726 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
728 if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(group))
\r
730 graphGroup = al.getAlignmentAnnotation()[i].graphGroup + 1;
\r
731 al.getAlignmentAnnotation()[i].graphGroup = graphGroup;
\r
736 // Now update groups
\r
737 while (st.hasMoreTokens())
\r
739 group = st.nextToken();
\r
740 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
742 if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(group))
\r
744 al.getAlignmentAnnotation()[i].graphGroup = graphGroup;
\r
751 void addLine(AlignmentI al, StringTokenizer st)
\r
753 String group = st.nextToken();
\r
754 AlignmentAnnotation annotation = null;
\r
756 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
758 if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(group))
\r
760 annotation = al.getAlignmentAnnotation()[i];
\r
765 if (annotation == null)
\r
769 float value = new Float(st.nextToken()).floatValue();
\r
770 String label = st.hasMoreTokens() ? st.nextToken() : null;
\r
771 java.awt.Color colour = null;
\r
772 if (st.hasMoreTokens())
\r
774 UserColourScheme ucs = new UserColourScheme(st.nextToken());
\r
775 colour = ucs.findColour('A');
\r
778 annotation.setThreshold(new GraphLine(value, label, colour));
\r
780 void addGroup(AlignmentI al, StringTokenizer st)
\r
782 SequenceGroup sg = new SequenceGroup();
\r
783 sg.setName(st.nextToken());
\r
786 rng = st.nextToken();
\r
787 if (rng.length()>0 && !rng.startsWith("*"))
\r
789 sg.setStartRes(Integer.parseInt(rng) - 1);
\r
793 rng = st.nextToken();
\r
794 if (rng.length()>0 && !rng.startsWith("*"))
\r
796 sg.setEndRes(Integer.parseInt(rng) - 1);
\r
798 sg.setEndRes(al.getWidth()-1);
\r
800 } catch (Exception e)
\r
802 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
803 // assume group is full width
\r
805 sg.setEndRes(al.getWidth()-1);
\r
808 String index = st.nextToken();
\r
809 if (index.equals("-1"))
\r
811 while (st.hasMoreElements())
\r
813 sg.addSequence(al.findName(st.nextToken()), false);
\r
818 StringTokenizer st2 = new StringTokenizer(index, ",");
\r
820 while (st2.hasMoreTokens())
\r
822 String tmp = st2.nextToken();
\r
823 if (tmp.equals("*"))
\r
825 for (int i = 0; i < al.getHeight(); i++)
\r
827 sg.addSequence(al.getSequenceAt(i), false);
\r
830 else if (tmp.indexOf("-") >= 0)
\r
832 StringTokenizer st3 = new StringTokenizer(tmp, "-");
\r
834 int start = (Integer.parseInt(st3.nextToken()));
\r
835 int end = (Integer.parseInt(st3.nextToken()));
\r
839 for (int i = start; i <= end; i++)
\r
841 sg.addSequence(al.getSequenceAt(i - 1), false);
\r
848 .addSequence(al.getSequenceAt(Integer.parseInt(tmp) - 1),
\r
854 if (refSeq != null)
\r
856 sg.setStartRes(refSeq.findIndex(sg.getStartRes() + 1) - 1);
\r
857 sg.setEndRes(refSeq.findIndex(sg.getEndRes() + 1) - 1);
\r
858 sg.setSeqrep(refSeq);
\r
861 if (sg.getSize() > 0)
\r
867 void addProperties(AlignmentI al, StringTokenizer st)
\r
870 // So far we have only added groups to the annotationHash,
\r
871 // the idea is in the future properties can be added to
\r
872 // alignments, other annotations etc
\r
873 if (al.getGroups() == null)
\r
877 SequenceGroup sg = null;
\r
879 String name = st.nextToken();
\r
881 Vector groups = al.getGroups();
\r
882 for (int i = 0; i < groups.size(); i++)
\r
884 sg = (SequenceGroup) groups.elementAt(i);
\r
885 if (sg.getName().equals(name))
\r
897 String keyValue, key, value;
\r
898 ColourSchemeI def = sg.cs;
\r
900 while (st.hasMoreTokens())
\r
902 keyValue = st.nextToken();
\r
903 key = keyValue.substring(0, keyValue.indexOf("="));
\r
904 value = keyValue.substring(keyValue.indexOf("=") + 1);
\r
906 if (key.equalsIgnoreCase("description"))
\r
908 sg.setDescription(value);
\r
910 else if (key.equalsIgnoreCase("colour"))
\r
912 sg.cs = ColourSchemeProperty.getColour(al, value);
\r
914 else if (key.equalsIgnoreCase("pidThreshold"))
\r
916 sg.cs.setThreshold(Integer.parseInt(value), true);
\r
919 else if (key.equalsIgnoreCase("consThreshold"))
\r
921 sg.cs.setConservationInc(Integer.parseInt(value));
\r
922 Conservation c = new Conservation("Group",
\r
923 ResidueProperties.propHash, 3, sg.getSequences(null), sg
\r
924 .getStartRes(), sg.getEndRes() + 1);
\r
927 c.verdict(false, 25);
\r
929 sg.cs.setConservation(c);
\r
932 else if (key.equalsIgnoreCase("outlineColour"))
\r
934 sg.setOutlineColour(new UserColourScheme(value).findColour('A'));
\r
936 else if (key.equalsIgnoreCase("displayBoxes"))
\r
938 sg.setDisplayBoxes(Boolean.valueOf(value).booleanValue());
\r
940 else if (key.equalsIgnoreCase("displayText"))
\r
942 sg.setDisplayText(Boolean.valueOf(value).booleanValue());
\r
944 else if (key.equalsIgnoreCase("colourText"))
\r
946 sg.setColourText(Boolean.valueOf(value).booleanValue());
\r
948 else if (key.equalsIgnoreCase("textCol1"))
\r
950 sg.textColour = new UserColourScheme(value).findColour('A');
\r
952 else if (key.equalsIgnoreCase("textCol2"))
\r
954 sg.textColour2 = new UserColourScheme(value).findColour('A');
\r
956 else if (key.equalsIgnoreCase("textColThreshold"))
\r
958 sg.thresholdTextColour = Integer.parseInt(value);
\r
960 else if (key.equalsIgnoreCase("idColour"))
\r
962 // consider warning if colour doesn't resolve to a real colour
\r
963 sg.setIdColour((def = new UserColourScheme(value))
\r
966 else if (key.equalsIgnoreCase("hide"))
\r
968 // see bug https://mantis.lifesci.dundee.ac.uk/view.php?id=25847
\r
969 sg.setHidereps(true);
\r
971 else if (key.equalsIgnoreCase("hidecols"))
\r
973 // see bug https://mantis.lifesci.dundee.ac.uk/view.php?id=25847
\r
974 sg.setHideCols(true);
\r
976 sg.recalcConservation();
\r
985 void setBelowAlignment(AlignmentI al, StringTokenizer st)
\r
988 AlignmentAnnotation aa;
\r
989 while (st.hasMoreTokens())
\r
991 token = st.nextToken();
\r
992 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
994 aa = al.getAlignmentAnnotation()[i];
\r
995 if (aa.sequenceRef == refSeq && aa.label.equals(token))
\r
997 aa.belowAlignment = true;
\r
1003 void addAlignmentDetails(AlignmentI al, StringTokenizer st)
\r
1005 String keyValue, key, value;
\r
1006 while (st.hasMoreTokens())
\r
1008 keyValue = st.nextToken();
\r
1009 key = keyValue.substring(0, keyValue.indexOf("="));
\r
1010 value = keyValue.substring(keyValue.indexOf("=") + 1);
\r
1011 al.setProperty(key, value);
\r
1016 * Write annotations as a CSV file of the form 'label, value, value, ...' for
\r
1019 * @param annotations
\r
1020 * @return CSV file as a string.
\r
1022 public String printCSVAnnotations(AlignmentAnnotation[] annotations)
\r
1024 StringBuffer sp = new StringBuffer();
\r
1025 for (int i = 0; i < annotations.length; i++)
\r
1027 String atos = annotations[i].toString();
\r
1031 int cp = atos.indexOf("\n", p);
\r
1032 sp.append(annotations[i].label);
\r
1036 sp.append(atos.substring(p, cp + 1));
\r
1040 sp.append(atos.substring(p));
\r
1046 return sp.toString();
\r