obofoundry.rs

Structures to deserialize OBO Foundry listings into.

TravisCI 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:

toml [dependencies] obofoundry = "0.1" serde_yaml = "0.8"

Then use the serde framework to load the listings:

```rust extern crate obofoundry; extern crate serde_yaml;

let yamldata = includestr!("..."); let foundry: obofoundry::Foundry = serdeyaml::fromstr(&yml).unwrap(); ```

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

```rust extern crate obofoundry; extern crate reqwest; extern crate serde_yaml;

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

let mut res = reqwest::get(url).unwrap(); let mut yml = String::new(); res.readtostring(&mut yml);

let foundry: obofoundry::Foundry = serdeyaml::fromstr(&yml).unwrap(); ```

Examples

Print the PURLs of all obo ontologies in the OBO Foundry

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