import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.DBRefSource;
+import jalview.datamodel.Sequence;
import jalview.io.FormatAdapter;
import jalview.io.IdentifyFile;
import jalview.ws.intermine.IntermineFetchClient;
return false;
}
+ @SuppressWarnings("unchecked")
@Override
public AlignmentI getSequenceRecords(String query) throws Exception
{
startQuery();
String jsonString = IntermineFetchClient.fetchData(query);
-
- Object sequenceString = "";
+ Sequence[] retrievedSeq = null;
+ String sequence = "";
+ String name = "";
System.out.println("Found json: " + jsonString);
org.json.simple.parser.JSONParser jsonParser = new org.json.simple.parser.JSONParser();
try
{
JSONObject jobj = (JSONObject) jsonParser.parse(jsonString);
JSONArray responses = (JSONArray) jobj.get("features");
+ int count = 0;
for (Iterator<JSONObject> rvals = responses.iterator(); rvals
.hasNext();)
{
+ retrievedSeq = new Sequence[responses.size()];
+
JSONObject feature = rvals.next();
- Object seq = feature.get("seq");
- System.out.println("Sequence : " + seq.toString());
+ // name = feature.get("name").toString();
+ name = "name";
+ sequence = feature.get("seq").toString();
+ int start = Integer.valueOf(feature.get("start").toString());
+ int end = Integer.valueOf(feature.get("end").toString());
+
+ retrievedSeq[count++] = new Sequence(name, sequence, start, end);
+
+ System.out.println("Sequence : " + sequence);
+
}
} catch (Exception e)
{
e.printStackTrace();
}
stopQuery();
- return parseResult(sequenceString.toString());
+ return parseResult(retrievedSeq);
}
@Override
}
-
+ private Alignment parseResult(Sequence[] seqs)
+ {
+ Alignment sequences = new Alignment(seqs);
+ return sequences;
+ }
@Override