forked from TreeBASE/supertreebase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
75 lines (63 loc) · 1.95 KB
/
Makefile
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
63
64
65
66
67
68
69
70
71
72
73
74
75
# eukaryotes
ROOTID=2759
PERL=perl
EXTRACT=unzip -f
ARCH=zip
MKPATH=mkdir -p
SCRIPT=script
CURL=curl
DATA=data
VERBOSITY=-v -v -v
MRPDIR=$(DATA)/mrp
TAXDMP=taxdmp
TAXDMPDIR=$(DATA)/$(TAXDMP)
TAXDMPTMP=$(TAXDMPDIR)/tmp
TAXDMPARCH=$(TAXDMPDIR)/$(TAXDMP).$(ARCH)
TAXDMPURL=ftp.ncbi.nlm.nih.gov/pub/taxonomy/$(TAXDMP).$(ARCH)
NCBIMRP=$(MRPDIR)/ncbi.dat
NCBINODES=$(TAXDMPDIR)/nodes.dmp
NCBINAMES=$(TAXDMPDIR)/names.dmp
NCBIFILES=$(NCBINODES) $(NCBINAMES)
TB2STUDYPURLS=$(wildcard $(TB2DATA)/*.url)
TB2STUDYFILES=$(patsubst %.url,%.xml,$(TB2STUDYPURLS))
TB2MRPFILES=$(patsubst %.xml,%.txt,$(TB2STUDYFILES))
TB2DATA=$(DATA)/treebase
TB2SITEMAP=sitemap.xml
TB2SITEMAPXML=$(TB2DATA)/$(TB2SITEMAP)
TB2SITEMAPURL=http://treebase.org/treebase-web/$(TB2SITEMAP)
TB2TAXA=$(TB2DATA)/taxa.txt
.PHONY : all tb2 clean_tb2
all : tb2 $(NCBIMRP)
tb2 : tb2studypurls $(TB2STUDYFILES) $(TB2TAXA)
clean_tb2 :
rm -rf $(TB2DATA)/*.url
rm -rf $(TB2DATA)/*.dat
rm -rf $(TB2DATA)/*.xml
rm -rf $(TB2DATA)/*.txt
# fetch the TreeBASE site map
$(TB2SITEMAPXML) :
$(MKPATH) $(TB2DATA)
$(CURL) -o $@ $(TB2SITEMAPURL)
# turn the study URLs in the site map into local *.url files with PURLs
tb2studypurls : $(TB2SITEMAPXML)
$(PERL) $(SCRIPT)/make_tb2_urls.pl -i $(TB2SITEMAPXML) -o $(TB2DATA)
# fetch the studies
$(TB2STUDYFILES) : %.xml : %.url
$(CURL) -L -o $@ `cat $<`
# make TreeBASE MRP matrices
$(TB2MRPFILES) : %.txt : %.xml
$(PERL) $(SCRIPT)/make_tb2_mrp.pl -i $< > $@
# create list of unique taxon IDs
$(TB2TAXA) : $(TB2MRPFILES)
cat $(TB2MRPFILES) | cut -f 1 | sort | uniq > $@
# download taxdmp archive
$(TAXDMPARCH) :
$(MKPATH) $(TAXDMPDIR)
$(CURL) -o $(TAXDMPARCH) $(TAXDMPURL)
# extract archive
$(NCBIFILES) : $(TAXDMPARCH)
cd $(TAXDMPDIR) && $(EXTRACT) $(TAXDMP).$(ARCH) && cd -
# make NCBI MRP matrix
$(NCBIMRP) : $(NCBIFILES)
$(MKPATH) $(MRPDIR) $(TAXDMPTMP)
$(PERL) $(SCRIPT)/make_ncbi_mrp.pl -taxa $(TB2TAXA) -nodes $(NCBINODES) -names $(NCBINAMES) -dir $(TAXDMPTMP) $(VERBOSITY) > $@