JPRED-2 Initial commit of software for the Jpred website (some files excluded due...
[jpred.git] / websoft / bin / Makefile
1 # Makefile for construction of databases that Jpred uses.
2 # The pdb make target has been over documented so as to provide
3 # explanation of the method behind the madness.
4 # All variables are defined at the top of the file, and then targets
5 # are defined afterwards
6
7 # Suffixes created by BLAST, ptm is also created, but I think this is
8 # a temporary file, so is mentioned explicitly in the clean target
9 BLAST_SUFFIX = .phr .pin .psd .psi .psq
10
11 # Specifically add path for some of the commands so we know we'll
12 # find them
13 PATH := $(PATH):/r0/www_servers/jpred/jpred_bin:/site/Linux/bin
14
15 # Define commands that occur multiple times
16 # The wget command means that you have to give the output location first,
17 # then the target
18 WGET = wget -N -t 10
19 FORMATDB = formatdb -o T -i
20
21 # Variables specific for PDB stuff
22 # URL to get the file from
23 PDB_URL = ftp://ftp.ebi.ac.uk/pub/databases/msd/pdb_aa.fasta
24 PDB_FILE = $(notdir $(PDB_URL))
25 # Target path to download to
26 PDB_FASTA = pdb.fasta
27 # Files created by running formatdb on $(PDB_FASTA)
28 PDB_BLAST = $(addprefix $(PDB_FASTA), $(BLAST_SUFFIX))
29 # Directory to install the files into
30 #PDB_TARGET = /r0/www_servers/jpred/databases/pdb
31 PDB_TARGET = /tmp/jpred/databases/pdb
32 # The target paths of the files that are to be installed
33 PDB_INSTALL =  $(addprefix $(PDB_TARGET)/, $(PDB_BLAST) $(PDB_FASTA))
34
35 # Variables specific for SWALL
36 SP_URL = ftp://ftp.ebi.ac.uk/pub/databases/sp_tr_nrdb/fasta/sprot.fas.gz
37 SP_FILE = $(notdir $(SP_URL))
38 TREMBL_URL = ftp://ftp.ebi.ac.uk/pub/databases/sp_tr_nrdb/fasta/trembl.fas.gz 
39 TREMBL_FILE = $(notdir $(TREMBL_URL))
40
41 SWALL_FASTA = swall.fasta
42 SWALL_INDX = swall.jidx
43 SWALL_FILT = swall.filt
44 SWALL_BLAST = $(addprefix $(SWALL_FILT), $(BLAST_SUFFIX))
45 SWALL_TARGET = /tmp/jpred/cluster/packages/jpred_swall
46 SWALL_INSTALL = $(addprefix $(SWALL_TARGET)/, $(SWALL_BLAST) $(SWALL_FASTA) $(SWALL_FILT))
47
48 ######################################################################
49 all: pdb.db swall.db
50
51 ######################################################################
52 # PDB FASTA seqeunce database
53
54 # Heirarchy of dependancies (indentation denotes dependancy):
55 # /installation/dir/pdb.fasta{,.{phr,pin,psd,psi,psq}}
56 #       pdb_wget
57 #       pdb.fasta{.{phr,pin,psd,psi,psq}}
58 #               pdb.fasta
59 #                       pdb_aa.fasta
60 # pdb_wget creates pdb_aa.fasta
61
62 # This states that the PDB target depends upon the pdb_wget target and
63 # the files in the variable $(PDB_INSTALL), this is the group of formatdb
64 # index files and the original FASTA file used to create them in the
65 # installation directory
66 pdb.db: pdb_wget $(PDB_INSTALL)
67
68 # This installs the files into the final directory
69 $(PDB_INSTALL): $(PDB_BLAST)
70         mkdir -p $(PDB_TARGET)
71         install -m 644 $(PDB_BLAST) $(PDB_FASTA) $(PDB_TARGET)
72
73 # Do BLAST DB formating. This depends on a group of files, so if any of
74 # them are deleted/too old, then they're reformated.
75 $(PDB_BLAST): $(PDB_FASTA)
76         $(FORMATDB) $(PDB_FASTA)
77
78 $(PDB_FASTA): $(PDB_FILE)
79         cp $(PDB_FILE) $(PDB_FASTA)
80
81 # This is a phony rule that's always executed, in this case it's to check
82 # whether a newer version of the PDB FASTA file has been deposited on the
83 # FTP site.
84 # It has to be a phony rule as if it's made a normal rule that depends
85 # on the file that's downloaded, its always considered upto date and the
86 # wget command isn't run.
87 .PHONY: pdb_wget
88 pdb_wget:
89         $(WGET) $(PDB_FASTA) $(PDB_URL)
90         
91 ######################################################################
92
93 swall.db: sp_wget trembl_wget $(SWALL_INSTALL)
94
95 $(SWALL_INSTALL): $(SWALL_BLAST) $(SWALL_FASTA) $(SWALL_FILT) $(SWALL_INDX)
96         mkdir -p $(SWALL_TARGET)
97         install -m 644 $(SWALL_BLAST) $(SWALL_FASTA) $(SWALL_FILT) $(SWALL_INDX) $(SWALL_TARGET)
98
99 $(SWALL_BLAST): $(SWALL_FILT)
100         $(FORMATDB) $(SWALL_FILT)
101
102 # This next line defines a temporary variable for the target
103 $(SWALL_FILT): TMP_FILE := $(shell tempfile -d /r0/scratch) 
104 $(SWALL_FILT): $(SWALL_FASTA)
105         seg $(SWALL_FASTA) 12 2.2 2.5 -x > $(TMP_FILE)
106         ~/src/helixfilt/helixfilt $(TMP_FILE) > $(SWALL_FILT)
107         rm $(TMP_FILE)
108
109 $(SWALL_INDX): $(SWALL_FASTA)
110         db_dbmindex $(SWALL_FASTA) $(SWALL_INDX)
111
112 $(SWALL_FASTA): $(SP_FILE) $(TREMBL_FILE)
113         gzip -c -d $(SP_FILE) > $(SWALL_FASTA)
114         gzip -c -d $(TREMBL_FILE) >> $(SWALL_FASTA)
115
116 $(SP_FILE): sp_wget
117
118 $(TREMBL_FILE): trembl_wget
119
120 .PHONY: sp_wget
121 sp_wget:
122         $(WGET) $(SP_URL)
123
124 .PHONY: trembl_wget
125 trembl_wget:
126         $(WGET) $(TREMBL_URL)
127
128 ######################################################################
129 clean:
130         -rm $(SWALL_FASTA) $(SWALL_INDX) $(SWALL_FILT) $(SWALL_BLAST)
131         -rm $(PDB_FASTA) $(PDB_BLAST)
132         -rm formatdb.log *.ptm
133
134 distclean: clean
135         -rm $(PDB_FILE) $(SP_FILE) $(TREMBL_FILE)
136
137 installclean:
138         -rm -r $(SWALL_TARGET)
139         -rm -r $(PDB_TARGET)