home
  News
  Discussion forum
  WIKI
  Collaboration
  Downloads
  Language grammar
  Examples
 associated projects
  RuleML
  GoPubMed
  Mandarax
  RBSLA
  Jena
 

The colours shown below are used to distinguish the language elements:


% Comments are in green

% Built-in predicates are brown
tokenize_list(Line,"\t",[T|Ts])

% User-defined predicates are blue
member(X,[X|Xs])

% Java calls and constructors are red
Text1=P1.toString()

% Table names are magenta
sql_select(DB,cla,[px,PXA],[pdb_id,PDB_ID])


Examples:
 
% Facts (what we know)

% "anticoagulant" is a "molecular_function"
is_a("anticoagulant","molecular_function"). 
 
% Rules (how to derive new knowledge) 
parent(X,Y) :-   % X is parent of Y IF Y is a (kind of) X 
   is_a(Y,X). 
parent(X,Y) :-   % X is parent of Y IF X has a Y
   has_a(X,Y). 
 
% Goal (what to do/what to derive) 
% Who is Parent of "anticoagulant"? 
:- solve(parent(Parent,"anticoagulant")).
  
> Parent="molecular_function"
% X is a member of a list IF it is the first element 
member(X,[X|Xs]). 
% X is a member of a list IF it is in the list tail 
member(X,[_|Xs]) :- 
   member(X,Xs). 

% What Integer(s) are part of the specified list? 
:- solve(member(Integer.X,[1,3.141592,5,"3"])). 


> java.lang.Integer.X=1 
> java.lang.Integer.X=5
:- solve(cos(3.141592,Result)). 
:- solve(cos(3.141592,Double.Result)). 
:- solve(cos(3.141592,String.Result)). 
:- solve(cos(3.141592,Integer.Result)). 

cos(Double.X,Double.Y) :- 
   % Observe the Java call 
   Double.Y=java.lang.Math.cos(Double.X). 


[1] > Result=-0.9999999999997864 
[2] > java.lang.Double.Result=-0.9999999999997864 
[3] >  
[4] > 
:- eval(test_collections()). 

test_collections() :- 
   Map=java.util.HashMap(), % Constructor of a Java HashMap 
   Map.put(0,"false"),      % Instance method calls 
   Map.put(1,"true"), 
   println(["Map=",Map]).   % Built-in printing  

> Map={1="true",0="false"}
:- eval((test_scripting("pdb1dan.ent.Z")). 

test_scripting(FileName) :- 
   exec(["gzip -d ",FileName]), 
   exec(["rm ",FileName]).
:- solve(scop_multi_domain(PDB_ID)). 

% PDB_ID is multi-domain IF it contains >1 domain 
scop_multi_domain(PDB_ID) :- 
   dbopen(scop,DB), 
   sql_select(DB,cla,[pdb_id,PDB_ID],[count(px),N],[having,"count(px)>1"]). 

> PDB_ID=1041
> PDB_ID=10gs
...
Mirrors provide access to data from prioritised location defaults. If any location is not available the next one is tried. All data sources are classified in types (e.g., pdb).
% FACTS: Where files of type pdb and ID's are located 
location(pdb,"1dan","file:/c:/dbs/pdb").                  % Specific for 1dan 
location(pdb,_,"http://comas.soi.city.ac.uk/dbs/pdb").    % Default 1 
location(pdb,_,"http://www.rcsb.org/pdb/cgi/export.cgi"). % Default 2 

% RULE: Whether domains PXA and PXB in PDB_ID interact 
scop_dom2dom(DB,PDB_ID,PXA,PXB) :- 
   get_data(pdb,PDB_ID,Protein), % Data for PDB_ID 
   ... 

% RULE: Code for retrieving data from a PDB entry 
retrieve_data(pdb,PDB_ID,Protein,URL) :- 
   Protein=psimap.Pdb.getProtein(URL,PDB_ID).             % Call java method 

% RULE: General mirrored access to data of type Type 
get_data(Type,ID,Data) :- 
   % Data taken from prioritised locations 
   location(Type,ID,URL),   
   retrieve_data(Type,ID,Data,URL), 
   % No more locations tried if successful
   !.