/*\r
* Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
*\r
* This program is free software; you can redistribute it and/or\r
* modify it under the terms of the GNU General Public License\r
package jalview.io;\r
\r
import java.io.*;\r
-import jalview.datamodel.*;\r
+import java.net.*;\r
import java.util.*;\r
-import jalview.schemes.UserColourScheme;\r
-import java.net.URL;\r
\r
+import jalview.analysis.*;\r
+import jalview.datamodel.*;\r
+import jalview.schemes.*;\r
\r
public class AnnotationFile\r
{\r
+ StringBuffer text = new StringBuffer(\r
+ "JALVIEW_ANNOTATION\n"\r
+ + "# Created: "\r
+ + new java.util.Date() + "\n\n");\r
\r
- public String printAnnotations(AlignmentAnnotation [] annotations)\r
+ public String printAnnotations(AlignmentAnnotation[] annotations,\r
+ Vector groups)\r
{\r
- StringBuffer text = new StringBuffer(\r
- "JALVIEW_ANNOTATION\n"\r
- +"# Created: "\r
- +new java.util.Date()+"\n\n");\r
+ if (annotations != null)\r
+ {\r
+ AlignmentAnnotation row;\r
+ String comma;\r
+ SequenceI seqref = null;\r
\r
- AlignmentAnnotation row;\r
- String comma;\r
- String seqref = null;\r
+ StringBuffer colours = new StringBuffer();\r
+ StringBuffer graphLine = new StringBuffer();\r
\r
- StringBuffer colours = new StringBuffer();\r
- StringBuffer graphLine = new StringBuffer();\r
+ Hashtable graphGroup = new Hashtable();\r
\r
- Hashtable graphGroup = new Hashtable();\r
+ java.awt.Color color;\r
\r
- java.awt.Color color;\r
+ for (int i = 0; i < annotations.length; i++)\r
+ {\r
+ row = annotations[i];\r
\r
- for(int i=0; i<annotations.length; i++)\r
- {\r
- row = annotations[i];\r
- color = null;\r
+ if (!row.visible)\r
+ {\r
+ continue;\r
+ }\r
\r
- if( row.sequenceRef == null)\r
- seqref = null;\r
+ color = null;\r
\r
- else if (seqref == null\r
- || !seqref.equals(row.sequenceRef.getName()))\r
- {\r
- seqref = row.sequenceRef.getName();\r
- text.append("\nSEQUENCE_REF\t" + seqref + "\n");\r
- }\r
+ if (row.sequenceRef == null)\r
+ {\r
+ if (seqref != null)\r
+ {\r
+ text.append("\nSEQUENCE_REF\tALIGNMENT\n");\r
+ }\r
\r
+ seqref = null;\r
+ }\r
\r
- if( row.graph == AlignmentAnnotation.NO_GRAPH)\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
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
+ {\r
+ text.append("BAR_GRAPH\t");\r
+ }\r
+ else if (row.graph == AlignmentAnnotation.LINE_GRAPH)\r
+ {\r
+ text.append("LINE_GRAPH\t");\r
+ }\r
\r
- if(row.getThreshold()!=null)\r
+ if (row.getThreshold() != null)\r
+ {\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
\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
+ {\r
graphGroup.put(key, graphGroup.get(key)\r
- +"\t"+row.label);\r
+ + "\t" + row.label);\r
+ }\r
else\r
+ {\r
graphGroup.put(key, row.label);\r
+ }\r
}\r
- }\r
+ }\r
\r
- text.append(row.label+"\t");\r
+ text.append(row.label + "\t");\r
+ if (row.description != null)\r
+ {\r
+ text.append(row.description + "\t");\r
+ }\r
\r
- for(int j=0; j<row.annotations.length; j++)\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].displayCharacter.length() > 0\r
- && !row.annotations[j].displayCharacter.equals(" "))\r
- {\r
- text.append(row.annotations[j].displayCharacter);\r
- comma = ",";\r
- }\r
- if (row.annotations[j].secondaryStructure!=' ')\r
+ if (seqref != null &&\r
+ jalview.util.Comparison.isGap(seqref.getCharAt(j)))\r
{\r
- text.append(comma + row.annotations[j].secondaryStructure);\r
- comma = ",";\r
+ continue;\r
}\r
- if (row.annotations[j].value!=0f)\r
+\r
+ if (row.annotations[j] != null)\r
{\r
- color = row.annotations[j].colour;\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
+ {\r
+ text.append(comma + row.annotations[j].value);\r
+ }\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
+ 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
+ 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
+ {\r
+ text.append("description=" + sg.getDescription() + "\t");\r
+ }\r
+ if (sg.cs != null)\r
+ {\r
+ text.append("colour=" + ColourSchemeProperty.getColourName(sg.cs) +\r
+ "\t");\r
+ if (sg.cs.getThreshold() != 0)\r
+ {\r
+ text.append("pidThreshold=" + sg.cs.getThreshold());\r
+ }\r
+ if (sg.cs.conservationApplied())\r
+ {\r
+ text.append("consThreshold=" + sg.cs.getConservationInc() + "\t");\r
+ }\r
+ }\r
+ text.append("outlineColour=" +\r
+ jalview.util.Format.getHexString(sg.getOutlineColour()) +\r
+ "\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
+ {\r
+ text.append("textCol1=" +\r
+ jalview.util.Format.getHexString(sg.textColour) + "\t");\r
+ }\r
+ if (sg.textColour2 != java.awt.Color.white)\r
+ {\r
+ text.append("textCol2=" +\r
+ jalview.util.Format.getHexString(sg.textColour2) + "\t");\r
+ }\r
+ if (sg.thresholdTextColour != 0)\r
+ {\r
+ text.append("textColThreshold=" + sg.thresholdTextColour);\r
+ }\r
+\r
+ text.append("\n\n");\r
+\r
+ }\r
}\r
\r
- public boolean readAnnotationFile(AlignmentI al, String file)\r
+ SequenceI refSeq = null;\r
+ public boolean readAnnotationFile(AlignmentI al,\r
+ String file,\r
+ String protocol)\r
{\r
try\r
{\r
BufferedReader in = null;\r
- java.io.InputStream is = getClass().getResourceAsStream("/" + file);\r
- if (is != null)\r
+ if (protocol.equals(AppletFormatAdapter.FILE))\r
{\r
- in = new BufferedReader(new java.io.InputStreamReader(is));\r
+ in = new BufferedReader(new FileReader(file));\r
}\r
- else\r
+ else if (protocol.equals(AppletFormatAdapter.URL))\r
{\r
- try\r
- {\r
- URL url = new URL(file);\r
- in = new BufferedReader(new InputStreamReader(url.openStream()));\r
- }\r
- catch (java.net.MalformedURLException ex)\r
+ URL url = new URL(file);\r
+ in = new BufferedReader(new InputStreamReader(url.openStream()));\r
+ }\r
+ else if (protocol.equals(AppletFormatAdapter.PASTE))\r
+ {\r
+ in = new BufferedReader(new StringReader(file));\r
+ }\r
+ else if (protocol.equals(AppletFormatAdapter.CLASSLOADER))\r
+ {\r
+ java.io.InputStream is = getClass().getResourceAsStream("/" + file);\r
+ if (is != null)\r
{\r
- in = new BufferedReader(new FileReader(file));\r
+ in = new BufferedReader(new java.io.InputStreamReader(is));\r
}\r
}\r
\r
String line, label, description, token;\r
int graphStyle, index;\r
- SequenceI refSeq = null;\r
int refSeqIndex = 1;\r
int existingAnnotations = 0;\r
- if(al.getAlignmentAnnotation()!=null)\r
- existingAnnotations = al.getAlignmentAnnotation().length;\r
+ if (al.getAlignmentAnnotation() != null)\r
+ {\r
+ existingAnnotations = al.getAlignmentAnnotation().length;\r
+ }\r
\r
int alWidth = al.getWidth();\r
\r
boolean jvAnnotationFile = false;\r
while ( (line = in.readLine()) != null)\r
{\r
- if (line.indexOf("#") == 0 )\r
+ if (line.indexOf("#") == 0)\r
+ {\r
continue;\r
+ }\r
\r
if (line.indexOf("JALVIEW_ANNOTATION") > -1)\r
{\r
}\r
}\r
\r
- if(!jvAnnotationFile)\r
+ if (!jvAnnotationFile)\r
{\r
in.close();\r
return false;\r
\r
while ( (line = in.readLine()) != null)\r
{\r
- if(line.indexOf("#")==0\r
- || line.indexOf("JALVIEW_ANNOTATION")>-1\r
- || line.length()==0)\r
+ if (line.indexOf("#") == 0\r
+ || line.indexOf("JALVIEW_ANNOTATION") > -1\r
+ || line.length() == 0)\r
+ {\r
continue;\r
+ }\r
\r
st = new StringTokenizer(line, "\t");\r
token = st.nextToken();\r
- if(token.equalsIgnoreCase("COLOUR"))\r
+ if (token.equalsIgnoreCase("COLOUR"))\r
{\r
colourAnnotations(al, st.nextToken(), st.nextToken());\r
continue;\r
}\r
\r
- if(token.equalsIgnoreCase("COMBINE") )\r
+ else if (token.equalsIgnoreCase("COMBINE"))\r
{\r
combineAnnotations(al, st);\r
continue;\r
}\r
\r
- if (token.equalsIgnoreCase("GRAPHLINE"))\r
+ else if (token.equalsIgnoreCase("GRAPHLINE"))\r
{\r
addLine(al, st);\r
continue;\r
}\r
\r
-\r
- if(token.equalsIgnoreCase("SEQUENCE_REF") )\r
+ else if (token.equalsIgnoreCase("SEQUENCE_REF"))\r
{\r
refSeq = al.findName(st.nextToken());\r
- try{\r
+ try\r
+ {\r
refSeqIndex = Integer.parseInt(st.nextToken());\r
+ if (refSeqIndex < 1)\r
+ {\r
+ refSeqIndex = 1;\r
+ System.out.println(\r
+ "WARNING: SEQUENCE_REF index must be > 0 in AnnotationFile");\r
+ }\r
}\r
- catch(Exception ex)\r
+ catch (Exception ex)\r
{\r
refSeqIndex = 1;\r
}\r
\r
+ continue ;\r
+ }\r
+\r
+ else if (token.equalsIgnoreCase("SEQUENCE_GROUP"))\r
+ {\r
+ addGroup(al, st);\r
continue;\r
}\r
\r
+ else if (token.equalsIgnoreCase("PROPERTIES"))\r
+ {\r
+ addProperties(al, st);\r
+ continue;\r
+ }\r
\r
graphStyle = AlignmentAnnotation.getGraphValueFromString(token);\r
- label = description = st.nextToken();\r
+ label = st.nextToken();\r
+\r
+ if (st.countTokens() > 1)\r
+ {\r
+ description = st.nextToken();\r
+ }\r
+ else\r
+ {\r
+ description = null;\r
+ }\r
\r
line = st.nextToken();\r
\r
index = 0;\r
boolean emptyColumn = true;\r
\r
-\r
- while (st.hasMoreElements() && index<alWidth)\r
+ while (st.hasMoreElements() && index < alWidth)\r
{\r
token = st.nextToken().trim();\r
- if(token.equals("|"))\r
+ if (token.equals("|"))\r
{\r
- if(emptyColumn)\r
+ if (emptyColumn)\r
+ {\r
index++;\r
+ }\r
\r
emptyColumn = true;\r
}\r
}\r
}\r
\r
- annotation = new AlignmentAnnotation(label,\r
- description,\r
- annotations,\r
- 0,\r
- 0,\r
- graphStyle);\r
+ annotation = new AlignmentAnnotation(label,\r
+ description,\r
+ annotations,\r
+ 0,\r
+ 0,\r
+ graphStyle);\r
\r
- if(refSeq!=null)\r
- {\r
- annotation.createSequenceMapping(refSeq, refSeqIndex);\r
- refSeq.addAlignmentAnnotation(annotation);\r
- }\r
+ if (refSeq != null)\r
+ {\r
+ annotation.createSequenceMapping(refSeq, refSeqIndex, false);\r
+ refSeq.addAlignmentAnnotation(annotation);\r
+ }\r
\r
- al.addAnnotation(annotation);\r
+ al.addAnnotation(annotation);\r
\r
- al.setAnnotationIndex(annotation, al.getAlignmentAnnotation().length - existingAnnotations-1);\r
+ al.setAnnotationIndex(annotation,\r
+ al.getAlignmentAnnotation().length - existingAnnotations -\r
+ 1);\r
}\r
\r
- }catch(Exception ex)\r
+ }\r
+ catch (Exception ex)\r
{\r
ex.printStackTrace();\r
- System.out.println("Problem reading annotation file: "+ex);\r
+ System.out.println("Problem reading annotation file: " + ex);\r
return false;\r
}\r
return true;\r
\r
Annotation parseAnnotation(String string)\r
{\r
- String desc = "", displayChar="";\r
+ String desc = null, displayChar = "";\r
char ss = ' '; // secondaryStructure\r
float value = 0;\r
boolean parsedValue = false;\r
StringTokenizer st = new StringTokenizer(string, ",");\r
String token;\r
- while(st.hasMoreTokens())\r
+ while (st.hasMoreTokens())\r
{\r
token = st.nextToken().trim();\r
- if(token.length()==0)\r
+ if (token.length() == 0)\r
+ {\r
continue;\r
+ }\r
\r
- if(!parsedValue)\r
+ if (!parsedValue)\r
{\r
- try{\r
+ try\r
+ {\r
displayChar = token;\r
value = new Float(token).floatValue();\r
parsedValue = true;\r
- }catch(NumberFormatException ex){}\r
+ continue;\r
+ }\r
+ catch (NumberFormatException ex)\r
+ {}\r
}\r
\r
- if(token.equals("H") || token.equals("E"))\r
+ if (token.equals("H") || token.equals("E"))\r
{\r
// Either this character represents a helix or sheet\r
// or an integer which can be displayed\r
ss = token.charAt(0);\r
- displayChar = "";\r
+ if (displayChar.equals(token.substring(0, 1)))\r
+ {\r
+ displayChar = "";\r
+ }\r
}\r
- else if(desc.length()<1)\r
+ else if (desc == null)\r
+ {\r
desc = token;\r
+ }\r
+\r
+ }\r
\r
+ if (desc == null)\r
+ {\r
+ desc = value + "";\r
+ }\r
+\r
+ if (displayChar.length() > 1 && desc.length() == 1)\r
+ {\r
+ String tmp = displayChar;\r
+ displayChar = desc;\r
+ desc = tmp;\r
}\r
\r
return new Annotation(displayChar, desc, ss, value);\r
{\r
UserColourScheme ucs = new UserColourScheme(colour);\r
Annotation[] annotations;\r
- for(int i=0; i<al.getAlignmentAnnotation().length; i++)\r
+ for (int i = 0; i < al.getAlignmentAnnotation().length; i++)\r
{\r
- if(al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(label))\r
+ if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(label))\r
{\r
annotations = al.getAlignmentAnnotation()[i].annotations;\r
- for(int j=0; j<annotations.length; j++)\r
+ for (int j = 0; j < annotations.length; j++)\r
{\r
- if(annotations[j]!=null)\r
- annotations[j].colour = ucs.findColour("A");\r
+ if (annotations[j] != null)\r
+ {\r
+ annotations[j].colour = ucs.findColour('A');\r
+ }\r
}\r
}\r
}\r
int graphGroup = -1;\r
String group = st.nextToken();\r
//First make sure we are not overwriting the graphIndex\r
- for(int i=0; i<al.getAlignmentAnnotation().length; i++)\r
+ for (int i = 0; i < al.getAlignmentAnnotation().length; i++)\r
{\r
- if(al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(group))\r
+ if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(group))\r
{\r
- graphGroup = al.getAlignmentAnnotation()[i].graphGroup +1;\r
+ graphGroup = al.getAlignmentAnnotation()[i].graphGroup + 1;\r
al.getAlignmentAnnotation()[i].graphGroup = graphGroup;\r
break;\r
}\r
}\r
\r
//Now update groups\r
- while(st.hasMoreTokens())\r
+ while (st.hasMoreTokens())\r
{\r
group = st.nextToken();\r
- for(int i=0; i<al.getAlignmentAnnotation().length; i++)\r
+ for (int i = 0; i < al.getAlignmentAnnotation().length; i++)\r
{\r
if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(group))\r
{\r
}\r
}\r
\r
- if(annotation==null)\r
+ if (annotation == null)\r
+ {\r
return;\r
+ }\r
float value = new Float(st.nextToken()).floatValue();\r
- String label = st.hasMoreTokens() ? st.nextToken() : null;\r
+ String label = st.hasMoreTokens() ? st.nextToken() : null;\r
java.awt.Color colour = null;\r
- if(st.hasMoreTokens())\r
+ if (st.hasMoreTokens())\r
{\r
UserColourScheme ucs = new UserColourScheme(st.nextToken());\r
- colour = ucs.findColour("A");\r
+ colour = ucs.findColour('A');\r
}\r
\r
annotation.setThreshold(new GraphLine(value, label, colour));\r
+ }\r
+\r
+ void addGroup(AlignmentI al, StringTokenizer st)\r
+ {\r
+ SequenceGroup sg = new SequenceGroup();\r
+ sg.setName(st.nextToken());\r
+ sg.setStartRes(Integer.parseInt(st.nextToken()) - 1);\r
+ sg.setEndRes(Integer.parseInt(st.nextToken()) - 1);\r
+\r
+ String index = st.nextToken();\r
+ if (index.equals("-1"))\r
+ {\r
+ while (st.hasMoreElements())\r
+ {\r
+ sg.addSequence(al.findName(st.nextToken()), false);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ StringTokenizer st2 = new StringTokenizer(index, ",");\r
+\r
+ while (st2.hasMoreTokens())\r
+ {\r
+ String tmp = st2.nextToken();\r
+ if (tmp.equals("*"))\r
+ {\r
+ for (int i = 0; i < al.getHeight(); i++)\r
+ {\r
+ sg.addSequence(al.getSequenceAt(i), false);\r
+ }\r
+ }\r
+ else if (tmp.indexOf("-") >= 0)\r
+ {\r
+ StringTokenizer st3 = new StringTokenizer(tmp, "-");\r
+\r
+ int start = (Integer.parseInt(st3.nextToken()));\r
+ int end = (Integer.parseInt(st3.nextToken()));\r
+\r
+ if (end > start)\r
+ {\r
+ for (int i = start; i <= end; i++)\r
+ {\r
+ sg.addSequence(al.getSequenceAt(i - 1), false);\r
+ }\r
+ }\r
+ }\r
+ else\r
+ {\r
+ sg.addSequence(al.getSequenceAt(Integer.parseInt(tmp) - 1), false);\r
+ }\r
+ }\r
+ }\r
+\r
+ if (refSeq != null)\r
+ {\r
+ sg.setStartRes(refSeq.findIndex(sg.getStartRes() + 1) - 1);\r
+ sg.setEndRes(refSeq.findIndex(sg.getEndRes() + 1) - 1);\r
+ }\r
\r
+ if (sg.getSize() > 0)\r
+ {\r
+ al.addGroup(sg);\r
+ }\r
+ }\r
+\r
+ void addProperties(AlignmentI al, StringTokenizer st)\r
+ {\r
+\r
+ //So far we have only added groups to the annotationHash,\r
+ //the idea is in the future properties can be added to\r
+ //alignments, other annotations etc\r
+ if (al.getGroups() == null)\r
+ {\r
+ return;\r
+ }\r
+ SequenceGroup sg = null;\r
+\r
+ String name = st.nextToken();\r
+\r
+ Vector groups = al.getGroups();\r
+ for (int i = 0; i < groups.size(); i++)\r
+ {\r
+ sg = (SequenceGroup) groups.elementAt(i);\r
+ if (sg.getName().equals(name))\r
+ {\r
+ break;\r
+ }\r
+ else\r
+ {\r
+ sg = null;\r
+ }\r
+ }\r
+\r
+ if (sg != null)\r
+ {\r
+ String keyValue, key, value;\r
+ while (st.hasMoreTokens())\r
+ {\r
+ keyValue = st.nextToken();\r
+ key = keyValue.substring(0, keyValue.indexOf("="));\r
+ value = keyValue.substring(keyValue.indexOf("=") + 1);\r
+\r
+ if (key.equalsIgnoreCase("description"))\r
+ {\r
+ sg.setDescription(value);\r
+ }\r
+ else if (key.equalsIgnoreCase("colour"))\r
+ {\r
+ sg.cs = ColourSchemeProperty.getColour(al, value);\r
+ }\r
+ else if (key.equalsIgnoreCase("pidThreshold"))\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
+ else if (key.equalsIgnoreCase("displayBoxes"))\r
+ {\r
+ sg.setDisplayBoxes(Boolean.valueOf(value).booleanValue());\r
+ }\r
+ else if (key.equalsIgnoreCase("displayText"))\r
+ {\r
+ sg.setDisplayText(Boolean.valueOf(value).booleanValue());\r
+ }\r
+ else if (key.equalsIgnoreCase("colourText"))\r
+ {\r
+ sg.setColourText(Boolean.valueOf(value).booleanValue());\r
+ }\r
+ else if (key.equalsIgnoreCase("textCol1"))\r
+ {\r
+ sg.textColour = new UserColourScheme(value).findColour('A');\r
+ }\r
+ else if (key.equalsIgnoreCase("textCol2"))\r
+ {\r
+ sg.textColour2 = new UserColourScheme(value).findColour('A');\r
+ }\r
+ else if (key.equalsIgnoreCase("textColThreshold"))\r
+ {\r
+ sg.thresholdTextColour = Integer.parseInt(value);\r
+ }\r
+\r
+ sg.recalcConservation();\r
+ }\r
+ }\r
}\r
}\r