}\r
\r
/**\r
- * DOCUMENT ME!\r
+ * The Application can render HTML, but the applet will\r
+ * remove HTML tags and replace links with %LINK%\r
+ * Both need to read links in HTML however\r
+ *\r
+ * @throws IOException DOCUMENT ME!\r
+ */\r
+ public boolean parse(AlignmentI align,\r
+ Hashtable colours,\r
+ boolean removeHTML)\r
+ {\r
+ return parse(align, colours, null, removeHTML);\r
+ }\r
+ /**\r
+ * The Application can render HTML, but the applet will\r
+ * remove HTML tags and replace links with %LINK%\r
+ * Both need to read links in HTML however\r
*\r
* @throws IOException DOCUMENT ME!\r
*/\r
- public boolean parse(AlignmentI align, Hashtable colours)\r
- throws IOException\r
+ public boolean parse(AlignmentI align,\r
+ Hashtable colours,\r
+ Hashtable featureLink,\r
+ boolean removeHTML)\r
{\r
String line = null;\r
try\r
float score;\r
StringTokenizer st;\r
SequenceFeature sf;\r
- String featureGroup = null;\r
+ String featureGroup = null, groupLink = null;\r
+ Hashtable typeLink = new Hashtable();\r
\r
boolean GFFFile = true;\r
\r
if (type.equalsIgnoreCase("startgroup"))\r
{\r
featureGroup = st.nextToken();\r
+ if (st.hasMoreElements())\r
+ {\r
+ groupLink = st.nextToken();\r
+ featureLink.put(featureGroup, groupLink);\r
+ }\r
}\r
else if (type.equalsIgnoreCase("endgroup"))\r
{\r
//but at present theres no way of showing more than 1 group\r
st.nextToken();\r
featureGroup = null;\r
+ groupLink = null;\r
}\r
else\r
{\r
UserColourScheme ucs = new UserColourScheme(st.nextToken());\r
colours.put(type, ucs.findColour("A"));\r
+ if (st.hasMoreElements())\r
+ {\r
+ String link = st.nextToken();\r
+ typeLink.put(type, link);\r
+ if(featureLink==null)\r
+ featureLink = new Hashtable();\r
+ featureLink.put(type, link);\r
+ }\r
+\r
}\r
continue;\r
}\r
\r
sf = new SequenceFeature(type, desc, "", start, end, featureGroup);\r
\r
- seq.getDatasetSequence().addSequenceFeature(sf);\r
+ seq.addSequenceFeature(sf);\r
+\r
+ if(groupLink!=null && removeHTML)\r
+ {\r
+ sf.addLink(groupLink);\r
+ sf.description += "%LINK%";\r
+ }\r
+ if(typeLink.containsKey(type) && removeHTML)\r
+ {\r
+ sf.addLink(typeLink.get(type).toString());\r
+ sf.description += "%LINK%";\r
+ }\r
+\r
+ parseDescriptionHTML(sf, removeHTML);\r
\r
//If we got here, its not a GFFFile\r
GFFFile = false;\r
{\r
System.out.println(line);\r
ex.printStackTrace();\r
- System.out.println("Error parsing groups file: " + ex +"\n"+line);\r
+ System.out.println("Error parsing feature file: " + ex +"\n"+line);\r
return false;\r
}\r
\r
return true;\r
-\r
}\r
\r
+ void parseDescriptionHTML(SequenceFeature sf, boolean removeHTML)\r
+ {\r
+ StringBuffer sb = new StringBuffer();\r
+ StringTokenizer st = new StringTokenizer(sf.getDescription(), "<");\r
+ String token, link;\r
+ while(st.hasMoreElements())\r
+ {\r
+ token = st.nextToken("<>");\r
+ if(token.equalsIgnoreCase("html") || token.startsWith("/"))\r
+ continue;\r
+\r
+ if(token.startsWith("a href="))\r
+ {\r
+ link = token.substring(token.indexOf("\"")+1, token.length()-1);\r
+ String label = st.nextToken("<>");\r
+ sf.addLink(label+"|"+link);\r
+ sb.append(label+"%LINK%");\r
+ }\r
+ else if(token.equalsIgnoreCase("br"))\r
+ sb.append("\n");\r
+ else\r
+ sb.append(token);\r
+ }\r
+\r
+ if(removeHTML)\r
+ sf.description = sb.toString();\r
+ }\r
\r
/**\r
* DOCUMENT ME!\r
\r
do\r
{\r
- if (groups.size() > 0)\r
+\r
+\r
+ if (groups.size() > 0 && groupIndex < groups.size())\r
{\r
group = groups.elementAt(groupIndex).toString();\r
out.append("\nSTARTGROUP\t" + group + "\n");\r
}\r
-\r
+ else\r
+ group = null;\r
\r
for (int i = 0; i < seqs.length; i++)\r
{\r
if (!visible.containsKey(next[j].type))\r
continue;\r
\r
- if (group != null && !next[j].featureGroup.equals(group))\r
+ if (group != null\r
+ && (next[j].featureGroup==null\r
+ || !next[j].featureGroup.equals(group))\r
+ )\r
+ continue;\r
+\r
+ if(group==null && next[j].featureGroup!=null)\r
continue;\r
\r
if(next[j].description==null || next[j].description.equals(""))\r
}\r
}\r
\r
- if(groups.size()>0)\r
+ if(group!=null)\r
{\r
out.append("ENDGROUP\t"+group+"\n");\r
+ groupIndex++;\r
}\r
+ else\r
+ break;\r
\r
- groupIndex++;\r
}\r
- while(groupIndex < groups.size());\r
+ while(groupIndex < groups.size()+1);\r
\r
\r
return out.toString();\r