How can I express with SPARQL the following query:
"Given you have 'patternSpectrum', holding a set of peaks, with specified numerical values of their heights, do SELECT all spectrums which hold a set of peaks, where each of their peaks corresponds to exactly one peak in patternSpectrum, within a numerical limit of 0.3 units"
So, some kind of search for spectra with near-matches of all it's peaks' heights with the peaks of a given "pattern spectrum" or "search spectrum".
I was able to express this search in Prolog, as documented in http://saml.rilspace.com/content/backtracking-key-difference-between-sparql-and-prolog (the third code snippet), but so far NOT in SPARQL :|
One of the problems seems to be that arithmetic operations can only be done in FILTER constructs, and not the SELECT statements. But also, since it is a comparison of a set of peaks, which has to match one-to-one to another set, it seems like the backtracking feature of Prolog becomes indispensable ... but maybe I'm missing something?
I'm fearing that it possibly has to involve some OWL definitions (though I had some difficulties finding out how to do that as well :|), and of course I'd hope for a solution solely in SPARQL since this application really is a search problem and not a classification one. (Though, hints about how to do this in OWL are highly welcome too!)
EDIT: An extract from the sample data I'm using, describing a spectrum, having peaks, which each have a numerical-value shift:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:nmr="http://www.nmrshiftdb.org/onto#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:chem="http://www.blueobelisk.org/chemistryblogs/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:bibo="http://purl.org/ontology/bibo/">
<rdf:Description rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?spectrumId=4735">
<nmr:spectrumId>4735</nmr:spectrumId>
<nmr:spectrumType>13C</nmr:spectrumType>
<nmr:hasPeak><nmr:peak rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?s4735p0">
<nmr:hasShift rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">17.6</nmr:hasShift>
</nmr:peak></nmr:hasPeak>
... [more peaks] ...
</rdf:Description>
...
</rdf:RDF>
What I want to retrieve is a list of spectra which satisfies the criteria (that there is one corresponding peak shift value for each of a list of numerical values which the user provides).