Last active
August 29, 2015 14:26
-
-
Save abargnesi/002112aa481e6bfa83d2 to your computer and use it in GitHub Desktop.
Custom resources when parsing BEL Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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