[BioRuby] [GSoC][NeXML and RDF API] RDF API

Anurag Priyam anurag08priyam at gmail.com
Sun Jul 25 18:10:38 UTC 2010

> The rdf lib can be used by any component of BioRuby by using that object as
> the subject or object of an rdf statement. However, a cleaner solution would
> be to have an Annotatable module mixed into the classes that are likely to
> use the rdf lib. Annotatable would just provide a wrapper over the core rdf
> lib to work with rdf. To begin with I have added two functions 'annotate'
> and 'annotation' which create and return a rdf graph for that object
> respectively. The example for these functions is pending in the specs.
> However, I was thinking of something like:
> seq = Bio::Sequece.new
> seq.annotate do |graph|
>   graph << [self, CDAO[:foo], 'moo' ]
> end
> seq.annotation.query :predicate => CDAO[:foo]

Here is what I have done:

I would like you all to have a rough overview of graph.rb,
mixins/enumerable.rb and mixins/queryable.rb

So a graph contains RDF::Statements that can be enumerated and queried over
in various movies.

Then have a look at the Annotatable module:

To make a class annotatable this module just needs to be included. Say:
class Bio::NeXML::Otu
  include Bio::RDF::Annotatable

The idea is to add an instance variable( @graph ) to Otu that stores a
RDF::Graph object and delegate methods that begin with 'rdf_' to @graph.
This way all the API defined for a Graph is available to an Annotatable
object( by prefixing the method names with an 'rdf_' )

otu = Bio::NeXML::Otu.new( 't1')
otu.annotate do |g|
  g << [ otu, CDAO[ :label ], "XXX" ]
  g << [ otu, CDAO[ :discoverer ], "Moo" ]

otu.rdf_query( :predicate => CDAO[ :label ] ) { |s| puts s.subject }

is same as

otu.annotation.query(:predicate => CDAO[ :label ]) { |s| puts s.subject }

Anurag Priyam,
3rd Year Undergraduate,
Department of Mechanical Engineering,
IIT Kharagpur.

More information about the BioRuby mailing list