comparison NCBO_services/extract.java @ 20:1910c878378c

get_ontology menu improved (Automatically generated), source added, readme improved
author Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
date Wed, 25 Jan 2012 19:49:20 +0100
parents
children
comparison
equal deleted inserted replaced
19:4cd75b0d77af 20:1910c878378c
1 package es.upm.fi.dia.oeg.ncbo.galaxy;
2
3 import java.io.BufferedReader;
4 import java.io.BufferedWriter;
5 import java.io.IOException;
6 import java.io.InputStream;
7 import java.io.InputStreamReader;
8 import java.io.OutputStreamWriter;
9
10 import org.apache.http.HttpEntity;
11 import org.apache.http.HttpResponse;
12 import org.apache.http.client.ClientProtocolException;
13 import org.apache.http.client.HttpClient;
14 import org.apache.http.client.methods.HttpGet;
15 import org.apache.http.impl.client.DefaultHttpClient;
16
17 public class extract {
18
19 /**
20 * @param args
21 * @throws IOException
22 * @throws ClientProtocolException
23 */
24 public static void main(String[] args) throws ClientProtocolException, IOException {
25
26 // http://www.bioontology.org/wiki/index.php/View_Extraction
27 // ./viewextractor/{ontology version id}[?{args}]&apikey={YourAPIKey}
28
29 String api_key = args [0];
30 String ontologyversionid = args [1]; // 35686
31 String conceptid = args [2]; // E800-E999.9
32 String filterrelations = args [3]; // PAR,isa,CHD,inverse_isa,SUBSETMEMBER,SubClass,SuperClass,[R]SIB,SI
33 String ontologyname = args [4]; // http://who.int/icd9
34
35 HttpClient client = new DefaultHttpClient();
36
37 // HttpGet get = new HttpGet("http://rest.bioontology.org/bioportal/viewextractor/35686/" +
38 // "?conceptid=E800-E999.9&filterrelations=PAR,isa,CHD,inverse_isa,SUBSETMEMBER,SubClass,SuperClass," +
39 // "[R]SIB,SIB&existontology=true&ontologyname=http://who.int/icd9&apikey=74c12fc6-9423-455a-a619-b94f47d1951b");
40
41 HttpGet get = new HttpGet("http://rest.bioontology.org/bioportal/viewextractor/" + ontologyversionid +
42 "/?conceptid="+ conceptid +"&filterrelations=" + filterrelations +
43 "&existontology=true&ontologyname="+ ontologyname + "&apikey=" + api_key);
44
45 HttpResponse response = client.execute(get);
46 HttpEntity entity = response.getEntity();
47 if (entity != null) {
48 InputStream instream = entity.getContent();
49 InputStreamReader is=new InputStreamReader(instream);
50 BufferedReader br=new BufferedReader(is);
51 String read=br.readLine();
52 BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
53 while(read!=null){
54 // System.out.println(read);
55 bw.write(read);
56 bw.newLine();
57 read=br.readLine();
58 }
59 bw.close();
60 instream.close();
61 }
62
63 }
64
65 }