Published March 6, 2025 | Version v2
Software Open

Taxonomy OWLizer

  • 1. University of Twente
  • 2. Universidade de São Paulo

Description

This version includes the documentation of the web-based app developed for this script, available at https://filipi-soares.github.io/TaxonOWLConverter/.

Overview

This script fetches taxonomic classification data for given species names from the GBIF API and generates an OWL ontology representation of the taxonomy. It ensures that only accepted scientific names are included in the OWL representation, ignoring synonyms.

Requirements

  • Python 3.x
  • requests library

Functions

fetch_gbif_data(scientific_name)

Fetches taxonomic classification from the GBIF API for a given scientific name.

  • Parameters: scientific_name (str) - The scientific name of the species.
  • Returns: dict - The JSON response from the API containing taxonomic data, or None if the request fails.

Example:

data = fetch_gbif_data("Apis mellifera")
 

fetch_synonyms(species_key)

Fetches synonyms for a given species key from the GBIF API.

Parameters:

species_key (int): The unique key identifying the species in the GBIF database.

Returns:

list: A list of dictionaries, each representing a synonym of the species, or an empty list if the request fails.

Example:

synonyms = fetch_synonyms(1341976)
 

accumulate_taxa(data, taxa)

Accumulates unique taxa and their relationships from the provided taxonomic data into the taxa dictionary.

Parameters:

  • data (dict): The taxonomic data for a species.
  • taxa (dict): A dictionary to store unique taxa and their relationships.

validate_accepted_name(data, taxa)

Ensures that only the accepted scientific name is included in the taxa dictionary by validating against synonyms. Parameters:

generate_owl(taxa)

Generates an OWL representation from the accumulated taxa.

Parameters: taxa (dict) - A dictionary containing unique taxonomic information. Returns: A string containing the OWL representation of the taxonomy.

Usage

  1. Define a list of species names you want to include in the ontology.
species_names = [
    "Apis mellifera",
    "Bos taurus",
    "Capra aegagrus hircus",
    "Ovis aries",
    "Sus",
    "Prochilodus cearensis",
    "Prochilodus scrofa",
    "Prochilodus margravii",
    "Semaprochilodus insignis",
    "Semaprochilodus taeniurus",
    "Colossoma mitrei",
    "Arapaima gigas",
    "Tilapia"
]
 
  1. Iterate through the list of species names, fetch their taxonomic data, accumulate the taxa, and validate accepted names.
taxa = {}
for name in species_names:
    data = fetch_gbif_data(name)
    if data:
        accumulate_taxa(data, taxa)
        validate_accepted_name(data, taxa)
 
  1. Generate the OWL representation from the accumulated taxa.
owl_data = generate_owl(taxa)
print(owl_data)
 

The program generates an OWL representation of the accumulated taxonomy, ensuring that each taxonomic level is included only once, and prints it to the console.

Files

TaxonOWLConverter-main.zip

Files (10.7 kB)

Name Size Download all
md5:48089260213e1ef39b5d57fe5c699e55
10.7 kB Preview Download

Additional details

Funding

Fundação de Amparo à Pesquisa do Estado de São Paulo
A metadata model for interoperability of agricultural databases 21/15125-0

Software

Repository URL
https://github.com/Filipi-Soares/TaxonOWLConverter/tree/main
Programming language
Python, HTML, JavaScript
Development Status
Active