Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
cmungall committed Sep 5, 2019
1 parent a7576b4 commit 4cfe317
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 47 deletions.
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,23 @@ pe-clean:
docker rm $(IM) || echo not made

pe-build:
test -f tests/out.tmp && rm tests/out.tmp || echo ok \
@docker build -t $(IM):$(VERSION) . \
(test -f tests/out.tmp && rm tests/out.tmp || echo ok) && \
docker build -t $(IM):$(VERSION) . \
&& docker tag $(IM):$(VERSION) $(IM):latest


pe-run:
docker run -p 9083:9083 -e PORT=9083 --name sparqlprog $(IM)

pe-run-bg:
docker run -p 9083:9083 -e PORT=9083 --name sparqlprog $(IM) &

pe-test: pe-run-bg
sleep 3 ;\
python3 ../sparqlprog-python/sparqlprog.py -u http://localhost:9083 -e wd "continent(X)" ;\
docker kill sparqlprog ;\
docker rm sparqlprog

pe-publish: pe-build
@docker push $(IM):$(VERSION) \
&& docker push $(IM):latest
Expand Down
9 changes: 9 additions & 0 deletions examples/ebi-examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ pq-ebi -l sample
# everything about https://www.ebi.ac.uk/biosamples/samples/SAMN02847463
pq-ebi -l "rdf(biosd:'SAMN02847463',P,Y)"

# sample property-values
pq-ebi -l "sample_property_value(biosd:'SAMN02847463',P,V)"

# distincty attributes
# (may be too slow...)
pq-ebi "aggregate(count(distinct(P)),rdf(A,ebi_atlas:propertyType,P),Num)" "x(Num)"

# all distinct attributes (24732)
pq-ebi --distinct "rdf(A,ebi_atlas:propertyType,P)" "x(P)
1 change: 1 addition & 0 deletions install.pl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
install_optional_packs :-
writeln(loading),
ensure_loaded(pack),
ensure_loaded(packplus),
Opts=[interactive(false)],
\+ \+ clause(optional_pack(_),_),
forall(optional_pack(X),
Expand Down
3 changes: 1 addition & 2 deletions pack.pl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name('sparqlprog').
title('Logic programming with SPARQL').
version('0.2.7').
version('0.2.8').
author('Chris Mungall','[email protected]').
author('Samer Abdallah','[email protected]').
maintainer('Chris Mungall','[email protected]').
Expand All @@ -9,7 +9,6 @@
requires(dcgutils).
requires(regex).
requires(typedef).
optional_pack(obo_metadata).



1 change: 1 addition & 0 deletions packplus.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
optional_pack(obo_metadata).
53 changes: 49 additions & 4 deletions prolog/sparqlprog/ontologies/ebi.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
[

sample/1,
sample_attribute_node/2,
sample_attribute/2,
attribute_property_value/3,
attribute_property_value/4,
attribute_property_value/5,
sample_biocharacteristic/2,
sample_property_value/3,
sample_property_value/4,
sample_depth/2,
sample_environment_feature/2,

identifier/2,
description/2,
Expand Down Expand Up @@ -52,11 +60,48 @@


sample(A) :- rdf(A,rdf:type,biosd_terms:'Sample').
sample_attribute_node(S,A) :-
rdf(S,biosd_terms:'has-sample-attribute',A).

%sample_
%! sample_biocharacteristic(?S : ebi_biosample, ?A : ebi_attribute_node) is nondet.
sample_biocharacteristic(S,A) :-
rdf(S,biosd_terms:'has-bio-characteristic',A).



%! sample_attribute(?S : ebi_biosample, ?A : ebi_attribute_node) is nondet.
sample_attribute(S,A) :-
rdf(S,biosd_terms:'has-sample-attribute',A).

%! attribute_property_value(?A : ebi_attribute_node,
% ?P : ebi_biosample_property,
% ?V : ebi_biosample_value) is nondet.
%
attribute_property_value(A, P, V) :-
rdf(A,ebi_atlas:propertyType,P),
rdf(A,ebi_atlas:propertyValue,V).
attribute_property_value(A, P, V, T) :-
rdf(A,rdf:type,T),
rdf(A,ebi_atlas:propertyType,P),
rdf(A,ebi_atlas:propertyValue,V).
attribute_property_value(A, P, V, T, G) :-
rdf(A,rdf:type,T, G),
rdf(A,ebi_atlas:propertyType,P),
rdf(A,ebi_atlas:propertyValue,V).

%! sample_property_value(?S : ebi_biosample,
% ?P : ebi_biosample_property,
% ?V : ebi_biosample_value) is nondet.
%
sample_property_value(S, P, V) :-
sample_attribute(S, A),
attribute_property_value(A,P,V).
sample_property_value(S, P, V, T) :-
sample_attribute(S, A),
attribute_property_value(A,P,V, T).

sample_depth(S,V) :-
sample_property_value(S, "depth"^^xsd:string, V).
sample_environment_feature(S,V) :-
sample_property_value(S, "environment feature"^^xsd:string, V).

% B seems to always be identifiers.org
see_also(A,B) :- rdf(A,rdfs:seeAlso,B).
Expand Down
46 changes: 7 additions & 39 deletions prolog/sparqlprog/ontologies/uniprot.pl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
:- type uniprot_annotation ---> atomic_iri.
:- type uniprot_disease_annotation ---> uniprot_annotation.
:- type uniprot_xref ---> atomic_iri.
:- type uniprot_term ---> atomic_iri.
:- type uniprot_sequence_string ---> string ^^ xsd_type.

%! protein(?P : uniprot_protein) is nondet.
Expand Down Expand Up @@ -118,78 +119,45 @@


%! is_dbsnp(?X : uniprot_xref) is nondet.
%
%
%
is_dbsnp(X) :- rdf(X,up:database,updb:dbSNP).



%! transmembrane_annotation(?A : uniprot_annotation) is nondet.
%
%
%
transmembrane_annotation(A) :- rdf(A,rdf:type,up:'Transmembrane_Annotation').

%! has_transmembrane_annotation(?P : uniprot_protein, ?A : uniprot_annotation) is nondet.
%
%
%
has_transmembrane_annotation(P,A) :- annotation(P,A),rdf(A,rdf:type,up:'Transmembrane_Annotation').



%! mnemonic(?C, ?N) is nondet.
%
%
%
mnemonic(C,N) :- rdf(C,up:mnemonic,N).

%! encoded_by(?P : uniprot_protein, ?G) is nondet.
%
%
%
encoded_by(P,G) :- rdf(P,up:encodedBy,G).


%! recommended_name(?P : uniprot_protein, ?N) is nondet.
%
%
%
recommended_name(P,N) :- rdf(P,up:recommendedName,N).

%! has_full_name(?P : uniprot_protein, ?X) is nondet.
%
%
%
has_full_name(P,X) :- rdf(P,up:recommendedName,N), rdf(N,up:fullName,X).

% for genes only

%! pref_label(?E, ?N) is nondet.
%
%
%
pref_label(E,N) :- rdf(E,skos:prefLabel,N).


%! in_taxon(?P : uniprot_protein, ?T) is nondet.
%
%
%
in_taxon(P,T) :- rdf(P,up:organism,T).


%! annotation(?P : uniprot_protein, ?A : uniprot_annotation) is nondet.
%
%
%
annotation(P,A) :- rdf(P,up:annotation,A).

%! database(?X : uniprot_xref, ?D) is nondet.
%
%
%
database(X,D) :- rdf(X,up:database,D).


Expand All @@ -203,30 +171,30 @@


%! annotation_range(?P : uniprot_annotation, ?B, ?E, ?R) is nondet.
%
%
%
annotation_range(P,B,E,R) :-
rdf(P,up:range,I),
begin_coord(I,B,R),
end_coord(I,E,R).

%! protein_begin(?P : uniprot_protein, ?B, ?R) is nondet.
%
%
%
protein_begin(P,B,R) :-
rdf(P,up:range,I),
begin_coord(I,B,R).



%! classified_with(P : uniprot_protein, T : uniprot_term) is nondet.
classified_with(P,T) :- rdf(P,up:classifiedWith,t).


%! substitution(?A : uniprot_annotation, ?S : uniprot_sequence_string) is nondet.
%
% annotation A is associated with a substitution S
%
substitution(A,S) :- rdf(A,up:substitution,S).



%! xref(?P : uniprot_protein, ?X : uniprot_xref) is nondet.
%
% P has xref X
Expand Down

0 comments on commit 4cfe317

Please sign in to comment.