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

Pjotr Prins pjotr.public14 at thebird.nl
Sat Jul 17 09:22:30 UTC 2010

Hi Anurag,

I'll go over the Specs in a short time. First thing that is
interesting to note is that the elaborage class hierarchy does not
show in the unit tests, nor Specs. This is indicates they are not
really needed. E.g. search for 

grep -r ProteinCellRow *
grep -r RestrictionSeqRow *

Does not render any tests. Which is to be expected.

I know you haven't gotten round to refactoring, but you can see what
I mean?

When designing a class hierarchy, it can best be driven from the API.
That is one reason behaviour driven testing - or even unit testing is
done upfront.

Meanwhile, there is a second good reason to introduce an OOP hierarchy
- it is when it makes 'internal' code easier to understand. 

You should judge every new class you introduce based on those
grounds: Does it add to, or simplify, my API? Or does it make my
internal code organisation a lot easier to understand. Tick one of
those two boxes to create class hierarchies. Otherwise you are best
off with the most *simple* data representation. Simple, in general,
is easy to understand and allows for more flexible approaches.


On Thu, Jul 15, 2010 at 08:27:45PM +0530, Anurag Priyam wrote:
> Hello all,
> I have worked out an initial set of specs for the RDF API. The code is in
> 'rdf' branch - http://github.com/yeban/bioruby/tree/rdf.
> I am providing an overview here:
> To start with I have put the specs in bioruby/spec directory. I took the
> liberty of adding a rake task to execute all the specs. Most of the specs
> will fail as of now and some are pending. "rake spec SPEC_OPTS="--format
> nested" " should be good to get a rough overview of the specs.
> The lib itself( currently only bare class definition ) resides in
> bioruby/lib/bio/rdf directory and uses Bio::RDF namespace.
> At the core are Literal, Node, URI and classes, which form the subject,
> predicate, object and context of any RDF statement. An RDF statement can be
> created as an instance of Statement class. A collection of Statements form a
> Graph. An RDF graph can be queried for statements with a given subject,
> predicate or object. We can define new Vocabularies with the Vocabulary
> class. I am explaining the vocabulary class in more detail below.
> RDF vocabularies are defined on a namespace uri. Say, the XSD vocabulary
> that defines datatypes for literals. XSD is defined on "
> http://www.w3.org/2001/XMLSchema#" namespace with the 'xsd' prefix. So the
> actual URI for the curie "xsd:double" goes like "
> http://www.w3.org/2001/XMLSchema#double". The rational is to have such URI
> and curie automatically generated :
> xsd = Vocabulary.new "http://www.w3.org/2001/XMLSchema#"
> xsd[:double]
> I was thinking of having commonly used vocabulary defined in the lib so
> someone could use it out of box like: XSD[:double] or CDAO[:foo].
> 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]
> I think with this design we can maintain loose coupling between the rdf lib
> and bioruby components. I have just begun creating the classes to realize
> the specs, so the design can still be modified completely if I am in a wrong
> direction.
> In thinking out the rdf lib, I have mostly referred to the RDF primer and
> Wikipedia. I might have gone wrong on some RDF concepts too. Please correct
> :).
> -- 
> Anurag Priyam,
> 2nd Year Undergraduate,
> Department of Mechanical Engineering,
> IIT Kharagpur.
> +91-9775550642
> _______________________________________________
> BioRuby Project - http://www.bioruby.org/
> BioRuby mailing list
> BioRuby at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioruby

More information about the BioRuby mailing list