Skip to content

Instantly share code, notes, and snippets.

@abargnesi
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save abargnesi/002112aa481e6bfa83d2 to your computer and use it in GitHub Desktop.

Select an option

Save abargnesi/002112aa481e6bfa83d2 to your computer and use it in GitHub Desktop.
Custom resources when parsing BEL Script
require 'bel'
# Load RDF extension; Loaded by default
BEL::Extension.load_extension 'rdf/rdf'
# Define your resources including the URI.
resource_overrides = {
:MESHDISEASE => NamespaceDefinition.new(
:MESHDISEASE,
'http://resource.belframework.org/belframework/20150611/namespace/mesh-diseases.belns',
'http://www.openbel.org/bel/namespace/mesh-disease'
),
}
# Parse your BEL file with the custom resources.
rdf_triples = BEL::Script.
parse(File.open('your_file.bel'), resource_overrides).
select { |obj| obj.is_a? BEL::Model::Statement }.
flat_map { |stmt| stmt.to_rdf[1] }
# Do something with triples...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment