# HG changeset patch # User Mikel Egaña Aranguren # Date 1327517360 -3600 # Node ID 1910c878378c195a0a98a40e262dc4f3c6258fd2 # Parent 4cd75b0d77af0c227e7ffacc7dc5f56112ac9e85 get_ontology menu improved (Automatically generated), source added, readme improved diff -r 4cd75b0d77af -r 1910c878378c NCBO_services/README --- a/NCBO_services/README Wed Jan 18 17:59:05 2012 +0100 +++ b/NCBO_services/README Wed Jan 25 19:49:20 2012 +0100 @@ -50,6 +50,20 @@ +ACKNOWLEDGEMENTS +================ + +The work on get_ontology, extract and get_ontology_view is funded by the +Marie Curie Cofund program of the EU, FP7. + + + +COPYRIGHT AND LICENSE +===================== + +get_ontology, extract and get_ontology_view are copyright of Mikel +Egaña Aranguren (2012), and they are distributed under a GPL 3 license +(http://www.gnu.org/licenses/) @@ -60,3 +74,8 @@ + + + + + diff -r 4cd75b0d77af -r 1910c878378c NCBO_services/extract.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NCBO_services/extract.java Wed Jan 25 19:49:20 2012 +0100 @@ -0,0 +1,65 @@ +package es.upm.fi.dia.oeg.ncbo.galaxy; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.DefaultHttpClient; + +public class extract { + + /** + * @param args + * @throws IOException + * @throws ClientProtocolException + */ + public static void main(String[] args) throws ClientProtocolException, IOException { + +// http://www.bioontology.org/wiki/index.php/View_Extraction +// ./viewextractor/{ontology version id}[?{args}]&apikey={YourAPIKey} + + String api_key = args [0]; + String ontologyversionid = args [1]; // 35686 + String conceptid = args [2]; // E800-E999.9 + String filterrelations = args [3]; // PAR,isa,CHD,inverse_isa,SUBSETMEMBER,SubClass,SuperClass,[R]SIB,SI + String ontologyname = args [4]; // http://who.int/icd9 + + HttpClient client = new DefaultHttpClient(); + +// HttpGet get = new HttpGet("http://rest.bioontology.org/bioportal/viewextractor/35686/" + +// "?conceptid=E800-E999.9&filterrelations=PAR,isa,CHD,inverse_isa,SUBSETMEMBER,SubClass,SuperClass," + +// "[R]SIB,SIB&existontology=true&ontologyname=http://who.int/icd9&apikey=74c12fc6-9423-455a-a619-b94f47d1951b"); + + HttpGet get = new HttpGet("http://rest.bioontology.org/bioportal/viewextractor/" + ontologyversionid + + "/?conceptid="+ conceptid +"&filterrelations=" + filterrelations + + "&existontology=true&ontologyname="+ ontologyname + "&apikey=" + api_key); + + HttpResponse response = client.execute(get); + HttpEntity entity = response.getEntity(); + if (entity != null) { + InputStream instream = entity.getContent(); + InputStreamReader is=new InputStreamReader(instream); + BufferedReader br=new BufferedReader(is); + String read=br.readLine(); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + while(read!=null){ +// System.out.println(read); + bw.write(read); + bw.newLine(); + read=br.readLine(); + } + bw.close(); + instream.close(); + } + + } + +} diff -r 4cd75b0d77af -r 1910c878378c NCBO_services/get_ontology.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NCBO_services/get_ontology.java Wed Jan 25 19:49:20 2012 +0100 @@ -0,0 +1,49 @@ +package es.upm.fi.dia.oeg.ncbo.galaxy; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.DefaultHttpClient; + +public class get_ontology { + + /** + * @param args + * @throws IOException + * @throws ClientProtocolException + */ + public static void main(String[] args) throws ClientProtocolException, IOException { + String api_key = args [0]; + String ontology_id = args [1]; // 1522 + HttpClient client = new DefaultHttpClient(); + + HttpGet get = new HttpGet("http://rest.bioontology.org/bioportal/virtual/download/" + ontology_id + "?apikey=" +api_key); + HttpResponse response = client.execute(get); + HttpEntity entity = response.getEntity(); + if (entity != null) { + InputStream instream = entity.getContent(); + InputStreamReader is=new InputStreamReader(instream); + BufferedReader br=new BufferedReader(is); + String read=br.readLine(); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + while(read!=null){ +// System.out.println(read); + bw.write(read); + bw.newLine(); + read=br.readLine(); + } + bw.close(); + instream.close(); + } + } +} diff -r 4cd75b0d77af -r 1910c878378c NCBO_services/get_ontology.xml --- a/NCBO_services/get_ontology.xml Wed Jan 18 17:59:05 2012 +0100 +++ b/NCBO_services/get_ontology.xml Wed Jan 25 19:49:20 2012 +0100 @@ -25,110 +25,200 @@ - + - - + + + + + + + + + - + + + + + + + + + + + + + + + + + + + - + + + + + - + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - + + + + + + + @@ -139,6 +229,8 @@ + + @@ -148,103 +240,23 @@ + + + + + - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -259,18 +271,78 @@ - + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 4cd75b0d77af -r 1910c878378c NCBO_services/get_ontology_view.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NCBO_services/get_ontology_view.java Wed Jan 25 19:49:20 2012 +0100 @@ -0,0 +1,54 @@ +package es.upm.fi.dia.oeg.ncbo.galaxy; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.DefaultHttpClient; + +public class get_ontology_view { + + /** + * @param args + * @throws IOException + * @throws ClientProtocolException + */ + public static void main(String[] args) throws ClientProtocolException, IOException { +// http://www.bioontology.org/wiki/index.php/BioPortal_REST_services#Download_a_specific_ontology_view_based_on_the_ontology_view_version_id +// Download a specific ontology view based on the ontology view version id + + String api_key = args [0]; + String ontology_view_id = args [1]; + + HttpClient client = new DefaultHttpClient(); +// http://rest.bioontology.org/bioportal/ontologies/download/43072?apikey=YourAPIKey + HttpGet get = new HttpGet("http://rest.bioontology.org/bioportal/ontologies/download/" + ontology_view_id + "?apikey=" + api_key); + + HttpResponse response = client.execute(get); + HttpEntity entity = response.getEntity(); + if (entity != null) { + InputStream instream = entity.getContent(); + InputStreamReader is=new InputStreamReader(instream); + BufferedReader br=new BufferedReader(is); + String read=br.readLine(); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + while(read!=null){ +// System.out.println(read); + bw.write(read); + bw.newLine(); + read=br.readLine(); + } + bw.close(); + instream.close(); + } + } +}