X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fensembl%2FEnsemblFeatures.java;h=e28cc7f0b4a4fdf9828ad89eaca14c35ed9e2d19;hb=refs%2Fheads%2FJAL-3253-applet-SwingJS-omnibus;hp=054743307df33e3a2e86f295847b17866a087271;hpb=b8058f3f849f44740a695c83e96bdca3a197af5c;p=jalview.git
diff --git a/src/jalview/ext/ensembl/EnsemblFeatures.java b/src/jalview/ext/ensembl/EnsemblFeatures.java
index 0547433..e28cc7f 100644
--- a/src/jalview/ext/ensembl/EnsemblFeatures.java
+++ b/src/jalview/ext/ensembl/EnsemblFeatures.java
@@ -1,15 +1,44 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.ext.ensembl;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
-import jalview.io.FeaturesFile;
-import jalview.io.FileParse;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceI;
+import jalview.io.gff.SequenceOntologyI;
+import jalview.util.JSONUtils;
+import jalview.util.Platform;
+import java.io.BufferedReader;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+
+import org.json.simple.parser.ParseException;
/**
* A client for fetching and processing Ensembl feature data in GFF format by
@@ -62,11 +91,141 @@ class EnsemblFeatures extends EnsemblRestClient
public AlignmentI getSequenceRecords(String query) throws IOException
{
// TODO: use a vararg String... for getSequenceRecords instead?
- List queries = new ArrayList();
+
+ List queries = new ArrayList<>();
queries.add(query);
- FileParse fp = getSequenceReader(queries);
- FeaturesFile fr = new FeaturesFile(fp);
- return new Alignment(fr.getSeqsAsArray());
+ SequenceI seq = parseFeaturesJson(queries);
+ if (seq == null)
+ return null;
+ return new Alignment(new SequenceI[] { seq });
+
+ }
+
+ /**
+ * Parses the JSON response into Jalview sequence features and attaches them
+ * to a dummy sequence
+ *
+ * @param br
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ private SequenceI parseFeaturesJson(List queries)
+ {
+ SequenceI seq = new Sequence("Dummy", "");
+ try
+ {
+ Iterator