|
Hello Stefan, All,
A sample Java code, using Jena, will illustrate the difference
between duplicated properties and bags:
==========
package org.vcell.sybil.rdf.smelt;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.vocabulary.RDF;
public class TestRDFBag {
public static void main(String[] args) {
Model model = ModelFactory.createDefaultModel();
String ns = "http://example.org/";
Resource r1 = model.createResource(ns + "r1");
Resource r2 = model.createResource(ns + "r2");
Resource r3 = model.createResource(ns + "r3");
Resource r4 = model.createResource(ns + "r4");
Resource c1 = model.createResource(ns + "c1");
Resource c2 = model.createResource(ns + "c2");
Resource b = model.createResource();
Property p = model.createProperty(ns + "p");
model.setNsPrefix("ex", ns);
model.add(r3, RDF.type, c2);
model.add(r4, RDF.type, c2);
model.add(r1, RDF.type, c1);
model.add(r1, p, r3);
model.add(r1, p, r4);
model.add(r2, RDF.type, c2);
model.add(r2, p, b);
model.add(b, RDF.type, RDF.Bag);
model.add(b, RDF.li(1), r3);
model.add(b, RDF.li(2), r4);
model.write(System.out, "RDF/XML-ABBREV");
System.out.println("==========");
model.write(System.out, "N-TRIPLE");
System.out.println("==========");
model.write(System.out, "N3");
}
}
==========
The output of this is as follows:
==========
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:ex="http://example.org/">
<ex:c2 rdf:about="http://example.org/r2">
<ex:p>
<rdf:Bag>
<rdf:li>
<ex:c2 rdf:about="http://example.org/r3"/>
</rdf:li>
<rdf:li>
<ex:c2 rdf:about="http://example.org/r4"/>
</rdf:li>
</rdf:Bag>
</ex:p>
</ex:c2>
<ex:c1 rdf:about="http://example.org/r1">
<ex:p rdf:resource="http://example.org/r4"/>
<ex:p rdf:resource="http://example.org/r3"/>
</ex:c1>
</rdf:RDF>
==========
<http://example.org/r3>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://example.org/c2> .
_:A4a46e254X3aX123c96c9bf3X3aXX2dX8000
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_2>
<http://example.org/r4> .
_:A4a46e254X3aX123c96c9bf3X3aXX2dX8000
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
<http://example.org/r3> .
_:A4a46e254X3aX123c96c9bf3X3aXX2dX8000
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag> .
<http://example.org/r1> <http://example.org/p> <http://example.org/r4> .
<http://example.org/r1> <http://example.org/p> <http://example.org/r3> .
<http://example.org/r1>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://example.org/c1> .
<http://example.org/r4>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://example.org/c2> .
<http://example.org/r2> <http://example.org/p>
_:A4a46e254X3aX123c96c9bf3X3aXX2dX8000 .
<http://example.org/r2>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://example.org/c2> .
==========
@prefix ex: <http://example.org/> .
ex:r2
a ex:c2 ;
ex:p [ a <http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
ex:r3 ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_2>
ex:r4
] .
ex:r4
a ex:c2 .
ex:r1
a ex:c1 ;
ex:p ex:r3 , ex:r4 .
ex:r3
a ex:c2 .
==========
Take care
Oliver
On Thu, Sep 17, 2009 at 2:03 PM, shoops <shoops@vbi.vt.edu> wrote:
> Hello Oliver,
>
> On Thu, 17 Sep 2009 11:40:00 -0400
> Oliver Ruebenacker <curoli@gmail.com> wrote:
>
>> Hello Stefan, All,
>>
>> On Thu, Sep 17, 2009 at 8:31 AM, shoops <shoops@vbi.vt.edu> wrote:
>> >> <bqbiol:isVersionOf>
>> >> <rdf:bag>
>> >> <rdf:li rdf:resource="http://some.uri.thing.1"/>
>> >> <rdf:li rdf:resource="http://some.uri.thing.2"/>
>> >> <rdf:li rdf:resource="http://some.uri.thing.3"/>
>> >> <rdf:li rdf:resource="http://some.uri.thing.4"/>
>> >> </rdf:bag>
>> >> </bqbiol:isVersionOf>
>> >>
>> >> which is 1 CVTerm with 4 resources :-)
>> >>
>> >
>> > Actually :(
>> >
>> > because from the standpoint from RDF we have for triplets:
>> > subject: ???, predicate: bqbiol:isVersionOf, resource: ...1
>> > subject: ???, predicate: bqbiol:isVersionOf, resource: ...2
>> > subject: ???, predicate: bqbiol:isVersionOf, resource: ...3
>> > subject: ???, predicate: bqbiol:isVersionOf, resource: ...4
>> >
>> > Therfore I would expect the count of stements to be 4. The tags bag
>> > and li are just used for convenience/human readability. They do not
>> > change the datamodel.
>>
>> Maybe it is equvalent for SBML/MIRIAM purposes, but in terms of RDF,
>> a bag is not a convenience notation for similar statements. A bag is
>> an object that represents a set, and the resulting statements are
>> different. For example, to say that Obama has two daughters, without
>> bags, you would say (in N3 notation):
>>
>> ex:Obama ex:hasChild ex:Malia .
>> ex:Obama ex:hasChild ex:Sasha .
>>
>> with a bag, the equivalent to above situation would be:
>>
>> ex:Obama ex:hasChildren _:b0 .
>> _:b0 rdf:type rdf:bag .
>> _:b0 rdf:li ex:Malia .
>> _:b0 rdf:li ex:Sasha .
>>
>> where _:b0 is a blank node. Instead of a blank node, you could also
>> use a named node, such as:
>>
>> ex:Obama ex:hasChildren ex:ObamaChildren .
>> ex:ObamaChildren rdf:type rdf:bag .
>> ex:ObamaChildren rdf:li ex:Malia .
>> ex:ObamaChildren rdf:li ex:Sasha .
>>
>> In any case, that makes one statement involving ex:Obama, but four
>> statements total.
>>
>> Take care
>> Oliver
>>
>
> Your example differs from the SBML example. You use 2 different
> predicates:
> ex:hasChild and ex:hasChildren
> therfore it does not apply since in SBML we use just bqbiol:isVersionOf
> which means that
>
> <bqbiol:isVersionOf>
> <rdf:bag>
> <rdf:li rdf:resource="http://some.uri.thing.1"/>
> <rdf:li rdf:resource="http://some.uri.thing.2"/>
> <rdf:li rdf:resource="http://some.uri.thing.3"/>
> <rdf:li rdf:resource="http://some.uri.thing.4"/>
> </rdf:bag>
> </bqbiol:isVersionOf>
>
> is from the content view equivalent to:
>
> <bqbiol:isVersionOf rdf:resource="http://some.uri.thing.1"/>
> <bqbiol:isVersionOf rdf:resource="http://some.uri.thing.2"/>
> <bqbiol:isVersionOf rdf:resource="http://some.uri.thing.3"/>
> <bqbiol:isVersionOf rdf:resource="http://some.uri.thing.4"/>
>
> If you do not belive me try the raptor library implemented by Dave
> Beckett, who is and expert in this field, to generate the triplets and
> write them out in a compact versus verbose format.
>
> Thanks,
> Stefan
>
>
> --
> Stefan Hoops, Ph.D.
> Senior Project Associate
> Virginia Bioinformatics Institute - 0477
> Virginia Tech
> Bioinformatics Facility II
> Blacksburg, Va 24061, USA
>
> Phone: (540) 231-1799
> Fax: (540) 231-2606
> Email: shoops@vbi.vt.edu
> ____________________________________________________________
> To manage your sbml-interoperability list subscription, visit
> https://utils.its.caltech.edu/mailman/listinfo/sbml-interoperability
>
> For a web interface to the sbml-interoperability mailing list, visit
> http://sbml.org/Forums/
>
> For questions or feedback about the sbml-interoperability list,
> contact sbml-team@caltech.edu
>
--
Oliver Ruebenacker, Computational Cell Biologist
BioPAX Integration at Virtual Cell (http://vcell.org/biopax)
Center for Cell Analysis and Modeling
http://www.oliver.curiousworld.org
____________________________________________________________
To manage your sbml-interoperability list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/sbml-interoperability
For a web interface to the sbml-interoperability mailing list, visit
http://sbml.org/Forums/
For questions or feedback about the sbml-interoperability list,
contact sbml-team@caltech.edu
|