1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
package jalview.io; |
23 |
|
|
24 |
|
import jalview.api.ComplexAlignFile; |
25 |
|
import jalview.api.FeatureSettingsModelI; |
26 |
|
import jalview.api.FeaturesDisplayedI; |
27 |
|
import jalview.datamodel.HiddenColumns; |
28 |
|
import jalview.datamodel.SequenceI; |
29 |
|
|
30 |
|
import java.io.IOException; |
31 |
|
import java.io.StringReader; |
32 |
|
|
33 |
|
import org.jsoup.Jsoup; |
34 |
|
import org.jsoup.nodes.Document; |
35 |
|
import org.jsoup.nodes.Element; |
36 |
|
|
|
|
| 0% |
Uncovered Elements: 66 (66) |
Complexity: 21 |
Complexity Density: 0.49 |
|
37 |
|
public class HtmlFile extends AlignFile implements ComplexAlignFile |
38 |
|
{ |
39 |
|
public static final String FILE_EXT = "html"; |
40 |
|
|
41 |
|
public static final String FILE_DESC = "HTML"; |
42 |
|
|
43 |
|
private String globalColourScheme; |
44 |
|
|
45 |
|
private boolean showSeqFeatures; |
46 |
|
|
47 |
|
private HiddenColumns hiddenColumns; |
48 |
|
|
49 |
|
private SequenceI[] hiddenSequences; |
50 |
|
|
51 |
|
private FeaturesDisplayedI displayedFeatures; |
52 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
53 |
0 |
public HtmlFile()... |
54 |
|
{ |
55 |
0 |
super(); |
56 |
|
} |
57 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
58 |
0 |
public HtmlFile(FileParse source) throws IOException... |
59 |
|
{ |
60 |
0 |
super(source); |
61 |
|
} |
62 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
63 |
0 |
public HtmlFile(String inFile, DataSourceType sourceType)... |
64 |
|
throws IOException |
65 |
|
{ |
66 |
0 |
super(inFile, sourceType); |
67 |
|
} |
68 |
|
|
|
|
| 0% |
Uncovered Elements: 37 (37) |
Complexity: 7 |
Complexity Density: 0.24 |
|
69 |
0 |
@Override... |
70 |
|
public void parse() throws IOException |
71 |
|
{ |
72 |
0 |
Element content = null; |
73 |
0 |
Document doc = null; |
74 |
0 |
try |
75 |
|
{ |
76 |
0 |
StringBuilder htmlData = new StringBuilder(); |
77 |
0 |
String currentLine; |
78 |
0 |
while ((currentLine = nextLine()) != null) |
79 |
|
{ |
80 |
0 |
htmlData.append(currentLine); |
81 |
|
} |
82 |
0 |
doc = Jsoup.parse(htmlData.toString()); |
83 |
|
} catch (OutOfMemoryError oom) |
84 |
|
{ |
85 |
0 |
errormessage = "Not enough memory to process HTML document"; |
86 |
0 |
throw new IOException(errormessage); |
87 |
|
} |
88 |
|
|
89 |
0 |
try |
90 |
|
{ |
91 |
0 |
boolean contentFromDiv = true; |
92 |
|
|
93 |
0 |
content = doc.select("div[id=seqData]").first(); |
94 |
0 |
if (content == null) |
95 |
|
{ |
96 |
0 |
contentFromDiv = false; |
97 |
|
|
98 |
0 |
content = doc.getElementById("seqData"); |
99 |
|
} |
100 |
|
|
101 |
0 |
if (content == null) |
102 |
|
{ |
103 |
0 |
errormessage = "The html document is not embedded with BioJSON data"; |
104 |
0 |
throw new IOException(errormessage); |
105 |
|
} |
106 |
0 |
JSONFile jsonFile = new JSONFile().parse(new StringReader( |
107 |
0 |
contentFromDiv ? content.text() : content.val())); |
108 |
0 |
this.seqs = jsonFile.getSeqs(); |
109 |
0 |
this.seqGroups = jsonFile.getSeqGroups(); |
110 |
0 |
this.annotations = jsonFile.getAnnotations(); |
111 |
0 |
this.showSeqFeatures = jsonFile.isShowSeqFeatures(); |
112 |
0 |
this.globalColourScheme = jsonFile.getGlobalColourScheme(); |
113 |
0 |
this.hiddenSequences = jsonFile.getHiddenSequences(); |
114 |
0 |
this.hiddenColumns = jsonFile.getHiddenColumns(); |
115 |
0 |
this.displayedFeatures = jsonFile.getDisplayedFeatures(); |
116 |
|
} catch (Exception e) |
117 |
|
{ |
118 |
0 |
throw e; |
119 |
|
} |
120 |
|
} |
121 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
122 |
0 |
@Override... |
123 |
|
public String print(SequenceI[] sqs, boolean jvsuffix) |
124 |
|
{ |
125 |
0 |
throw new UnsupportedOperationException( |
126 |
|
"Print method of HtmlFile is not supported!"); |
127 |
|
} |
128 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
129 |
0 |
@Override... |
130 |
|
public boolean isShowSeqFeatures() |
131 |
|
{ |
132 |
0 |
return showSeqFeatures; |
133 |
|
} |
134 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
135 |
0 |
public void setShowSeqFeatures(boolean showSeqFeatures)... |
136 |
|
{ |
137 |
0 |
this.showSeqFeatures = showSeqFeatures; |
138 |
|
} |
139 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
140 |
0 |
@Override... |
141 |
|
public String getGlobalColourScheme() |
142 |
|
{ |
143 |
0 |
return globalColourScheme; |
144 |
|
} |
145 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
146 |
0 |
public void setColourScheme(String globalColourScheme)... |
147 |
|
{ |
148 |
0 |
this.globalColourScheme = globalColourScheme; |
149 |
|
} |
150 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
151 |
0 |
@Override... |
152 |
|
public HiddenColumns getHiddenColumns() |
153 |
|
{ |
154 |
0 |
return hiddenColumns; |
155 |
|
} |
156 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
157 |
0 |
public void setHiddenColumns(HiddenColumns hidden)... |
158 |
|
{ |
159 |
0 |
this.hiddenColumns = hidden; |
160 |
|
} |
161 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
162 |
0 |
@Override... |
163 |
|
public SequenceI[] getHiddenSequences() |
164 |
|
{ |
165 |
0 |
return hiddenSequences; |
166 |
|
} |
167 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
168 |
0 |
public void setHiddenSequences(SequenceI[] hiddenSequences)... |
169 |
|
{ |
170 |
0 |
this.hiddenSequences = hiddenSequences; |
171 |
|
} |
172 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
173 |
0 |
@Override... |
174 |
|
public FeaturesDisplayedI getDisplayedFeatures() |
175 |
|
{ |
176 |
0 |
return displayedFeatures; |
177 |
|
} |
178 |
|
|
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
|
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
188 |
0 |
@Override... |
189 |
|
public FeatureSettingsModelI getFeatureColourScheme() |
190 |
|
{ |
191 |
0 |
return new PDBFeatureSettings(); |
192 |
|
} |
193 |
|
|
194 |
|
} |