var start2 = new Date().getTime();
// js.say(blipkit.queryProlog( [ "findMoleculeWithPeakValuesNear", "100", "[23.3, 23.3, 23.5, 23.5, 26.1, 60.5, 90.0, 132.1, 0]", "Molecules" ] ));
js.say(blipkit.queryProlog( [ "findMoleculeWithPeakValuesNear", "100", "[12.5, 13.8, 23.8, 36.5, 44.3, 78.8, 87.3, 133.8, 0]", "Molecules" ] ));
var elapsed2 = (new Date().getTime() - start2)/1000;
js.say("Total time for finding molecule by shift values (Near-search): " + elapsed2 + " s");[['.'('http://pele.farmbio.uu.se/nmrshiftdb/?moleculeId=2189', [])]]
Total time for finding molecule by shift values (Near-search): 2.575 s
[['.'('http://pele.farmbio.uu.se/nmrshiftdb/?moleculeId=10022848', [])],
['.'('http://pele.farmbio.uu.se/nmrshiftdb/?moleculeId=20028275', [])],
['.'('http://pele.farmbio.uu.se/nmrshiftdb/?moleculeId=10009791', [])],
['.'('http://pele.farmbio.uu.se/nmrshiftdb/?moleculeId=10022297', [])],
['.'('http://pele.farmbio.uu.se/nmrshiftdb/?moleculeId=10022294', [])],
['.'('http://pele.farmbio.uu.se/nmrshiftdb/?moleculeId=20000143', [])],
['.'('http://pele.farmbio.uu.se/nmrshiftdb/?moleculeId=10022207', [])],
['.'('http://pele.farmbio.uu.se/nmrshiftdb/?moleculeId=10017654', [])],
['.'('http://pele.farmbio.uu.se/nmrshiftdb/?moleculeId=76533', [])],
['.'('http://pele.farmbio.uu.se/nmrshiftdb/?moleculeId=30085506', [])],
['.'('http://pele.farmbio.uu.se/nmrshiftdb/?moleculeId=76477', [])],
['.'('http://pele.farmbio.uu.se/nmrshiftdb/?moleculeId=89235', [])],
['.'('http://pele.farmbio.uu.se/nmrshiftdb/?moleculeId=10022911', [])],
['.'('http://pele.farmbio.uu.se/nmrshiftdb/?moleculeId=89237', [])]]
Total time for finding molecule by shift values (Near-search): 2.385 s
[['.'('http://pele.farmbio.uu.se/nmrshiftdb/?moleculeId=90000', [])]]
Total time for finding molecule by shift values (Near-search): 2.729 sfindMoleculeWithPeakValuesNear( SearchShiftValues, Molecules ) :-
setof( Molecule,
( listPeakShiftsOfMolecule( Molecule, MoleculeShiftValues ),
containsListElementsNear( SearchShiftValues, MoleculeShiftValues ) ),
Molecules ).
listPeakShiftsOfMolecule( Molecule, ListOfPeaks ) :-
hasSpectrum( Molecule, Spectrum ),
findall( ShiftValue,
( hasPeak( Spectrum, Peak ),
hasShiftValue( Peak, ShiftValue ) ),
ListOfPeaks ).
containsListElementsNear( [ElemHead|ElemTail], List ) :-
memberCloseTo( ElemHead, List ),
( containsListElementsNear( ElemTail, List );
ElemTail == [] ).
memberCloseTo( X, [ Y | Tail ] ) :-
closeTo( X, Y ).
memberCloseTo( X, [ Y | Tail ] ) :-
memberCloseTo( X, Tail ).
closeTo( Val1, Val2 ) :-
abs(Val1 - Val2) =< 0.3.
hasSpectrumId( Subject, Predicate ) :-
rdf_db:rdf( Subject, 'http://www.nmrshiftdb.org/onto#spectrumId', Predicate).
hasShiftValue( Peak, ShiftValue ) :-
rdf_db:rdf( Peak, 'http://www.nmrshiftdb.org/onto#hasShift', literal(type('nmr:ppm', ShiftValueLiteral))),
atom_number_create( ShiftValueLiteral, ShiftValue ).
hasPeak( Subject, Predicate ) :-
rdf_db:rdf( Subject, 'http://www.nmrshiftdb.org/onto#hasPeak', Predicate).// JavaScript
//var myStore = pellet.createStore("runningbioclipse/JenaTDB3");
// var myStore = pellet.createInMemoryStore();
var myStore = pellet.createStore("runningbioclipse/JenaTDB6");
var start = new Date().getTime();
rdf.importFile(myStore, "runningbioclipse/nmrshiftdata.works.rdf.xml", "RDF/XML");
var elapsed = (new Date().getTime() - start)/1000;
js.say("Total time for importing nmrshiftdata.works.rdf.xml with Pellet: " + elapsed + " s");
// rdf.importFile(myStore, "runningbioclipse/NMRDatatypes.R2.rdf.xml", "RDF/XML");
// var myStore = pellet.createStore("runningbioclipse/JenaTDB3");
var sparql = " PREFIX onto: <http://www.nmrshiftdb.org/onto#> PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> PREFIX fn: <http://www.w3.org/2005/xpath-functions#> SELECT distinct ?shift WHERE { ?peak onto:hasShift ?shift . FILTER ( fn:abs(?shift - 12.5) < 0.3 && fn:abs(?shift - 23.8) <= 0.3 && fn:abs(?shift - 36.5) <= 0.3 && fn:abs(?shift - 44.3) <= 0.3 && fn:abs(?shift - 78.8) <= 0.3 && fn:abs(?shift - 87.3) <= 0.3 && fn:abs(?shift - 133.8) <= 0.3 && fn:abs(?shift - 0.0) <= 0.3 )} LIMIT 10";
var start2 = new Date().getTime();
js.say(pellet.reason(myStore, sparql));
var elapsed2 = (new Date().getTime() - start2)/1000;
js.say("Total time for retreiving Molecules with shift near [12.5, 13.8, 23.8, 36.5, 44.3, 78.8, 87.3, 133.8, 0], with Pellet: " + elapsed2 + " s");Total time for importing nmrshiftdata.works.rdf.xml with Pellet: 137.739 s [] Total time for retreiving Molecules with shift near [12.5, 13.8, 23.8, 36.5, 44.3, 78.8, 87.3, 133.8, 0], with Pellet: 215.035 s
No results! :( I'm doing something wrong here ...