X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FAnnotationFile.java;h=7f71df18f9bb06686b879766426cde6203dd9dec;hb=67b2671b1ded591a6f8eb7f13d319e58f993df77;hp=d9fd871cf31c7332667ddf8525aaa69e334b3a6d;hpb=574045b24991af25bbb25526fbb9abd3b92c3fac;p=jalview.git diff --git a/src/jalview/io/AnnotationFile.java b/src/jalview/io/AnnotationFile.java index d9fd871..7f71df1 100755 --- a/src/jalview/io/AnnotationFile.java +++ b/src/jalview/io/AnnotationFile.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) - * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1) + * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -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; } } @@ -259,6 +261,7 @@ public class AnnotationFile String key = en.nextElement().toString(); text.append("\t" + key + "=" + properties.get(key)); } + // TODO: output alignment visualization settings here if required } @@ -268,12 +271,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"); @@ -305,7 +319,7 @@ public class AnnotationFile text.append("displayBoxes=" + sg.getDisplayBoxes() + "\t"); text.append("displayText=" + sg.getDisplayText() + "\t"); text.append("colourText=" + sg.getColourText() + "\t"); - + text.append("showUnconserved="+sg.getShowunconserved()+"\t"); if (sg.textColour != java.awt.Color.black) { text.append("textCol1=" @@ -318,14 +332,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"); } @@ -413,6 +439,7 @@ public class AnnotationFile token = st.nextToken(); if (token.equalsIgnoreCase("COLOUR")) { + // TODO: use graduated colour def'n here too colourAnnotations(al, st.nextToken(), st.nextToken()); continue; } @@ -752,13 +779,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 +857,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) @@ -891,6 +939,10 @@ public class AnnotationFile { sg.setDisplayBoxes(Boolean.valueOf(value).booleanValue()); } + else if (key.equalsIgnoreCase("showUnconserved")) + { + sg.setShowunconserved(Boolean.valueOf(value).booleanValue()); + } else if (key.equalsIgnoreCase("displayText")) { sg.setDisplayText(Boolean.valueOf(value).booleanValue()); @@ -917,6 +969,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)