Introduction

Once you have submitted some ontologies into the BioPortal Ontology Services (BioPortal Core), you can use these to populate the backend data sets required by the Annotator Web Service. These datasets are collectively referred to as the Annotator datasets and comprise: The hierarchy database (formerly known as "OBS"), a dictionary file, and (optionally) a mapping database. The population process uses classes, terms, relations, and semantic types from the ontologies. The population is done in two major steps: 1) Synchronize the hierarchy database with BioPortal Core and 2) Create the dictionary file for use with MGREP. A third step, populating mapping information, should be done if there are mappings available.

Synchronize Hierarchy Database with Ontology Services

Note: All NCBO REST Web services will be required to contain the parameter "apikey=YourApiKey" starting June 2011. As a result, the "ObsApiKey" parameter should now be appended to all the OBS worklflow execution urls.

The ontologies and related data that will be used by the Annotator are gathered from the Ontology Services (part of BioPortal Core). This process should be run any time a new ontology (or a new version of an existing ontology) is added to the Ontology Services, though it could theoretically be run from a cron script or scheduled job.

Remove out-dated ontologies from hierarchy database (e.g. older version of ontologies that does not in BioPortal anymore). By invoking this restlet, it will remove all the outdated ontology data and the associated entities such as concepts, terms, relations, semantic types and hierarchy information.

Add new ontologies from BioPortal to the hierarchy database. By invoking this restlet, it will add all the new ontology data and the associated entities such as concepts, terms, relations, semantic types and hierarchy information.

The dictionary file is generated in several chunks to avoid memory problems. There is a 1,000,000 term limit per file.

Generate the dictionary file:

http://example/obs/createDictionary/0?apikey=ObsApiKey

After the files are generated, you can run the command ncborestart to concatenate the resulting dictionary files and to restart the MGREP server.

Mapping Data Population

Mappings between ontologies can be used in the Annotator Web Service to find related terms. Loading the mapping information is currently a manual process, though this will be automated in the future. If you have mapping data you would like to include in annotator, please contact NCBO.

Appendix

Data Population - Concepts and Hierarchy

Introduction: the Annotator hierarchy database population application pulls the ontology and the concept data from BioPortal Core via the REST services, then extracts and computes the hierarchy information, and finally stores the information in the hierarchy database. Then this computed data is accessible via the Annotator REST services.

Data population is divided into two parts: 1) Concepts and 2) Hierarchy. Please see below for details on these two population procedures.

Concepts and Direct Relation (level == 1)

Pre-requisite in "status":

The ontology should be in valid status ("status = 3") in the obs_ontology table in Hierarchy Database to start this process (i.e. This is the initial status from BioPortal Core when ontology is successfully parsed). This is also serves as a safety lock to avoid launching population again for ontologies that are already in the process of population or already populated.

Troubleshooting

Errors are logged both in Tomcat catalina.out and DB (obs_error_queue table).

Case 1: BioPortal REST Service is Down

When you kick off the process using the Annotator REST call - either via web browser or shell script - it checks first if BioPortal REST service is alive. If the BioPortal REST service is down – the tomcat log will generate an error message about BioPortal REST service being down (But it does not change the ontology "status" field. Just simply kick off the process again when BioPortal REST service is back up. If BioPortal REST service is down, no change in Annotator database, therefore no need to clean up. See "Error Handling" for the "status" change scenario).

Case 2: Critical Error

If the error is critical – RunTimeException and etc – the "status" the ontology in obs_ontology table becomes "99" and the data population process halts.

Case 3: Non-critical Error

If the error is not critical, the "status" the ontology in obs_ontology table becomes "99" but the data population process still continues to populate the rest of the data. An example for a non-critical error is a discrepancy between the data from two different BioPortal REST calls – i.e. Some of the root concepts from getRootConcepts call are missing in BioPortal (The list of concepts from getAllConcepts does not have some of the root concepts).

In the case of case 2 & 3, data clean up may be necessary. Please see "Data Clean-Up".

Indirect Relation Hierarchy (level > 1)

Pre-requisite in "status":

The ontology should be in valid status ("status = 14") in obs_ontology table in Hierarchy Database to start this process (i.e. "loaderBigConcepts" should have been completed for the given ontology). This is a safety lock to avoid launching population again for the ontologies already in the process of population or already populated.

Monitoring the Progress

To monitor the progress, please see "status" field in obs_ontology table.

Restlets

Status Required (valid status required to begin the process)

Status Start -> Finish

loaderBigConcepts

3

11 -> 14

loaderBigPaths

14

21 -> 28

(status value in obs_ontology table changes as progress continues)

Error Handling:

If there is any error, the status will be set to 99

If critical error (e.g. BioPortal REST services down) occurs, the population process will stop and exit. But if it is NOT a critical error (e.g. if the semantic type description is not found from semantic look up table etc), it will mark the status to 99, log the error (both Tomcat log and DB obs_error_queue), but continue with the population.

To restart the process, just run the script to clean up. The script will reset the status either to "3" or "14" depending on Concept clean up or Hierarchy clean up. (See Section II. Data Clean up)

Data Clean-Up

The source for several SQL commands that can be used to clean up data after an aborted population attempt is located in /ncbo/sources/annotator/2004/db/sql/obs_db_cleanup.sql – DO NOT RUN the entire script since this is just compiled list of commands.

Useful SQL Queries for Monitoring and Validation

The source for several queries that can be used for monitoring and data validation is located in /ncbo/sources/annotator/2004/db/sql/obs_db_cleanup.sql (In the same file as the Data Clean-Up)

To check if there are multiple entries for an Ontology

select name, virtual_ontology_id, local_ontology_id
from obs_ontology
group by virtual_ontology_id
having count(virtual_ontology_id)>1;

Number of concepts for a specific Ontology

select OT.name, OT.local_ontology_id AS local_ontology_id,
count(CT.id) AS concepts, OT.status from obs_ontology OT
left join obs_concept CT ON CT.ontology_id=OT.id
WHERE OT.local_ontology_id in ('40133')
GROUP BY OT.local_ontology_id;