X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FAnnotationFile.java;h=8ec234d12128745ff90f873ed3fa50611d9448c0;hb=dd74fc4938723fe5ec48d4e5fdcfbe58ac42a48d;hp=a7c67cd0638dd6b4520fbc588ee33cf5c02ed3f7;hpb=d70d7e5bc8da1189f44709b6ec59ea1e23f6f557;p=jalview.git diff --git a/src/jalview/io/AnnotationFile.java b/src/jalview/io/AnnotationFile.java index a7c67cd..8ec234d 100755 --- a/src/jalview/io/AnnotationFile.java +++ b/src/jalview/io/AnnotationFile.java @@ -24,149 +24,207 @@ import jalview.datamodel.*; import java.util.*; import java.net.URL; import jalview.schemes.*; +import jalview.analysis.Conservation; public class AnnotationFile { - - public String printAnnotations(AlignmentAnnotation [] annotations) - { - StringBuffer text = new StringBuffer( - "JALVIEW_ANNOTATION\n" - +"# Created: " + StringBuffer text = new StringBuffer( + "JALVIEW_ANNOTATION\n" + +"# Created: " +new java.util.Date()+"\n\n"); - AlignmentAnnotation row; - String comma; - SequenceI seqref = null; - - StringBuffer colours = new StringBuffer(); - StringBuffer graphLine = new StringBuffer(); + public String printAnnotations(AlignmentAnnotation [] annotations, + Vector groups) + { + if(annotations!=null) + { + AlignmentAnnotation row; + String comma; + SequenceI seqref = null; - Hashtable graphGroup = new Hashtable(); + StringBuffer colours = new StringBuffer(); + StringBuffer graphLine = new StringBuffer(); - java.awt.Color color; + Hashtable graphGroup = new Hashtable(); - for(int i=0; i-1) + if (row.graphGroup > -1) { String key = String.valueOf(row.graphGroup); - if(graphGroup.containsKey(key)) + if (graphGroup.containsKey(key)) graphGroup.put(key, graphGroup.get(key) - +"\t"+row.label); + + "\t" + row.label); else graphGroup.put(key, row.label); } - } - - text.append(row.label+"\t"); - if(row.description!=null) - text.append(row.description+"\t"); + } - for(int j=0; j 0 - && !row.annotations[j].displayCharacter.equals(" ")) - { - text.append(comma + row.annotations[j].displayCharacter); - comma = ","; - } - - if (row.annotations[j]!=null) + if (seqref != null && + jalview.util.Comparison.isGap(seqref.getCharAt(j))) + continue; + + if (row.annotations[j] != null) { - color = row.annotations[j].colour; - if (row.annotations[j].value!=0f) - text.append(comma + row.annotations[j].value); + comma = ""; + if (row.annotations[j].secondaryStructure != ' ') + { + text.append(comma + row.annotations[j].secondaryStructure); + comma = ","; + } + if (row.annotations[j].displayCharacter.length() > 0 + && !row.annotations[j].displayCharacter.equals(" ")) + { + text.append(comma + row.annotations[j].displayCharacter); + comma = ","; + } + + if (row.annotations[j] != null) + { + color = row.annotations[j].colour; + if (row.annotations[j].value != 0f) + text.append(comma + row.annotations[j].value); + } } + text.append("|"); } - text.append("|"); + + text.append("\n"); + + if (color != null && color != java.awt.Color.black) + { + colours.append("COLOUR\t" + + row.label + "\t" + + jalview.util.Format.getHexString(color) + "\n"); + } + } text.append("\n"); - if(color!=null && color!=java.awt.Color.black) + text.append(colours.toString()); + text.append(graphLine.toString()); + if (graphGroup.size() > 0) { - colours.append("COLOUR\t" - +row.label+"\t" - +jalview.util.Format.getHexString(color)+"\n"); + text.append("COMBINE\t"); + Enumeration en = graphGroup.elements(); + while (en.hasMoreElements()) + { + text.append(en.nextElement() + "\n"); + } } + } + + if(groups!=null) + { + printGroups(groups); } - text.append("\n"); + return text.toString(); + } + - text.append(colours.toString()); - text.append(graphLine.toString()); - if(graphGroup.size()>0) + public void printGroups(Vector sequenceGroups) + { + SequenceGroup sg; + for (int i = 0; i < sequenceGroups.size(); i++) { - text.append("COMBINE\t"); - Enumeration en = graphGroup.elements(); - while(en.hasMoreElements()) + sg = (SequenceGroup) sequenceGroups.elementAt(i); + text.append("SEQUENCE_GROUP\t" + + sg.getName() + "\t" + + (sg.getStartRes()+1) + "\t" + + (sg.getEndRes()+1) + "\t" + "-1\t"); + for(int s=0; s0) + { + al.addGroup(sg); + } } void addProperties(AlignmentI al, StringTokenizer st) @@ -540,7 +599,21 @@ public class AnnotationFile //So far we have only added groups to the annotationHash, //the idea is in the future properties can be added to //alignments, other annotations etc - SequenceGroup sg = (SequenceGroup)annotationsHash.get(st.nextToken()); + if(al.getGroups()==null) + return; + SequenceGroup sg = null; + + String name = st.nextToken(); + + Vector groups = al.getGroups(); + for(int i=0; i