Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tib service #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions Ontology-Search-Template.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
.hidden {
display: none;
}

.error {
padding-top: 10px;
color: #e74c3c;
Expand Down Expand Up @@ -233,6 +233,7 @@
<option value="bioportal" selected>Search BioPortal</option>
<option value="lov">Search LOV</option>
<option value="ols">Search OLS</option>
<option value="tib-ols">Search TIB TS</option>
</select>
</div>

Expand Down Expand Up @@ -302,21 +303,21 @@
* the sidebar UI with the resulting translation.
*/
function runSearch() {

var term = $('input[name=search-text]').val();

if(term === "") {
showError('Please enter a search term.', $('#button-bar'));
return
}
this.disabled = true;

this.disabled = true;

$('#search-results').html('<div id="spinner"><img src="//s-media-cache-ak0.pinimg.com/originals/0a/59/71/0a59718a5ee79a0558930ca9907c0659.gif" width="70px"/><p>Searching...</p></div>');
$('#error').remove();

var service = $('#service').val();


google.script.run
.withSuccessHandler(
Expand All @@ -325,10 +326,10 @@
var html = '<div id="accordion" class="accordion">';
console.log(result);
if (result) {

Object.keys(result).sort().forEach(function(ontology_abbr) {
var ontology = result[ontology_abbr];

html += '<h3><span class="ontology-abbr">' + ontology_abbr + '</span> - <span class="ontology-name">' + ontology["ontology-name"] + '</span></h3>' +
'<div><ul>'

Expand All @@ -345,10 +346,10 @@
'<div class="clearfix"></div>' +
'</li>';
});

html += '</ul></div>';
});

} else {
html += "<p>Sorry, no results were found matching your query...</p>";
}
Expand Down
66 changes: 63 additions & 3 deletions OntologySearch.gs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ function performSearch(service, term) {
return searchLOV(term);
case "ols":
return searchOLS(term);
case "tib-ols":
return searchTIBOLS(term);
default:
return searchLOV(term);
}
Expand Down Expand Up @@ -251,7 +253,65 @@ function searchOLS(term) {
ontologyDict[ontologyLabel] = {"ontology-name": elem.ontology_name, "terms": []};
record = {
label: elem.label,
id: elem.id,
id: elem.short_form,
'ontology-label': elem.ontology_prefix,
'ontology-name': elem.ontology_name,
accession: elem.iri,//elem.obo_id,
ontology: elem.ontology_name,
details: '',
url: elem.iri
};

storeInCache(record.id, JSON.stringify(record));
ontologyDict[ontologyLabel].terms.push(record);
}
});
storeInCache(url, JSON.stringify(ontologyDict));
// Logger.log(ontologyDict);
return ontologyDict;
}
catch(e) {
Logger.log(e);
throw(e);
}
}


/**
* @method
* @name searchTIBOLS
* @param{string} term
*/
function searchTIBOLS(term) {
try {
var restriction = findRestrictionForCurrentColumn("OLS");
var ontologies = getTIBOLSOntologies();
var url = TIBOLS_API_BASE_URI + '/search';
var queryObj = {
q: term,
rows: OLS_PAGINATION_SIZE,
start: 0,
ontology: restriction ? restriction.ontologyId : undefined
};
var queryString = jsonToQueryString(queryObj);
url += '?' + queryString;
var cacheResult = fetchFromCache(url);
if (cacheResult) {
return JSON.parse(cacheResult);
}
var text = UrlFetchApp.fetch(url).getContentText(), json = JSON.parse(text), ontologyDict = {};

var docs = json.response && json.response.docs;
if (!docs || docs.length === 0) {
throw "No Result found.";
}
docs.forEach(function(elem) {
var ontology = ontologies[elem.ontology_name], ontologyLabel = elem.ontology_prefix, record;
if (!ontologyDict[ontologyLabel]) {
ontologyDict[ontologyLabel] = {"ontology-name": elem.ontology_name, "terms": []};
record = {
label: elem.label,
id: elem.short_form,
'ontology-label': elem.ontology_prefix,
'ontology-name': elem.ontology_name,
accession: elem.iri,//elem.obo_id,
Expand Down Expand Up @@ -293,7 +353,7 @@ function handleTermInsertion(term_id) {
// figure out whether the Term Source REF and Term Accession Number columns exist, if they do exist at all. Insertion technique will vary
// depending on the file being looked at.
var sourceAndAccessionPositions = getSourceAndAccessionPositionsForTerm(selectedRange.getColumn());

// add all terms into a separate sheet with all their information.
if (sourceAndAccessionPositions.sourceRef != undefined && sourceAndAccessionPositions.accession != undefined) {
insertOntologySourceInformationInInvestigationBlock(ontologyObject);
Expand Down Expand Up @@ -328,4 +388,4 @@ function handleTermInsertion(term_id) {
throw err;
}

}
}
5 changes: 3 additions & 2 deletions Ontomaton-terms.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<li><a href="http://data.bioontology.org/documentation" rel="nofollow">NBCO Bioportal</a></li>
<li><a href="https://www.ebi.ac.uk/ols/docs/api" rel="nofollow">EMBL-EBI Ontology Lookup Service</a></li>
<li><a href="https://lov.linkeddata.es/dataset/lov/api" rel="nofollow">Linked Open Vocabularies catalogue</a></li>
<li><a href="https://service.tib.eu/ts4tib/api" rel="nofollow">TIB Terminology Service</a></li>
</ul>


Expand All @@ -30,11 +31,11 @@ Bioinformatics 2013 29: 525-527. <a href="https://doi.org/10.1093/bioinformatics

----


### Video Tutorial

Access the video tutorial showing how to install and use OntoMaton (version 1) [here](http://www.youtube.com/watch?v=Qs0nxGBfQac&feature=player_embedded).

### Templates

Templates can be found through accessing them on the google templates site. OntoMaton templates are [here](https://drive.google.com/templates?type=spreadsheets&q=ontomaton).
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,30 @@ OntoMaton facilitates ontology search and tagging functionalities within Google
### Read the Publication...
Access the Open Access <a href="http://bioinformatics.oxfordjournals.org">Bioinformatics</a> article on OntoMaton [here](http://dx.doi.org/10.1093/bioinformatics/bts718).

<i>Eamonn Maguire, Alejandra González-Beltrán, Patricia L. Whetzel, Susanna-Assunta Sansone, and Philippe Rocca-Serra
OntoMaton: a Bioportal powered ontology widget for Google Spreadsheets
<i>Eamonn Maguire, Alejandra González-Beltrán, Patricia L. Whetzel, Susanna-Assunta Sansone, and Philippe Rocca-Serra
OntoMaton: a Bioportal powered ontology widget for Google Spreadsheets
Bioinformatics 2013 29: 525-527. doi: [10.1093/bioinformatics/bts718](http://dx.doi.org/10.1093/bioinformatics/bts718)</i>

Please, note that at the time of the publication, OntoMaton was powered by the <a href="http://bioportal.bioontology.org/">NCBO BioPortal</a> web services. Since then, we have made the following extensions:

- we upgraded the code to [Google Add-ons for Docs and Sheets](http://googledrive.blogspot.it/2014/03/add-ons.html), which [deprecated the Apps Script applications and the Script Gallery](http://googleappsdeveloper.blogspot.co.uk/2014/06/deprecating-script-gallery-in-old.html), used in the original OntoMaton version
- we upgraded to the new BioPortal API for searching ontology terms and annotator services (see BioPortal 4.0 release notes), as the old API was deprecated in 2014
- we extended the ontology search functionality to support REST services from the <a href="http://lov.okfn.org/">Linked Open Vocabularies</a> and the <a href="https://www.ebi.ac.uk/ols/">EBI Ontology Lookup Service</a>, thus now allowing ontology term searches over three separate services.
- we extended the ontology search functionality to support REST services from the <a href="http://lov.okfn.org/">Linked Open Vocabularies</a>, the <a href="https://www.ebi.ac.uk/ols/">EBI Ontology Lookup Service</a>, and the <a href="https://service.tib.eu/ts4tib/api">TIB Terminology Service</a>, thus now allowing ontology term searches over three separate services.

For more information, see [our blog posts on OntoMaton](https://isatools.wordpress.com/?s=ontomaton).
For more information, see [our blog posts on OntoMaton](https://isatools.wordpress.com/?s=ontomaton).


### Installation

With the new add on infrastructure, installation is very easy.
With the new add on infrastructure, installation is very easy.

1. Click on the 'Add-ons' menu item in your Google Spreadsheet:

<div align="center">
<img src="https://github.com/ISA-tools/OntoMaton/blob/master/figures/ontomaton-fig1.png" width="500">
</div>

2. Click on 'Get add-ons...' and then search for 'OntoMaton':
2. Click on 'Get add-ons...' and then search for 'OntoMaton':

<div align="center">
<img src="https://github.com/ISA-tools/OntoMaton/blob/master/figures/ontomaton-fig2.png?" height="200">
Expand All @@ -68,7 +68,7 @@ Here you can click on the image and read more about OntoMaton:
</div>


4. You'll then have the OntoMaton app installed.
4. You'll then have the OntoMaton app installed.

<div align="center">
<img src="https://github.com/ISA-tools/OntoMaton/blob/master/figures/ontomaton-fig6.png" width="500">
Expand All @@ -90,7 +90,7 @@ From OntoMaton, you can search three different services within one tool: the [NC

### Ontology Tagging

With OntoMaton, you can select a number of spreadsheet cells and then 'tag' them. This means that OntoMaton will take the terms in the cells and send them to BioPortal's Annotator service. The results will come back as a list of the free text terms, showing for each all matches in BioPortal.
With OntoMaton, you can select a number of spreadsheet cells and then 'tag' them. This means that OntoMaton will take the terms in the cells and send them to BioPortal's Annotator service. The results will come back as a list of the free text terms, showing for each all matches in BioPortal.

<div align="center">
<img src="https://isatools.files.wordpress.com/2014/04/screen-shot-2014-04-16-at-18-55-27.png?h=500"/>
Expand All @@ -105,8 +105,8 @@ With OntoMaton, you can select a number of spreadsheet cells and then 'tag' them

From the settings screen, you can configure:

* How terms should be inserted in to the spreadsheet when not in 'ISA mode' (where the next columns aren't named 'Term Source REF' or 'Term Source Accession'). The two options are as either as a hyperlink to the term in Bioportal/OLS/LOV or as a term name with the hyperlink in parentheses.
* Restrictions, which specify for zero or more columns (with a name in the first cell), restrictions that should be placed on the search space per each of the ontology lookup services we use (Bioportal/OLS/LOV) E.g. the column 'Label' is restricted to terms from the Chemincal Entities of Biomedical Interest ontology (ChEBI). Please, note that for instance if a column has a restriction over the BioPortal service, the restiction will not have an effect if searching terms with OLS.
* How terms should be inserted in to the spreadsheet when not in 'ISA mode' (where the next columns aren't named 'Term Source REF' or 'Term Source Accession'). The two options are as either as a hyperlink to the term in Bioportal/OLS/LOV or as a term name with the hyperlink in parentheses.
* Restrictions, which specify for zero or more columns (with a name in the first cell), restrictions that should be placed on the search space per each of the ontology lookup services we use (Bioportal/OLS/LOV) E.g. the column 'Label' is restricted to terms from the Chemincal Entities of Biomedical Interest ontology (ChEBI). Please, note that for instance if a column has a restriction over the BioPortal service, the restiction will not have an effect if searching terms with OLS.


### Restricting OntoMaton's search space
Expand All @@ -121,17 +121,17 @@ From the settings screen, you can configure:


When you add a restriction using the 'Settings' panel for the first time, a 'Restrictions' sheet will be added automatically. This sheet will have the following column headers:
```Column Name | Ontology | Branch | Version | Ontology Name | Service```. Then you may define for a particular column header in your spreadsheet what ontology should be searched (or list of ontologies) over what service (BioPortal, OLS or LOV). A restriction will only apply if using the corresponding service for search.
```Column Name | Ontology | Branch | Version | Ontology Name | Service```. Then you may define for a particular column header in your spreadsheet what ontology should be searched (or list of ontologies) over what service (BioPortal, OLS or LOV). A restriction will only apply if using the corresponding service for search.

Additionally, within one ontology restriction, for BioPortal searches, you can restrict to a particular branch of an ontology, providing a way to further restrict the search space.

An example of a google spreadsheet with such functionality can be viewed here: https://docs.google.com/spreadsheet/ccc?key=0Al5WvYyk0zzmdDNLeEcxWHZJX042dS0taXJPNXpJMHc


### Video Tutorial

Access the video tutorial showing how to install and use OntoMaton (version 1) [here](http://www.youtube.com/watch?v=Qs0nxGBfQac&feature=player_embedded).

### Templates

Templates can be found through accessing them on the google templates site. OntoMaton templates are [here](https://drive.google.com/templates?type=spreadsheets&q=ontomaton).
Expand Down
50 changes: 43 additions & 7 deletions Settings.gs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function showSettings() {
SpreadsheetApp.getUi().showSidebar(html);
}

function loadOntologies() {
function loadOntologies() {
return {
'BioPortal': getBioPortalOntologies(),
'LOV': getLinkedOpenVocabularies(),
Expand All @@ -61,8 +61,8 @@ function viewRestrictionHandler() {
var restrictionSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Restrictions");

if (restrictionSheet == undefined) {
UiApp.getActiveApplication().getElementById("status").setText("Restriction sheet doesn't exist yet. Add a restriction and it will be created automatically.");
return UiApp.getActiveApplication();
var htmlOutput = HtmlService.createHtmlOutput("<p>Restriction sheet doesn't exist yet. Add a restriction and it will be created automatically.</p>");
SpreadsheetApp.getActiveSpreadsheet().show(htmlOutput);
} else {
SpreadsheetApp.getActiveSpreadsheet().setActiveSheet(restrictionSheet);
}
Expand All @@ -79,11 +79,11 @@ function loadPreferences() {
}

function addRestrictionHandler(params) {

var ontology = params.ontology.trim();
var columnName = params.columnName.trim();
var service = params.service.trim();

var restrictionSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Restrictions");

if (restrictionSheet == undefined) {
Expand All @@ -99,7 +99,7 @@ function addRestrictionHandler(params) {
SpreadsheetApp.getActiveSpreadsheet().setActiveSheet(activeSheet);
}


if(columnName !== "") {
var nextBlankRow = findNextBlankRow(restrictionSheet);
restrictionSheet.getRange(nextBlankRow, 1).setValue(columnName);
Expand All @@ -108,7 +108,7 @@ function addRestrictionHandler(params) {
restrictionSheet.getRange(nextBlankRow, 6).setValue(service);
return "Restriction for " + columnName + " Added"
}

return "Column name cannot be empty."
}

Expand Down Expand Up @@ -205,3 +205,39 @@ function getOLSOntologies() {
return ontologyDict;
}


/**
* @method
* @name getTIBOLSOntologies
* @description gets all the ontologies from TIB-OLS
* @return{Object}
*/
function getTIBOLSOntologies() {
var ontologiesUri = TIBOLS_API_BASE_URI + "/ontologies?size=" + OLS_PAGINATION_SIZE;
var cache = CacheService.getPrivateCache(), res, text, json, ontologies = [];

if (cache.get("tib-ols") == null) {
do {
res = UrlFetchApp.fetch(ontologiesUri);
text = res.getContentText('utf-8');
json = JSON.parse(text);
ontologies = ontologies.concat(json._embedded.ontologies);
ontologiesUri = json._links && json._links.next && json._links.next.href;
}
while (ontologiesUri);
// store into cache the result as plain text
splitResultAndCache(cache, "tib-ols", JSON.stringify(ontologies));
} else {
ontologies = JSON.parse(getCacheResultAndMerge(cache, "tib-ols"));
}

var ontologyDict = {};
ontologies.forEach(function(ontology) {
var config = ontology.config || {};
ontologyDict[ontology.ontologyId] = {
name: config.title,
uri: config.id
};
});
return ontologyDict;
}
5 changes: 3 additions & 2 deletions Utils.gs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@


// constants
var OLS_API_BASE_URI = "http://www.ebi.ac.uk/ols/api";
var TIBOLS_API_BASE_URI = "https://service.tib.eu/ts4tib/api";
var OLS_API_BASE_URI = "http://www.ebi.ac.uk/ols4/api";
var OLS_PAGINATION_SIZE = 500; // MAX pagination size

/**
Expand Down Expand Up @@ -361,4 +362,4 @@ function replaceControlCharacters(text) {
} catch (e){
return text;
}
}
}