|Did you know ...||Search Documentation:|
|Pack bio_db -- prolog/bio_db.pl|
Bio_db gives access to pre-packed biological databases and simplifies management and translation of biological data to Prolog friendly formats.
There are currently 2 major types of data supported: maps, and graphs. Maps define product mappings, translations and memberships, while graphs define interactions which can be visualised as weighed graphs (see bio_db_data_predicate/4 for a full list of statically generated list of bio_db data predicates).
There are 2 prolog flags (see current_prolog_flag/2) that can control the behaviour of the library: bio_db_qcompile (def: true) and bio_db_interface (def: prolog). When the first one is set to false, it can disable the compilation to
Bio_db itself does include any of the datasets. You can either download the separate
which contains all of the Prolog datasets.
bio_db_repo will install all the Prolog database files. The single tar and gzipped file is
246 Mb in size and the fully expanded version of a Prolog installation can take up to 3.1Gb.
The precise size depends on how many tables
are accessed at least once (each producing an expanded .pl and a .qlf file).
pack(bio_db_repo) holds a total 67 data predicates and serves 38710918 records.
This pack can be installed as per usual via
If you do not install all datasets, each data table will be auto-downloaded the first time you try to access some of its data. Auto-downloading works transparently to the user, where a data set is downloaded by simply calling the predicate.
?- map_hgnc_symb_hgnc( 'LMTK3', Hgnc ). % prolog DB:table hgnc:map_hgnc_symb_hgnc/2 is not installed, do you want to download (Y/n) ? % Trying to get: url_file(http://www.stoics.org.uk/bio_db_repo/data/maps/hgnc/map_hgnc_symb_hgnc.pl,/usr/local/users/nicos/local/git/test_bio_db/data/maps/hgnc/map_hgnc_symb_hgnc.pl) % Loading prolog db: /usr/local/users/nicos/local/git/test_bio_db/data/maps/hgnc/map_hgnc_symb_hgnc.pl Hgnc = 19295. ?- bio_db_interface( prosqlite ). % Setting bio_db_interface prolog_flag, to: prosqlite true. ?- map_hgnc_prev_symb( Prv, Symb ). % prosqlite DB:table hgnc:map_hgnc_prev_symb/2 is not installed, do you want to download (Y/n) ? % Trying to get: url_file(http://www.stoics.org.uk/bio_db_repo/data/maps/hgnc/map_hgnc_prev_symb.sqlite,/usr/local/users/nicos/local/git/test_bio_db/data/maps/hgnc/map_hgnc_prev_symb.sqlite) false. ?- map_hgnc_prev_symb( Prv, Symb ). % prosqlite DB:table hgnc:map_hgnc_prev_symb/2 is not installed, do you want to download (Y/n) ? % Trying to get: url_file(http://www.stoics.org.uk/bio_db_repo/data/maps/hgnc/map_hgnc_prev_symb.sqlite,/usr/local/users/nicos/local/git/test_bio_db/data/maps/hgnc/map_hgnc_prev_symb.sqlite) % Loading prosqlite db: /usr/local/users/nicos/local/git/test_bio_db/data/maps/hgnc/map_hgnc_prev_symb.sqlite Prv = 'A1BG-AS', Symb = 'A1BG-AS1' .
As of version 2.0 bio_db is formed of a number of hierarchically organised cells that can be loaded independently. This is because there now too many predicates and is also a devise for better supporting organism specific data. There are currently two main cells, hs (human) and mouse. Each sub-celled by data source of origin.
Loads the whole interface (all cells), without the user needing to be aware of anything.
The only difference is that the user will not be able to see all the module predicates
at the first line of file
Also loads everything.
?- lib(& bio_db).
Loads the skeleton of the module (cells usually laod the module dependencies like this).
?- lib(& bio_db(hs)).
Loads hs cell (and skeleton). hs comprises of a number of sub-cells.
?- lib(& bio_db(hs(hgnc))).
Loads the hs/hgnc primary cell (and the skeleton).
In both the above loads, the following becomes available, however, the former load also loads additional predicates for human, but non hgnc based.
?- map_hgnc_hgnc_symb( Hgnc, 'LMTK3' ). Hgnc = 19295.
?- use_module( pack('bio_db/cell/hs/hgnc') ).
also loads just the HGNC part of the human section of bio_db, but it is not a recommended way to do so.
For each database a token with the same token means that the field is the unique identifier of the object in that database.
The name convension for maps is
?- map_hgnc_hgnc_symb( Hgnc, Symb ). Hgnc = 1, Symb = 'A12M1~withdrawn' ; Hgnc = 2, Symb = 'A12M2~withdrawn' . ?- map_hgnc_hgnc_symb( 19295, Symb ). Symb = 'LMTK3'. ?- map_hgnc_symb_hgnc( 'LMTK3', Hgnc ). Hgnc = 19295.
Where the first hgnc corresponds to the source database, the second identifies the first argument of the map to be the unique identifier field for that database (here a positive integer starting at 1 and with no gaps), The last part of the predicate name corresponds to the second argument, which here is the unique Symbol assigned to a gene by HGNC. In the current version of bio_db, all tokens in map filenames are 4 characters long. Map data for predicate Pname from database DB are looked for in DB(Pname.Ext) (see bio_db_paths/0). Extension, Ext, depends on the current bio_db database interface (see bio_db_interface/1), and it is sqlite if the interface is prosqlite and pl otherwise.
The name convesion for graphs is
?- edge_string_hs_symb( Symb1, Symb2, W ). S1 = 'A1BG', S2 = 'ABAT', W = 360 ; S1 = 'A1BG', S2 = 'ABCC6', W = 158 .
Where only the first and second tokens, edge and string respectively, are controlled. The second token
indicates the database of origin. Graph data for predicate Pname from database DB are looked for in
bio_db_data(graphs/DB/Pname.Ext) (see bio_db_paths/1).
Extension, Ext, depends on the current bio_db database interface (see bio_db_interface/1), and it is sqlite if
the interface is prosqlite and pl otherwise.
Bio_db supports four db interfaces: prolog, prosqlite, berkeley and rocks. The first one is via Prolog fact bases, which is the default.
The second is an interface to SQLite via
pack(prosqlite) while the third and fourth work with the SWI-Prolog packs bdb and rocksdb.
The underlying mechanisms are entirely transparent to the user. In order to use the sqlite data sources
pack(prosqlite) needs to be installed via the pack manager
?- pack_install( prosqlite ).
The user can control which interface is in use with the bio_db_interface/1 predicate.
?- bio_db_interface( Curr ). Curr = prolog. ?- bio_db_interface( prosqlite ). ?- bio_db_interface( Curr ). Curr = prosqlite.
The type of the interface of a bio_db data predicate is determined by the interface at the time of first call.
Once the user has initiated the serving of a predicate via calling a goal to it, it is then possible to have access to information about the dataset such as download date and sourle url.
?- map_hgnc_hgnc_symb( Hgnc, Symb ). Hgnc = 1, Symb = 'A12M1~withdrawn' . ?- bio_db_info( map_hgnc_hgnc_symb, Key, Value ), write( Key-Value ), nl, fail. source_url-ftp://ftp.ebi.ac.uk/pub/databases/genenames/hgnc_complete_set.txt.gz datetime-datetime(2016,9,8,0,8,40) header-row(HGNC ID,Approved Symbol) unique_lengths-unique_lengths(44266,44266,44266) relation_type-relation_type(1,1) false.
As of version 2.0 there are two flags that can automate some of the interactions.
:- set_prolog_flag(bio_db_pl_from_zip, user). :- set_prolog_flag(bio_db_del_zip, user).
In both cases the recognised values for the flags are: [user,true,false]. User is for prompting the user and true is progressing with an implicit yes answer. The first flag automates conversion from .pl.zip to .pl (which will be the case for the first time you access any dataset if you have installed bio_db_repo), and the secondpertains to the qquestion of deleteling the zip file once the .pl file has been created.
Thanks to Jan Wielemaker for a retractall fix and for code for fast loading of precompiled fact bases (and indeed for the changes in SWI that made this possible).
There are two main directory repositories the predicate deals with: (a) the bio_db installed databases root (alias bio_db_data), and (b) the root of downloaded databases (alias bio_db_downloads). Optionally a top directory of which both (a) and (b) are subdirs can be defined (alias bio_db). The default value for alias bio_db is a made-up pack directory
pack(bio_db_repo). The default for bio_db_data is sub directory
dataof alias bio_db, while bio_db_downloads defaults to sub directory
downloadsof the alias bio_db. The canonical subdirectory name for (a) is data and for (b) is downloads.
pack(bio_db_repo) can also be installed as a complete package from SWI's manager.
?- pack_install( bio_db_repo ).
This will install all the Prolog database files. The single tar and gzipped file is 246 Mb in size and the fully expanded version of a Prolog installation can take up to 3.1Gb. The precise size depends on how many tables are accessed at least once (each producing an expanded .pl and a .qlf file).
Directory locations for (a) and (b) above can be given as either prolog flags with key bio_db_root and bio_dn_root respectively or via environment variables BioDbRoot and BioDnRoot.
alias(bio_db_data) contains sub-dirs
The above are mapped to aliases bio_graphs and bio_maps respectively. Within each of these sub-directories there is further structure based on the database the set was originated.
alias(bio_db_downloads) may contain sub-dirs
Alias bio_db_downloads is only useful if you are downloading data files directly from the supported databases.
?- absolute_file_name( packs(bio_db(auxil)), Auxil ), ls( Auxil ).
for examples of how these can be used.
For most users these aliases are not needed as the library manages them automatically.
?- bio_db_version( V, D ). V = 2:3:0, D = date(2019, 2, 11).
bibtex(Type,Key,Pairs)term of the same publication. Produces all related publications on backtracking.
The databases are
false) of bio_db's known interfaces.
trueif the interface dependencies are installed and the interface can be used, and =|false=| otherwise.
Can be used to enumerate all known or installed interfaces.
?- findall( Iface, bio_db_interface(Iface,_), Ifaces ). Ifaces = [prolog, berkeley, prosqlite, rocks].
Iface = prolog. Also supported:
prosqlite(needs pack proSQLite),
berkley(needs SWI's own library(bdb) and
?- bio_db_interface( Iface ). Iface = prolog. ?- debug( bio_db ). true. ?- bio_db_interface( wrong ). % Could not set bio_db_interface prolog_flag, to: wrong, which in not one of: [prolog,prosqlite,berkeley,rocks] false. ?- bio_db_interface( Iface ). Iface = prolog. ?- map_hgnc_symb_hgnc( 'LMTK3', Hgnc ). % Loading prolog db: /usr/local/users/nicos/local/git/lib/swipl-7.1.32/pack/bio_db_repo/data/maps/hgnc/map_hgnc_symb_hgnc.pl Hgnc = 19295. ?- bio_db_interface( prosqlite ). % Setting bio_db_interface prolog_flag, to: prosqlite true. ?- map_hgnc_prev_symb( Prev, Symb ). % prosqlite DB:table hgnc:map_hgnc_prev_symb/2 is not installed, do you want to download (Y/n) ? % Execution Aborted ?- map_hgnc_prev_symb( Prev, Symb ). % Loading prosqlite db: /usr/local/users/nicos/local/git/lib/swipl-7.1.32/pack/bio_db_repo/data/maps/hgnc/map_hgnc_prev_symb.sqlite Prev = 'A1BG-AS', Symb = 'A1BG-AS1' ;
In which case Iface is prosqlite.
When Iface is not given, Key and Value are those of the interface under which Pid is currently open for access. The predicate errors if Pid is not open for serving yet.
The bio_db_info/2 version succeeds for all interfaces Pid is installed- it is simply
a shortcut to:
bio_db_info( Iface, Pid, _, _ ).
The Key-Value information returned are about the particular data predicate as saved in the specific backend.
?- bio_db_info( Iface, map_hgnc_hgnc_symb/2, Key, Value), write( Iface:Key:Value ), nl, fail. prolog:source_url:ftp://ftp.ebi.ac.uk/pub/databases/genenames/hgnc_complete_set.txt.gz prolog:datetime:datetime(2016,9,10,0,2,14) prolog:data_types:data_types(integer,atom) prolog:unique_lengths:unique_lengths(44266,44266,44266) prolog:relation_type:relation_type(1,1) prolog:header:row(HGNC ID,Approved Symbol) prosqlite:source_url:ftp://ftp.ebi.ac.uk/pub/databases/genenames/hgnc_complete_set.txt.gz prosqlite:datetime:datetime(2016,9,10,0,2,14) prosqlite:data_types:data_types(integer,atom) prosqlite:unique_lengths:unique_lengths(44266,44266,44266) prosqlite:relation_type:relation_type(1,1) prosqlite:header:row(HGNC ID,Approved Symbol)
Close the current serving of predicate Pid. Next time a Pid Goal is called the current interface (bio_db_interface/1) will be used to establish a new server and resolve the query.
Predicate throws an error if the Pid does not correspond to a db_predicate or if it is not currently servered by any of the backends.
bio_db_interface( prosqlite ).
map_hgnc_hgnc_symb( Hgnc, Symb ).
Hgnc = 506,
Symb = 'ANT3~withdrawn' .
bio_db_close( map_hgnc_hgnc_symb/2 ).
bio_db_interface( prolog ).
map_hgnc_hgnc_symb( Hgnc, Symb ).
Hgnc = 1,
Symb = 'A12M1~withdrawn' .
bio_db_close( map_hgnc_hgnc_symb/2 ).
This is called by bio_db at halt.
True if Pid is a predicate identifier which is defined in current bio_db session, and starts with either edge_ or map_. When Pid is a free variable all such predicate identifiers are returned on backtracking.
For a statically produced list of all data predicates in bio_db see, bio_db_data_predicate/4.
?- bio_db_db_predicate( map_hgnc_hgnc_symb/2 ). true. ?- bio_db_db_predicate( X ). X = map_hgnc_symb_entz/2 ; X = map_ense_enst_ensg/2 ; ...
The following predicates are exported, but not or incorrectly documented.