1 package jalview.ws.dbsources;
3 import jalview.datamodel.Alignment;
4 import jalview.datamodel.AlignmentI;
5 import jalview.datamodel.DBRefSource;
6 import jalview.io.FormatAdapter;
7 import jalview.io.IdentifyFile;
8 import jalview.ws.intermine.IntermineFetchClient;
9 import jalview.ws.seqfetcher.DbSourceProxyImpl;
11 import java.util.Iterator;
13 import org.json.simple.JSONArray;
14 import org.json.simple.JSONObject;
16 import com.stevesoft.pat.Regex;
18 public class Intermine extends DbSourceProxyImpl // implements DbSourceProxy
22 public String getDbSource()
24 return DBRefSource.INTERMINE;
28 public String getDbName()
34 public String getDbVersion()
40 public String getAccessionSeparator()
46 public Regex getAccessionValidator()
53 public String getTestQuery()
55 // TODO Auto-generated method stub
56 return "http://www.flymine.org/query/service/jbrowse/7227/features/2L?start=100000&end=100200&reference=true";
60 public boolean isValidReference(String accession)
66 public AlignmentI getSequenceRecords(String query) throws Exception
69 String jsonString = IntermineFetchClient.fetchData(query);
71 Object sequenceString = "";
72 System.out.println("Found json: " + jsonString);
73 org.json.simple.parser.JSONParser jsonParser = new org.json.simple.parser.JSONParser();
76 JSONObject jobj = (JSONObject) jsonParser.parse(jsonString);
77 JSONArray responses = (JSONArray) jobj.get("features");
78 for (Iterator<JSONObject> rvals = responses.iterator(); rvals
81 JSONObject feature = rvals.next();
82 Object seq = feature.get("seq");
83 System.out.println("Sequence : " + seq.toString());
90 return parseResult(sequenceString.toString());
94 protected Alignment parseResult(String result) throws Exception
96 Alignment sequences = null;
97 String format = new IdentifyFile().Identify(result, "Paste");
98 if (FormatAdapter.isValidFormat(format))
100 sequences = new FormatAdapter().readFile(result, "Paste",