annotate get_ontology.java @ 28:ebf11126df7c draft default tip

Orain bai
author Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
date Mon, 08 Oct 2012 14:35:28 +0200
parents e2b16720ef25
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
1 package es.upm.fi.dia.oeg.ncbo.galaxy;
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
2
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
3 import java.io.BufferedReader;
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
4 import java.io.BufferedWriter;
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
5 import java.io.IOException;
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
6 import java.io.InputStream;
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
7 import java.io.InputStreamReader;
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
8 import java.io.OutputStreamWriter;
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
9
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
10 import org.apache.http.HttpEntity;
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
11 import org.apache.http.HttpResponse;
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
12 import org.apache.http.client.ClientProtocolException;
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
13 import org.apache.http.client.HttpClient;
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
14 import org.apache.http.client.methods.HttpGet;
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
15 import org.apache.http.client.methods.HttpPost;
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
16 import org.apache.http.impl.client.DefaultHttpClient;
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
17
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
18 public class get_ontology {
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
19
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
20 /**
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
21 * @param args
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
22 * @throws IOException
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
23 * @throws ClientProtocolException
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
24 */
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
25 public static void main(String[] args) throws ClientProtocolException, IOException {
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
26 String api_key = args [0];
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
27 String ontology_id = args [1]; // 1522
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
28 HttpClient client = new DefaultHttpClient();
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
29
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
30 HttpGet get = new HttpGet("http://rest.bioontology.org/bioportal/virtual/download/" + ontology_id + "?apikey=" +api_key);
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
31 HttpResponse response = client.execute(get);
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
32 HttpEntity entity = response.getEntity();
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
33 if (entity != null) {
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
34 InputStream instream = entity.getContent();
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
35 InputStreamReader is=new InputStreamReader(instream);
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
36 BufferedReader br=new BufferedReader(is);
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
37 String read=br.readLine();
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
38 BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
39 while(read!=null){
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
40 // System.out.println(read);
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
41 bw.write(read);
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
42 bw.newLine();
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
43 read=br.readLine();
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
44 }
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
45 bw.close();
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
46 instream.close();
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
47 }
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
48 }
1910c878378c get_ontology menu improved (Automatically generated), source added, readme improved
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
49 }