From 245c9609dc00df56054b35e76aff48a2dda0be50 Mon Sep 17 00:00:00 2001 From: Charles Ofoegbu Date: Mon, 20 Oct 2014 12:13:06 +0100 Subject: [PATCH] Modifed the way Intermine.java parse alignment data --- .gitignore | 3 ++- src/jalview/ws/dbsources/Intermine.java | 30 ++++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 46d39d0..78a6a7e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ .externalToolBuilders/Jalview Release indices [Builder].launch /.DS_Store /.com.apple.timemachine.supported -.settings/ \ No newline at end of file +.settings/ +.gitattributes \ No newline at end of file diff --git a/src/jalview/ws/dbsources/Intermine.java b/src/jalview/ws/dbsources/Intermine.java index e738adf..0d9ce02 100644 --- a/src/jalview/ws/dbsources/Intermine.java +++ b/src/jalview/ws/dbsources/Intermine.java @@ -3,6 +3,7 @@ package jalview.ws.dbsources; 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; @@ -62,32 +63,45 @@ public class Intermine extends DbSourceProxyImpl // implements DbSourceProxy 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 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 @@ -104,7 +118,11 @@ public class Intermine extends DbSourceProxyImpl // implements DbSourceProxy } - + private Alignment parseResult(Sequence[] seqs) + { + Alignment sequences = new Alignment(seqs); + return sequences; + } @Override -- 1.7.10.2