forked from karinils/supersmart-phylota
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile.tmpl
62 lines (52 loc) · 2.88 KB
/
Makefile.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# these are variables that are defined in the config file. they can be over-
# written at run time by setting an environment variable with the SUPERSMART
# prefix, e.g. conf.MYSQL_BIN becomes SUPERSMART_MYSQL_BIN
MYSQL=[% conf.MYSQL_BIN %]
PERL=[% conf.PERL_BIN %]
CURL=[% conf.CURL_BIN %]
WGET=[% conf.WGET_BIN %]
GUNZIP=[% conf.GUNZIP_BIN %]
FORMATDB=[% conf.FORMATDB_BIN %]
# this file is just used to check whether the InParanoid SQL tables were
# downloaded
INPARANOID_DL=[% conf.INPARANOID_SQL_DIR %]/robots.txt
# these are targets that have names, so that we can do things such as 'make
# tnrs'. They need to be listed here as 'phony' targets because the name of the
# target doesn't imply the creation of a file by that name. In other words,
# 'make tnrs' doesn't result in a file called tnrs, and we need to tell the make
# program about this so that it doesn't think files need to be re-generated.
.PHONY : setup database download inparanoid_blast
# eventually this target should result in all the pre-work being done, so that
# users can do "perl Makefile.PL && make && make setup && make test"
setup :
@echo "Configured for genbank release number [% conf.currentGBRelease %]"
# downloads and concatenates the phylota database dump chunks
[% conf.DUMP_IN_FILE %] :
$(CURL) [% conf.DUMP_IN_URL %][% conf.DUMP_IN_CHUNKS %] > $@
# download the concatenated FASTA file for InParanoid
[% conf.INPARANOID_SEQ_FILE %] :
$(CURL) [% conf.INPARANOID_SEQ_URL %] -o $@
# download the InParanoid pairwise comparison tables
$(INPARANOID_DL) :
cd [% conf.INPARANOID_SQL_DIR %] && $(WGET) --recursive --no-directories --no-parent --accept sqltable.* --level=1 [% conf.INPARANOID_SQL_URL %] && cd -
# does all the download targets
download : [% conf.DUMP_IN_FILE %] [% conf.INPARANOID_SEQ_FILE %] $(INPARANOID_DL)
# initializes the database:
# - creates the user
# - creates the empty database
# - grants newly created user all privileges on database
# - creates inparanoid database table
# - loads phylota database dump
# - applies a patch to the phylota schema (index on cigi.ti_of_gi)
database : [% conf.DUMP_IN_FILE %]
$(MYSQL) -e "create user '[% conf.USER %]'@'localhost' identified by '[% conf.PASS %]';"
$(MYSQL) -e "create database [% conf.DATABASE %];"
$(MYSQL) -e "grant all privileges on [% conf.DATABASE %].* to '[% conf.USER %]'@'localhost';"
$(MYSQL) -u [% conf.USER %] -p[% conf.PASS %] [% conf.DATABASE %] < [% conf.INPARANOID_SQL_FILE %]
$(GUNZIP) -c $< | mysql -u [% conf.USER %] -p[% conf.PASS %] [% conf.DATABASE %]
$(MYSQL) -u [% conf.USER %] -p[% conf.PASS %] [% conf.DATABASE %] -e "alter table ci_gi_[% conf.currentGBRelease %] add index(ti_of_gi);"
@echo "Database initialized succesfully"
# index the InParanoid BLAST database
[% conf.INPARANOID_LOG_FILE %] : [% conf.INPARANOID_SEQ_FILE %]
$(FORMATDB) -i $< -l [% conf.INPARANOID_LOG_FILE %] -p T -o T
inparanoid_blast : [% conf.INPARANOID_LOG_FILE %]