import java.util.*;\r
import java.net.URL;\r
import jalview.schemes.*;\r
+import jalview.analysis.Conservation;\r
\r
\r
public class AnnotationFile\r
{\r
-\r
- public String printAnnotations(AlignmentAnnotation [] annotations)\r
- {\r
- StringBuffer text = new StringBuffer(\r
- "JALVIEW_ANNOTATION\n"\r
- +"# Created: "\r
+ StringBuffer text = new StringBuffer(\r
+ "JALVIEW_ANNOTATION\n"\r
+ +"# Created: "\r
+new java.util.Date()+"\n\n");\r
\r
- AlignmentAnnotation row;\r
- String comma;\r
- SequenceI seqref = null;\r
-\r
- StringBuffer colours = new StringBuffer();\r
- StringBuffer graphLine = new StringBuffer();\r
+ public String printAnnotations(AlignmentAnnotation [] annotations,\r
+ Vector groups)\r
+ {\r
+ if(annotations!=null)\r
+ {\r
+ AlignmentAnnotation row;\r
+ String comma;\r
+ SequenceI seqref = null;\r
\r
- Hashtable graphGroup = new Hashtable();\r
+ StringBuffer colours = new StringBuffer();\r
+ StringBuffer graphLine = new StringBuffer();\r
\r
- java.awt.Color color;\r
+ Hashtable graphGroup = new Hashtable();\r
\r
- for(int i=0; i<annotations.length; i++)\r
- {\r
- row = annotations[i];\r
+ java.awt.Color color;\r
\r
- if(!row.visible)\r
- continue;\r
+ for (int i = 0; i < annotations.length; i++)\r
+ {\r
+ row = annotations[i];\r
\r
- color = null;\r
+ if (!row.visible)\r
+ continue;\r
\r
- if( row.sequenceRef == null)\r
- {\r
- if(seqref!=null)\r
- text.append("\nSEQUENCE_REF\tALIGNMENT\n");\r
+ color = null;\r
\r
- seqref = null;\r
- }\r
+ if (row.sequenceRef == null)\r
+ {\r
+ if (seqref != null)\r
+ text.append("\nSEQUENCE_REF\tALIGNMENT\n");\r
\r
- else if (seqref == null || seqref != row.sequenceRef)\r
- {\r
- seqref = row.sequenceRef;\r
- text.append("\nSEQUENCE_REF\t" + seqref.getName() + "\n");\r
- }\r
+ seqref = null;\r
+ }\r
\r
+ else if (seqref == null || seqref != row.sequenceRef)\r
+ {\r
+ seqref = row.sequenceRef;\r
+ text.append("\nSEQUENCE_REF\t" + seqref.getName() + "\n");\r
+ }\r
\r
- if( row.graph == AlignmentAnnotation.NO_GRAPH)\r
- {\r
+ if (row.graph == AlignmentAnnotation.NO_GRAPH)\r
+ {\r
text.append("NO_GRAPH\t");\r
- }\r
- else\r
- {\r
- if( row.graph == AlignmentAnnotation.BAR_GRAPH)\r
- text.append("BAR_GRAPH\t");\r
- else if(row.graph == AlignmentAnnotation.LINE_GRAPH)\r
- text.append("LINE_GRAPH\t");\r
+ }\r
+ else\r
+ {\r
+ if (row.graph == AlignmentAnnotation.BAR_GRAPH)\r
+ text.append("BAR_GRAPH\t");\r
+ else if (row.graph == AlignmentAnnotation.LINE_GRAPH)\r
+ text.append("LINE_GRAPH\t");\r
\r
- if(row.getThreshold()!=null)\r
+ if (row.getThreshold() != null)\r
graphLine.append("GRAPHLINE\t"\r
+ row.label + "\t"\r
+ row.getThreshold().value + "\t"\r
+ row.getThreshold().label + "\t"\r
+ jalview.util.Format.getHexString(\r
- row.getThreshold().colour)+"\n"\r
+ row.getThreshold().colour) + "\n"\r
);\r
\r
- if(row.graphGroup>-1)\r
+ if (row.graphGroup > -1)\r
{\r
String key = String.valueOf(row.graphGroup);\r
- if(graphGroup.containsKey(key))\r
+ if (graphGroup.containsKey(key))\r
graphGroup.put(key, graphGroup.get(key)\r
- +"\t"+row.label);\r
+ + "\t" + row.label);\r
else\r
graphGroup.put(key, row.label);\r
}\r
- }\r
-\r
- text.append(row.label+"\t");\r
- if(row.description!=null)\r
- text.append(row.description+"\t");\r
+ }\r
\r
- for(int j=0; j<row.annotations.length; j++)\r
- {\r
- if (seqref != null && jalview.util.Comparison.isGap(seqref.getCharAt(j)))\r
- continue;\r
+ text.append(row.label + "\t");\r
+ if (row.description != null)\r
+ text.append(row.description + "\t");\r
\r
- if(row.annotations[j]!=null)\r
+ for (int j = 0; j < row.annotations.length; j++)\r
{\r
- comma = "";\r
- if (row.annotations[j].secondaryStructure!=' ')\r
- {\r
- text.append(comma + row.annotations[j].secondaryStructure);\r
- comma = ",";\r
- }\r
- if (row.annotations[j].displayCharacter.length() > 0\r
- && !row.annotations[j].displayCharacter.equals(" "))\r
- {\r
- text.append(comma + row.annotations[j].displayCharacter);\r
- comma = ",";\r
- }\r
-\r
- if (row.annotations[j]!=null)\r
+ if (seqref != null &&\r
+ jalview.util.Comparison.isGap(seqref.getCharAt(j)))\r
+ continue;\r
+\r
+ if (row.annotations[j] != null)\r
{\r
- color = row.annotations[j].colour;\r
- if (row.annotations[j].value!=0f)\r
- text.append(comma + row.annotations[j].value);\r
+ comma = "";\r
+ if (row.annotations[j].secondaryStructure != ' ')\r
+ {\r
+ text.append(comma + row.annotations[j].secondaryStructure);\r
+ comma = ",";\r
+ }\r
+ if (row.annotations[j].displayCharacter.length() > 0\r
+ && !row.annotations[j].displayCharacter.equals(" "))\r
+ {\r
+ text.append(comma + row.annotations[j].displayCharacter);\r
+ comma = ",";\r
+ }\r
+\r
+ if (row.annotations[j] != null)\r
+ {\r
+ color = row.annotations[j].colour;\r
+ if (row.annotations[j].value != 0f)\r
+ text.append(comma + row.annotations[j].value);\r
+ }\r
}\r
+ text.append("|");\r
}\r
- text.append("|");\r
+\r
+ text.append("\n");\r
+\r
+ if (color != null && color != java.awt.Color.black)\r
+ {\r
+ colours.append("COLOUR\t"\r
+ + row.label + "\t"\r
+ + jalview.util.Format.getHexString(color) + "\n");\r
+ }\r
+\r
}\r
\r
text.append("\n");\r
\r
- if(color!=null && color!=java.awt.Color.black)\r
+ text.append(colours.toString());\r
+ text.append(graphLine.toString());\r
+ if (graphGroup.size() > 0)\r
{\r
- colours.append("COLOUR\t"\r
- +row.label+"\t"\r
- +jalview.util.Format.getHexString(color)+"\n");\r
+ text.append("COMBINE\t");\r
+ Enumeration en = graphGroup.elements();\r
+ while (en.hasMoreElements())\r
+ {\r
+ text.append(en.nextElement() + "\n");\r
+ }\r
}\r
+ }\r
+\r
\r
+ if(groups!=null)\r
+ {\r
+ printGroups(groups);\r
}\r
\r
- text.append("\n");\r
+ return text.toString();\r
+ }\r
\r
- text.append(colours.toString());\r
- text.append(graphLine.toString());\r
- if(graphGroup.size()>0)\r
+\r
+ public void printGroups(Vector sequenceGroups)\r
+ {\r
+ SequenceGroup sg;\r
+ for (int i = 0; i < sequenceGroups.size(); i++)\r
{\r
- text.append("COMBINE\t");\r
- Enumeration en = graphGroup.elements();\r
- while(en.hasMoreElements())\r
+ sg = (SequenceGroup) sequenceGroups.elementAt(i);\r
+ text.append("SEQUENCE_GROUP\t"\r
+ + sg.getName() + "\t"\r
+ + (sg.getStartRes()+1) + "\t"\r
+ + (sg.getEndRes()+1) + "\t" + "-1\t");\r
+ for(int s=0; s<sg.getSize(); s++)\r
{\r
- text.append(en.nextElement()+"\n");\r
+ text.append(sg.getSequenceAt(s).getName()+"\t");\r
}\r
- }\r
\r
- return text.toString();\r
+ text.append("\nPROPERTIES\t"+sg.getName()+"\t");\r
+\r
+ if(sg.getDescription()!=null)\r
+ text.append("description="+sg.getDescription()+"\t");\r
+ if(sg.cs!=null)\r
+ {\r
+ text.append("colour="+ColourSchemeProperty.getColourName(sg.cs)+"\t");\r
+ if(sg.cs.getThreshold()!=0)\r
+ text.append("pidThreshold="+sg.cs.getThreshold());\r
+ if(sg.cs.conservationApplied())\r
+ text.append("consThreshold="+sg.cs.getConservationInc()+"\t");\r
+ }\r
+ text.append("outlineColour="+\r
+ jalview.util.Format.getHexString(sg.getOutlineColour())+"\t");\r
+\r
+ text.append("displayBoxes=" + sg.getDisplayBoxes() + "\t");\r
+ text.append("displayText=" + sg.getDisplayText() + "\t");\r
+ text.append("colourText=" + sg.getColourText() + "\t");\r
+\r
+ if (sg.textColour != java.awt.Color.black)\r
+ text.append("textCol1=" +\r
+ jalview.util.Format.getHexString(sg.textColour) + "\t");\r
+ if (sg.textColour2 != java.awt.Color.white)\r
+ text.append("textCol2=" +\r
+ jalview.util.Format.getHexString(sg.textColour2) + "\t");\r
+ if(sg.thresholdTextColour!=0)\r
+ text.append("textColThreshold="+sg.thresholdTextColour);\r
+\r
+ text.append("\n\n");\r
+\r
+ }\r
}\r
\r
\r
sg.setEndRes( refSeq.findIndex( sg.getEndRes() +1) -1 );\r
}\r
\r
-\r
al.addGroup(sg);\r
annotationsHash.put(sg.getName(), sg);\r
}\r
else if(key.equalsIgnoreCase("colour"))\r
sg.cs = ColourSchemeProperty.getColour(al, value);\r
else if (key.equalsIgnoreCase("pidThreshold"))\r
- sg.cs.setThreshold(Integer.parseInt(value), false);//\r
+ {\r
+ sg.cs.setThreshold(Integer.parseInt(value), true);\r
+\r
+ }\r
+ else if (key.equalsIgnoreCase("consThreshold"))\r
+ {\r
+ sg.cs.setConservationInc(Integer.parseInt(value));\r
+ Conservation c = new Conservation("Group",\r
+ ResidueProperties.propHash, 3,\r
+ sg.getSequences(null),\r
+ sg.getStartRes(),\r
+ sg.getEndRes() + 1);\r
+\r
+ c.calculate();\r
+ c.verdict(false, 25);\r
+\r
+ sg.cs.setConservation(c);\r
+\r
+ }\r
else if (key.equalsIgnoreCase("outlineColour"))\r
{\r
sg.setOutlineColour(new UserColourScheme(value).findColour('A'));\r
}\r
-\r
- //Boolean.valueOf(string).booleanValue();\r
else if (key.equalsIgnoreCase("displayBoxes"))\r
sg.setDisplayBoxes( Boolean.valueOf(value).booleanValue() );\r
else if (key.equalsIgnoreCase("displayText"))\r
else if (key.equalsIgnoreCase("textColThreshold"))\r
sg.thresholdTextColour = Integer.parseInt(value);\r
\r
+ sg.recalcConservation();\r
}\r
}\r
}\r