3 import jalview.gui.AlignFrame;
4 import jalview.schemes.ColourSchemeI;
6 import java.io.IOException;
8 import org.jsoup.Jsoup;
9 import org.jsoup.nodes.Document;
10 import org.jsoup.nodes.Element;
12 public class HtmlFile extends AlignFile
14 // public static final String FILE_EXT = "html";
16 // public static final String FILE_DESC = "HTML";
18 private ColourSchemeI cs;
25 public HtmlFile(FileParse source) throws IOException
30 public HtmlFile(String inFile, String type) throws IOException
35 @SuppressWarnings("unchecked")
37 public void parse() throws IOException
41 StringBuilder htmlData = new StringBuilder();
43 while ((currentLine = nextLine()) != null)
45 htmlData.append(currentLine);
48 Document doc = Jsoup.parse(htmlData.toString());
49 Element content = doc.getElementById("seqData");
51 String alignmentJsonString = content.val();
53 new JSONFile().parse(alignmentJsonString);
55 // JSONParser jsonParser = new JSONParser();
56 // JSONObject alignmentJsonObj = (JSONObject) jsonParser
57 // .parse(alignmentJsonString);
58 // JSONArray seqJsonArray = (JSONArray) alignmentJsonObj.get("seqs");
59 // String bioJsColourScheme = (String) alignmentJsonObj
60 // .get("globalColorScheme");
61 // cs = getJalviewColorScheme(bioJsColourScheme);
63 // for (Iterator<JSONObject> sequenceIter = seqJsonArray.iterator();
67 // JSONObject sequence = sequenceIter.next();
68 // String sequcenceString = sequence.get("seq").toString();
69 // Sequence seq = new Sequence(sequence.get("name").toString(),
70 // sequcenceString, Integer.valueOf(sequence.get("start")
71 // .toString()), Integer.valueOf(sequence.get("end")
74 // JSONArray jsonSeqArray = (JSONArray) sequence.get("features");
75 // SequenceFeature[] retrievedSeqFeatures = getJalviewSequenceFeatures(
76 // jsonSeqArray, seq);
77 // if (retrievedSeqFeatures != null)
79 // seq.setSequenceFeatures(retrievedSeqFeatures);
90 // public SequenceFeature[] getJalviewSequenceFeatures(
91 // JSONArray jsonSeqFeatures, Sequence seq)
93 // SequenceFeature[] seqFeatures = null;
95 // if (jsonSeqFeatures != null)
97 // seqFeatures = new SequenceFeature[jsonSeqFeatures.size()];
98 // for (@SuppressWarnings("unchecked")
99 // Iterator<JSONObject> seqFeatureItr = jsonSeqFeatures.iterator();
104 // SequenceFeature sequenceFeature = new SequenceFeature();
105 // JSONObject jsonFeature = seqFeatureItr.next();
106 // Long begin = (Long) jsonFeature.get("xStart");
107 // Long end = (Long) jsonFeature.get("xEnd");
108 // String type = (String) jsonFeature.get("text");
109 // // String color = (String) jsonFeature.get("fillColor");
111 // sequenceFeature.setBegin(seq.findPosition(begin.intValue()));
112 // sequenceFeature.setEnd(seq.findPosition(end.intValue()) - 1);
113 // sequenceFeature.setType(type);
114 // seqFeatures[count++] = sequenceFeature;
117 // return seqFeatures;
120 public void LoadAlignmentFeatures(AlignFrame af)
123 af.setShowSeqFeatures(true);
125 af.setMenusForViewport();
128 // private ColourSchemeI getJalviewColorScheme(String bioJsColourSchemeName)
130 // ColourSchemeI jalviewColor = null;
131 // for (JalviewBioJsColorSchemeMapper cs : JalviewBioJsColorSchemeMapper
134 // if (cs.getBioJsName().equals(bioJsColourSchemeName))
136 // jalviewColor = cs.getJvColourScheme();
140 // return jalviewColor;
144 public String print()
146 throw new UnsupportedOperationException(
147 "Print method of HtmlFile not yet supported!");