Dear Scott, All, Of course learning more about SPIN is the whole goal. And now that I am trying to use TBC things are going quite smoothly. TBC is very intuitive, which is very good.
What I meant with saying that SPARQL to automatic conversion SPIN is not possible. SPARQL to SPIN constraint is and TBC/SPIN API do this very well. However, the generated SPIN constraint still needs to be attached to an rdfs:Class. See my earlier problem which Holger was very kind to solve for me. This attachment needs to be done by writing triples outside of the SPARQL query. Which is of course handled by TBC. And as you say needs to be done in my application or by using TBC to maintain the rules. I think that for us using TBC to maintain the rules makes a lot of sense. However, the execution of the checking needs to be done by an offline non interactive tool for which SPIN API matches very well. In practice I am writing JUnit tests for the constraints. So I use our internal domain java objects which are transformed to triples. And these triples are validated using spin API for constraints. Then there are asserts about the constraint found. In any case I am very happy with my progress due to Holgers excellent help and the well working tools provided. Regards, Jerven On Jan 26, 2011, at 3:04 PM, Scott Henninger wrote: > Jerven; Automatic conversion to/from SPIN is fully supported in all > TopBraid products. I'd suggest taking a look at the SPIN tutorial at > http://www.topquadrant.com/products/SPIN.html to learn more about how > SPIN works. This includes how to attach queries to spin:query > properties in classes so the SPARQL queries (rules) operate across > members of the class. > > If your intent is to use the SPIN API to create you own tool, > conversions to/from SPIN is part of the API and you will need to > develop the procedures that do this for your application. The advice > to learn a bit more about SPIN remains a good suggestions. Also see > http://spinrdf.org. > > -- Scott > > On Jan 26, 2:04 am, Jerven Bolleman <[email protected]> > wrote: >> Hi Holger, All, >> >> Just to make sure I understand correctly. The SPARQL query can not be >> converted into SPIN rules automatically only the other way round is >> possible. ie. SPIN -> SPARQL OK while SPARQL->SPIN !OK. Mostly because >> the SPARQL construct query can not be associated with a class in SPARQL >> (at least I think so). >> >> Which means that I need to generate SPIN rules as input not SPARQL. >> >> Regards, >> Jerven >> >> On 01/26/2011 12:16 AM, Holger Knublauch wrote: >> >>> Hi Jerven, >> >>> I recommend using a tool (TBC Free Edition) to edit SPIN files. Creating >>> them by hand is tricky, and TBC has some design patterns built in to help >>> you get started. In particular, the file you have sent does not contain an >>> owl:Ontology and no owl:imports (http://spinrdf.org/spinshould be >>> imported). Another issue is that the classes are untyped. >> >>> But the main issue that your CONSTRUCT query is not attached to any class. >>> If you want the SPIN engine to execute it, you need to link a class with >>> the constraints using spin:constraint. I have done this in the attached >>> version of your file. Use TBC FE (or higher) to open it, and you will see >>> that I have changed your query to be attached to :Protein. Instead of >>> ?entry as a variable, I am using ?this to refer to "all instances of >>> :Protein". Use the Refresh and Show problems (constraints) to see the >>> violation (which works fine in principle). >> >>> If you want to run the same in the SPIN API, you may need to make sure that >>> you also add the imported SPIN graph (and its SP import) to the OntModel. >> >>> HTH >>> Holger >> >>> On Jan 26, 2011, at 12:24 AM, [email protected] wrote: >> >>>> Hi Everyone, >> >>>> I am having difficulty getting beyond the examples in SPIN API. >> >>>> I try to get a SPARQL query to construct a constraint violation. Which >>>> will be triggered by SPIN. >> >>>> The data I start with is in Turtle: >>>> @prefix :<http://purl.uniprot.org/core/> . >>>> @prefix keyword:<http://purl.uniprot.org/keywords/> . >>>> @prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#> . >> >>>> uniprot:P00001 >>>> a :Protein ; >>>> :annotation<http://purl.uniprot.org/uniprot/ >>>> #_503030303031001> ; >>>> :reviewed "false" . >> >>>> <http://purl.uniprot.org/uniprot/#_503030303031001> >>>> a :PTM_Annotation ; >>>> rdfs:comment "ubiquitination" . >> >>>> The construct query I am trying is this >>>> PREFIX :<http://purl.uniprot.org/core/> >>>> PREFIX keyword:<http://purl.uniprot.org/keywords/> >>>> PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> >>>> PREFIX spin:<http://spinrdf.org/spin#> >>>> PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> >> >>>> CONSTRUCT { >>>> _:violation a spin:ConstraintViolation ; >>>> spin:violationRoot ?entry; >>>> spin:violationPath :classifiedWith; >>>> rdfs:label "If word ubiquitination is found: keyword:832 is >>>> required" >>>> } WHERE { >>>> ?entry a :Protein . >>>> ?entry :annotation ?annotation . >>>> ?annotation rdf:type :PTM_Annotation ; >>>> } >> >>>> This is combined into one ontModel >>>> @prefix :<http://purl.uniprot.org/core/> . >>>> @prefix citation:<http://purl.uniprot.org/citations/> . >>>> @prefix sp:<http://spinrdf.org/sp#> . >>>> @prefix keyword:<http://purl.uniprot.org/keywords/> . >>>> @prefix dcterms:<http://purl.org/dc/terms/> . >>>> @prefix annotation:<http://purl.uniprot.org/annotation/> . >>>> @prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#> . >>>> @prefix xsd:<http://www.w3.org/2001/XMLSchema#> . >>>> @prefix owl:<http://www.w3.org/2002/07/owl#> . >>>> @prefix spin:<http://spinrdf.org/spin#> . >>>> @prefix rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> . >>>> @prefix skos:<http://www.w3.org/2004/02/skos/core#> . >>>> @prefix uniprot:<http://purl.uniprot.org/uniprot/> . >> >>>> _:b1 sp:varName "comment"^^xsd:string . >> >>>> uniprot:P00001 >>>> a :Protein ; >>>> :annotation<http://purl.uniprot.org/uniprot/ >>>> #_503030303031001> ; >>>> :reviewed "false" . >> >>>> [] a sp:Construct ; >>>> sp:templates ([ sp:object spin:ConstraintViolation ; >>>> sp:predicate rdf:type ; >>>> sp:subject _:b2 >>>> ] [ sp:object _:b3 ; >>>> sp:predicate spin:violationRoot ; >>>> sp:subject _:b2 >>>> ] [ sp:object :classifiedWith ; >>>> sp:predicate spin:violationPath ; >>>> sp:subject _:b2 >>>> ] [ sp:object "If word ubiquitination is found: >>>> keyword:832 is required" ; >>>> sp:predicate rdfs:label ; >>>> sp:subject _:b2 >>>> ]) ; >>>> sp:where ([ sp:object :Protein ; >>>> sp:predicate rdf:type ; >>>> sp:subject _:b3 >>>> ] [ a sp:Filter ; >>>> sp:expression >>>> [ a sp:notExists ; >>>> sp:elements ([ sp:object<http:// >>>> purl.uniprot.org/keywords/832> ; >>>> sp:predicate :classifiedWith ; >>>> sp:subject _:b3 >>>> ]) >>>> ] >>>> ] [ sp:object _:b4 ; >>>> sp:predicate :annotation ; >>>> sp:subject _:b3 >>>> ] [ sp:object :PTM_Annotation ; >>>> sp:predicate rdf:type ; >>>> sp:subject _:b4 >>>> ] [ sp:object _:b1 ; >>>> sp:predicate rdf:comment ; >>>> sp:subject _:b4 >>>> ] [ a sp:Filter ; >>>> sp:expression >>>> [ a sp:regex ; >>>> sp:arg1 _:b1 ; >>>> sp:arg2 "ubiquitination" >>>> ] >>>> ]) . >> >>>> <http://purl.uniprot.org/uniprot/#_503030303031001> >>>> a :PTM_Annotation ; >>>> rdfs:comment "ubiquitination" . >> >>>> _:b4 sp:varName "annotation"^^xsd:string . >> >>>> _:b3 sp:varName "entry"^^xsd:string . >> >>>> This all seems ok to my inexperienced eyes. So I expect the SPARQL >>>> construct query to trigger. The example SPARQL triggers when tested >>>> against a SPARQL store (e.g.this returns data at linkedlifedata.com). >> >>>> Therefore I assume I am adding the SPARQL incorrectly to the OntModel. >>>> This is the main part of the code. >>>> Model model = >>>> ModelFactory.createDefaultModel(ReificationStyle.Minimal); >>>> setPrefixes(model); >>>> ARQ2SPIN arq2SPIN = new ARQ2SPIN(model); >>>> query = arq2SPIN.createQuery(ARQFactory.get().createQuery(model, >>>> rule), null); >> >>>> public List<ConstraintViolation> runRule() >>>> { >>>> SPINModuleRegistry.get().init(); >>>> // Create OntModel with imports >>>> OntModel ontModel = >>>> ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, entryModel); >>>> setPrefixes(ontModel); >>>> ontModel.add(query.getModel()); >> >>>> ontModel.write(System.out, FileUtils.langN3); //Prints out >>>> ontModel >>>> shown above. >>>> // Create and add Model for inferred triples >>>> Model newTriples = >>>> ModelFactory.createDefaultModel(ReificationStyle.Minimal); >>>> ontModel.addSubModel(newTriples); >> >>>> SPINModuleRegistry.get().registerAll(ontModel); >> >>>> // Run all inferences >>>> SPINInferences.run(ontModel, newTriples, null, null, false, >>>> null); >> >>>> System.out.println("Inferred triples: " + >>>> newTriples.size()); >> >>>> // Run all constraints >>>> List<ConstraintViolation> cvs = >>>> SPINConstraints.check(ontModel, >>>> null); >>>> System.out.println("Constraint violations:"); >>>> for (ConstraintViolation cv : cvs) >>>> { >>>> System.out.println(" - at " + >>>> SPINLabels.get().getLabel(cv.getRoot()) + ": " + cv.getMessage()); >>>> } >>>> return cvs; //Empty but I expect at least one hit. >>>> } >> >>>> Could anyone be so nice as to tell me where I am going wrong? >> >>>> Thanks very much! >> >>>> Regards, >>>> Jerven >> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Group "TopBraid Suite Users", the topics of which include TopBraid >>>> Composer, >>>> TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN. >>>> To post to this group, send email to >>>> [email protected] >>>> To unsubscribe from this group, send email to >>>> [email protected] >>>> For more options, visit this group at >>>> http://groups.google.com/group/topbraid-users?hl=en >> >> >> >> jerven_bolleman.vcf >> < 1KViewDownload > > -- > You received this message because you are subscribed to the Google > Group "TopBraid Suite Users", the topics of which include TopBraid Composer, > TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN. > To post to this group, send email to > [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/topbraid-users?hl=en -- You received this message because you are subscribed to the Google Group "TopBraid Suite Users", the topics of which include TopBraid Composer, TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/topbraid-users?hl=en
