obofoundry

Crates.ioobofoundry
lib.rsobofoundry
version0.11.0
sourcesrc
created_at2019-03-19 23:54:10.727434
updated_at2024-09-10 14:54:15.573776
descriptionStructures to deserialize OBO Foundry listings into.
homepage
repositoryhttps://github.com/althonos/obofoundry.rs
max_upload_size
id122596
size26,900
Martin Larralde (althonos)

documentation

README

obofoundry.rs Star me

Structures to deserialize OBO Foundry listings into.

Actions Codecov License Source Crate Documentation Changelog

Usage

Add the obofoundry crate to the Cargo.toml manifest, as well as either serde_yaml or serde_json:

[dependencies]
obofoundry = "0.11"
serde_yaml = "0.8"

Then use the serde framework to load the listings:

extern crate obofoundry;
extern crate serde_yaml;

let yaml_data = include_str!("...");
let foundry: obofoundry::Foundry = serde_yaml::from_str(&yml).unwrap();

It's also possible to use an HTTP library to load the listings from the OBO Foundry website directly, for instance using ureq:

extern crate obofoundry;
extern crate ureq;
extern crate serde_yaml;

let url = "http://www.obofoundry.org/registry/ontologies.yml";

let res = ureq::get(url).call();
let reader = res.unwrap().into_reader();
let foundry: obofoundry::Foundry = serde_yaml::from_reader(reader).unwrap();

Example

Download the ontologies.yml table from the OBO Foundry and use it to extract all PURLs to ontologies in the OBO format:

extern crate obofoundry;
extern crate ureq;
extern crate serde_yaml;
use std::io::Read;

const URL: &'static str = "http://www.obofoundry.org/registry/ontologies.yml";

fn main() {
    let res = ureq::get(URL).call();
    let reader = res.unwrap().into_reader();

    let foundry: obofoundry::Foundry = serde_yaml::from_reader(reader).unwrap();
    for ontology in &foundry.ontologies {
        for product in &ontology.products {
            if product.id.ends_with(".obo") {
                println!("{} - {}", product.id, product.ontology_purl)
            }
        }
    }
}

See the online documentation at docs.rs for more examples.

Changelog

This project adheres to Semantic Versioning and provides a changelog in the Keep a Changelog format.

License

This library is provided under the open-source MIT license.

Commit count: 75

cargo fmt