Using the Perl API to register an object
MOBY already has a
rather extensive ontology of data/object types. Still, if you can't find what you need, you have to create your own.
The signature for the registerObject method is as follows:
my $REG = $MOBY->registerObject( objectType => "the name of the Object", description => "a human-readable description of the object", contactEmail => "your@email.address", authURI => "URI of the registrar of this object", Relationships => { relationshipType1 => [ [Object1, articleName], [Object2, articleName]], relationshipType2 => [ [Object1, articleName]], } );For a concrete example of registering an object, let's use the hypothetical
PrimerPair
object that we looked at in
the previous section:
A Hypothetical 'Primer Pair' Object containing two DNASequence objects
<PrimerPair namespace='' id=''> <DNASequence namespace='PrimerDB' id='AS212334' articleName='fivePrime'> <Integer namespace='' id='' articleName='Length'> 23 </Integer> <String namespace='' id='' articleName='SequenceString'> TGGTGTTCACCTCTCTCGTCCTT </String> </DNASequence> <DNASequence namespace='PrimerDB' id='AS8873484' articleName='threePrime'> <Integer namespace='' id='' articleName='Length'> 25 </Integer> <String namespace='' id='' articleName='SequenceString'> GGGCGTGGCAACATGCTGCGCTTGC </String> </DNASequence> </PrimerPair>Note that the outermost PrimaryPair object is anonymous in this case, but it contains two DNASequence objects that are not anonymous; likely derived from some proprietary database in the namespace 'PrimerDB'.
Note also that the Integer and String object's articleName attributes do not change when they are more deeply contained! i.e. the articleName indicates the relationship that contained object has to its immediate parent, not to the outermost parent.
To register the hypothetical PrimerPair
object, you would
use the following code:
use MOBY::Client::Central; my $MOBY=MOBY::Client::Central->new; my $REG=$MOBY->registerObject( objectType => "PrimerPair", description => "a pair of DNA Sequences representing the 5-prime and 3-prime pairs of a PCR primer pair" contactEmail => 'someone@my.organization.org' authURI => "my.organization.org" Relationships => { ISA => [ ['Object', ""], # inherits directly from Object, no articleName ], HASA => [ ['DNASequence',"fivePrime"], ['DNASequence', "threePrime"] ], } ); if ($REG->success) { print "DONE!\n"; } else { print "FAILED!\n ", $REG->message, "\n"; }Note that we use individual HASA relationships, rather than a HAS relationship, to indicate that there are exactly two copies of a contained
DNASequence
object, and in addition, this
allows us to name them differently (i.e. fivePrime and threePrime).
The reason that we inherit directly from Object
(the 'ISA => [Object]
' parameter) is that, other than the two
contained DNASequence objects, there is no other content to this
object - without the fivePrime and threePrime entities, the only
information left is the namespace and
id . Thus we do not inherit from any object
type more complex than Object
.