From: jprocter
textCol2=black
textColThreshold=0
- idColour=ff3322
An example Annotation file is given below: diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index dd842ea..bb075aa 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -46,12 +46,18 @@ public class SequenceGroup boolean displayText = true; boolean colourText = false; - + /** + * group members + */ private Vector sequences = new Vector(); - + /** + * representative sequence for this group (if any) + */ + private SequenceI seqrep = null; int width = -1; - /** DOCUMENT ME!! */ + /** + * Colourscheme applied to group if any */ public ColourSchemeI cs; int startRes = 0; @@ -680,4 +686,71 @@ public class SequenceGroup { this.idColour = idColour; } + + /** + * @return the representative sequence for this group + */ + public SequenceI getSeqrep() + { + return seqrep; + } + + /** + * set the representative sequence for this group. + * Note - this affects the interpretation of the Hidereps attribute. + * @param seqrep the seqrep to set (null means no sequence representative) + */ + public void setSeqrep(SequenceI seqrep) + { + this.seqrep = seqrep; + } + /** + * + * @return true if group has a sequence representative + */ + public boolean hasSeqrep() + { + return seqrep != null; + } + /** + * visibility of rows or represented rows covered by group + */ + private boolean hidereps=false; + /** + * set visibility of sequences covered by (if no sequence representative is defined) + * or represented by this group. + * @param visibility + */ + public void setHidereps(boolean visibility) + { + hidereps = visibility; + } + /** + * + * @return true if sequences represented (or covered) by this group should be hidden + */ + public boolean isHidereps() + { + return hidereps; + } + /** + * visibility of columns intersecting this group + */ + private boolean hidecols=false; + /** + * set intended visibility of columns covered by this group + * @param visibility + */ + public void setHideCols(boolean visibility) + { + hidecols = visibility; + } + /** + * + * @return true if columns covered by group should be hidden + */ + public boolean isHideCols() + { + return hidecols; + } } diff --git a/src/jalview/io/AnnotationFile.java b/src/jalview/io/AnnotationFile.java index d9fd871..1872f60 100755 --- a/src/jalview/io/AnnotationFile.java +++ b/src/jalview/io/AnnotationFile.java @@ -60,13 +60,15 @@ public class AnnotationFile public ColumnSelection hiddencols; public Vector visibleGroups; - + public Hashtable hiddenRepSeqs; + public ViewDef(String viewname, HiddenSequences hidseqs, - ColumnSelection hiddencols) + ColumnSelection hiddencols, Hashtable hiddenRepSeqs) { this.viewname = viewname; this.hidseqs = hidseqs; this.hiddencols = hiddencols; + this.hiddenRepSeqs = hiddenRepSeqs; } } @@ -268,12 +270,23 @@ public class AnnotationFile public void printGroups(Vector sequenceGroups) { SequenceGroup sg; + SequenceI seqrep=null; for (int i = 0; i < sequenceGroups.size(); i++) { sg = (SequenceGroup) sequenceGroups.elementAt(i); - text.append("SEQUENCE_GROUP\t" + sg.getName() + "\t" - + (sg.getStartRes() + 1) + "\t" + (sg.getEndRes() + 1) + "\t" - + "-1\t"); + if (!sg.hasSeqrep()) + { + text.append("SEQUENCE_GROUP\t" + sg.getName() + "\t" + + (sg.getStartRes() + 1) + "\t" + (sg.getEndRes() + 1) + "\t" + + "-1\t"); + seqrep = null; + } else { + seqrep = sg.getSeqrep(); + text.append("SEQUENCE_REF\t"+seqrep.getName()+"\n"); + text.append("SEQUENCE_GROUP\t" + sg.getName() + "\t" + + (seqrep.findPosition(sg.getStartRes())) + "\t" + (seqrep.findPosition(sg.getEndRes())) + "\t" + + "-1\t"); + } for (int s = 0; s < sg.getSize(); s++) { text.append(sg.getSequenceAt(s).getName() + "\t"); @@ -318,14 +331,26 @@ public class AnnotationFile } if (sg.thresholdTextColour != 0) { - text.append("textColThreshold=" + sg.thresholdTextColour); + text.append("textColThreshold=" + sg.thresholdTextColour+"\t"); } if (sg.idColour != null) { text.append("idColour=" + jalview.util.Format.getHexString(sg.idColour) + "\t"); } - + if (sg.isHidereps()) + { + text.append("hide=true\t"); + } + if (sg.isHideCols()) + { + text.append("hidecols=true\t"); + } + if (seqrep!=null) + { + // terminate the last line and clear the sequence ref for the group + text.append("\nSEQUENCE_REF"); + } text.append("\n\n"); } @@ -752,13 +777,33 @@ public class AnnotationFile annotation.setThreshold(new GraphLine(value, label, colour)); } - void addGroup(AlignmentI al, StringTokenizer st) { SequenceGroup sg = new SequenceGroup(); sg.setName(st.nextToken()); - sg.setStartRes(Integer.parseInt(st.nextToken()) - 1); - sg.setEndRes(Integer.parseInt(st.nextToken()) - 1); + String rng =""; + try { + rng = st.nextToken(); + if (rng.length()>0 && !rng.startsWith("*")) + { + sg.setStartRes(Integer.parseInt(rng) - 1); + } else { + sg.setStartRes(0); + } + rng = st.nextToken(); + if (rng.length()>0 && !rng.startsWith("*")) + { + sg.setEndRes(Integer.parseInt(rng) - 1); + } else { + sg.setEndRes(al.getWidth()-1); + } + } catch (Exception e) + { + 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."); + // assume group is full width + sg.setStartRes(0); + sg.setEndRes(al.getWidth()-1); + } String index = st.nextToken(); if (index.equals("-1")) @@ -810,6 +855,7 @@ public class AnnotationFile { sg.setStartRes(refSeq.findIndex(sg.getStartRes() + 1) - 1); sg.setEndRes(refSeq.findIndex(sg.getEndRes() + 1) - 1); + sg.setSeqrep(refSeq); } if (sg.getSize() > 0) @@ -917,6 +963,16 @@ public class AnnotationFile sg.setIdColour((def = new UserColourScheme(value)) .findColour('A')); } + else if (key.equalsIgnoreCase("hide")) + { + // see bug https://mantis.lifesci.dundee.ac.uk/view.php?id=25847 + sg.setHidereps(true); + } + else if (key.equalsIgnoreCase("hidecols")) + { + // see bug https://mantis.lifesci.dundee.ac.uk/view.php?id=25847 + sg.setHideCols(true); + } sg.recalcConservation(); } if (sg.cs == null)