7305f6af2240cd55329c8f3fc2f4108aab1cda0f
[htsworkflow.git] / htswanalysis / scripts / LibrariesMakefile
1 #
2 # Makefile to bring new flowcells into the repository, calculating QC for each of them.
3 #
4 # Once the makefile has run once (please, for your sanity, use make -j N (where N is the number of CPU cores you have),
5 # then you need to run it again to actually make the libraries proper. This will be (needs to be fixed).
6 #
7 # Upon completion, all the above preprocessing is placed in all the flowcell directories, and the libraries are up-to-date.
8
9
10 #
11 # HTSW_ANALYSIS_ROOT is the location of all the programs used and 
12 #    should be defined in the environment
13 # DATA_DIR is the base directory of the flowcells repoitory
14 #
15 ROOT_DIR=$(HTSW_ANALYSIS_ROOT)
16 DATA_DIR=/Users/Data
17 HTML_DIR=/Library/WebServer/Documents/SequencingSummaries
18
19 # Error messages are collected so as not to bug the user. (if there are no matching files, ls errors.)
20 FILES=$(shell ls -1d $(DATA_DIR)/Flowcells/**/*.align*.txt 2>> LibrariesMakefile.err)
21 QC_FILES=$(shell ls -1d ~Data/Flowcells/**/ | awk -F/ '{print $$0"/"$$(NF-1)"_QC_Summary.html"}' )
22 LIBFILES=$(shell ls -1d $(DATA_DIR)/Libraries/.*.config 2>> LibrariesMakefile.err | sed -e s/config/txt/ -e "s/\/\./\//")
23
24 all: $(QC_FILES) $(FILES) $(DATA_DIR)/LibraryInfo.xml $(LIBFILES) $(DATA_DIR)/SequencingSummary.html Distribute
25
26 $(QC_FILES):
27         cd $(DATA_DIR)/Flowcells/`basename $@ | awk -F_ '{print $$1}'` && $(MAKE) -f $(ROOT_DIR)/scripts/Flowcell_QC_Makefile
28
29 $(DATA_DIR)/Libraries/%.txt: $(DATA_DIR)/Libraries/.%.config | LibraryInfo.xml
30         cat `cat $<` > $@;
31
32 $(DATA_DIR)/LibraryInfo.xml: $(QC_FILES)
33         $(ROOT_DIR)/scripts/CollectLibraries.pm `ls $(DATA_DIR)/Flowcells/**/*.align*.txt` > $@;
34         $(ROOT_DIR)/scripts/RecompileLibraries.pm $@ $(DATA_DIR)
35
36 $(DATA_DIR)/SequencingSummary.html: $(DATA_DIR)/LibraryInfo.xml
37         $(ROOT_DIR)/scripts/SummarizeLibrary.pm $< > $@;
38
39 Distribute: $(DATA_DIR)/SequencingSummary.html
40         cp $^ $(HTML_DIR);
41
42 Libraries: $(LIBFILES)