X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFeaturesFile.java;h=2c0b6d7f7787c6ecb00e01501016e84fd1da3afa;hb=af381a3653ac5985d3ed6099f3f358a25abd82a9;hp=b3d434efe6565676531f46294a63014243f1d128;hpb=571c4270480e5fbf2e0ea543563f7b54e68eed82;p=jalview.git diff --git a/src/jalview/io/FeaturesFile.java b/src/jalview/io/FeaturesFile.java index b3d434e..2c0b6d7 100755 --- a/src/jalview/io/FeaturesFile.java +++ b/src/jalview/io/FeaturesFile.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle +* Copyright (C) 2006 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 @@ -40,15 +40,6 @@ public class FeaturesFile extends AlignFile { } - /** - * Creates a new FeaturesFile object. - * - * @param inStr DOCUMENT ME! - */ - public FeaturesFile(String inStr) - { - super(inStr); - } /** * Creates a new FeaturesFile object. @@ -134,7 +125,7 @@ public class FeaturesFile extends AlignFile else { UserColourScheme ucs = new UserColourScheme(st.nextToken()); - colours.put(type, ucs.findColour("A")); + colours.put(type, ucs.findColour('A')); if (st.hasMoreElements()) { String link = st.nextToken(); @@ -182,7 +173,17 @@ public class FeaturesFile extends AlignFile catch (Exception ex) {} - seq.getDatasetSequence().addSequenceFeature(sf); + if(st.hasMoreTokens()) + { + StringBuffer attributes = new StringBuffer(); + while (st.hasMoreTokens()) + { + attributes.append("\t"+st.nextElement()); + } + sf.setValue("ATTRIBUTES", attributes.toString()); + } + + seq.addSequenceFeature(sf); break; } @@ -229,7 +230,7 @@ public class FeaturesFile extends AlignFile { // Probably the old style groups file UserColourScheme ucs = new UserColourScheme(type); - colours.put(type, ucs.findColour("A")); + colours.put(type, ucs.findColour('A')); } sf = new SequenceFeature(type, desc, "", start, end, featureGroup); @@ -257,7 +258,6 @@ public class FeaturesFile extends AlignFile catch (Exception ex) { System.out.println(line); - ex.printStackTrace(); System.out.println("Error parsing feature file: " + ex +"\n"+line); return false; } @@ -265,32 +265,62 @@ public class FeaturesFile extends AlignFile return true; } - void parseDescriptionHTML(SequenceFeature sf, boolean removeHTML) + public void parseDescriptionHTML(SequenceFeature sf, boolean removeHTML) { + if(sf.getDescription()==null) + return; + + if(removeHTML && sf.getDescription().toUpperCase().indexOf("")==-1) + removeHTML = false; + StringBuffer sb = new StringBuffer(); StringTokenizer st = new StringTokenizer(sf.getDescription(), "<"); String token, link; + int startTag; + String tag=null; while(st.hasMoreElements()) { - token = st.nextToken("<>"); + token = st.nextToken("&>"); if(token.equalsIgnoreCase("html") || token.startsWith("/")) + { continue; + } + + tag = null; + startTag = token.indexOf("<"); - if(token.startsWith("a href=")) + if (startTag > -1) { - link = token.substring(token.indexOf("\"")+1, token.length()-1); + tag = token.substring(startTag+1); + token = token.substring(0, startTag); + } + + if (tag != null && tag.toUpperCase().startsWith("A HREF=")) + { + if(token.length()>0) + sb.append(token); + link = tag.substring(tag.indexOf("\"") + 1, tag.length() - 1); String label = st.nextToken("<>"); - sf.addLink(label+"|"+link); - sb.append(label+"%LINK%"); + sf.addLink(label + "|" + link); + sb.append(label + "%LINK%"); } - else if(token.equalsIgnoreCase("br")) + else if (tag != null && tag.equalsIgnoreCase("br")) sb.append("\n"); + else if (token.startsWith("lt;")) + sb.append("<" + token.substring(3)); + else if (token.startsWith("gt;")) + sb.append(">" + token.substring(3)); + else if (token.startsWith("amp;")) + sb.append("&" + token.substring(4)); else + { sb.append(token); + } } if(removeHTML) sf.description = sb.toString(); + } /** @@ -382,7 +412,38 @@ public class FeaturesFile extends AlignFile if(next[j].description==null || next[j].description.equals("")) out.append(next[j].type+"\t"); else - out.append(next[j].description + "\t"); + { + if(next[j].links!=null + && next[j].getDescription().indexOf("")==-1) + out.append(""); + + out.append(next[j].description+" "); + if(next[j].links!=null) + { + for(int l=0; l" + + label + + ""); + } + } + + if (next[j].getDescription().indexOf("") == -1) + out.append(""); + } + + + out.append("\t"); + } + out.append( seqs[i].getName() + "\t-1\t" + next[j].begin + "\t" @@ -412,6 +473,7 @@ public class FeaturesFile extends AlignFile { StringBuffer out = new StringBuffer(); SequenceFeature [] next; + String source; for(int i=0; i