-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
255 lines (199 loc) · 10 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
MAKEFILE=Makefile
.PHONY: help doc pylint pylintshort \
nose unittest install install_user test bats bats_cmd \
test_cmd clean_install prepare_pip nose_travis
#------------------------------------------------------------------
# PYLINT arguments
#------------------------------------------------------------------
## Disable some testing in pylint
# W0123 : eval-used
# W0122 : exec-used
PYLINT_DISABLE=W0123,W0122
## Fix some issues with numpy,bx and pylint
# --extension-pkg-whitelist=numpy,bx
## Pylint arguments
PYLINT_ARGS= -d $(PYLINT_DISABLE) --extension-pkg-whitelist=numpy
#------------------------------------------------------------------
# Other variable
#------------------------------------------------------------------
CRAN_PACK_LIST=''
BIOC_PACK_LIST=''
#------------------------------------------------------------------
# Targets
#------------------------------------------------------------------
help:
@echo ""
@echo "- Available targets:"
@echo ""
@perl -ne 'if( /^(\w+):/){print "\t",$$1,"\n"}' $(MAKEFILE)
@echo ""
@echo ""
@echo "- More information:"
@echo ""
@echo -e "\tbats_cmd Usage: make bats_cmd CMD=select_by_key"
@echo ""
@echo -e "\ttest_para Usage: make test_para -j 10"
@echo -e "\release_all Usage: make release_all VER=1.0.0"
doc:
@rm -Rf docs/build/
@rm -Rf dist build *.egg*
@cd docs/; make html -j 4; cd ../..;
@echo ">>>> Docs is available in: docs/build/html/index.html"
pylint:
@find . -name "*.py" -exec pylint $(PYLINT_ARGS) {} \;
pylintshort:
@rm -Rf build dist gtftk.egg-info
@find . -name "*.py" -exec pylint $(PYLINT_ARGS) {} \; 2>/dev/null |perl -ne "print if(/(Your code has been rated)|(\*\*\*\* Module)/)"
nose:
@cd /tmp; mkdir -p gtftk_test; cd gtftk_test; a=`python -c "import os,pygtftk; print(os.path.dirname(pygtftk.__file__))"`; cd $$a ; for i in `find . -name "*.py*" | perl -ne 'print unless(/(setup)|(plugin)|(bwig)|(libgtftk.py)|(__)/)'`; do echo "================="; echo $$i; nosetests --with-doctest $$i --doctest-extension=pyx; done
nose_travis:
@ conda activate pygtftk_py3k; mkdir -p ~/tmp; cd ~/tmp ; mkdir -p gtftk_test; cd gtftk_test; a=`python -c "import os,pygtftk; print(os.path.dirname(pygtftk.__file__))"`; echo $$a; cd $$a ; for i in `find . -name "*.py*" | perl -ne 'print unless(/(setup)|(plugin)||(bwig)|(libgtftk.py)|(__)/)'`; do echo "================="; echo $$i; nosetests --with-doctest $$i --doctest-extension=pyx; done
install:
@rm -Rf build dist pygtftk.egg-info ; \
python setup.py install; rm -Rf build dist pygtftk.egg-info
test:
@make bats
bats:
@gtftk -p > gtftk_test.bats
@bats -t gtftk_test.bats
@rm -f gtftk_test.bats
test_travis:
@make bats_travis
bats_travis:
@gtftk -u > gtftk_test.bats
@bats -t gtftk_test.bats
@rm -f gtftk_test.bats
bats_cmd:
@gtftk -p|perl -npe 's/^ +//;' |perl -ne 'BEGIN{$$/="\n}"}{print $$_ if (/\@test +"$(CMD)/)}' > gtftk_test.bats.sub
@bats -t gtftk_test.bats.sub
@rm -f gtftk_test.bats.sub
test_cmd:
make bats_cmd CMD=$(CMD)
%.bats:
@gtftk -l |sort -r > prgm_list.txt; gtftk -p > test_list.txt; for i in $$(cat prgm_list.txt); do cat test_list.txt | grep -E "@test \"$$i" -A 3 | grep -v "^\-\-$$" > $$i.bats; done
%.bats_travis:
@gtftk -l |sort -r | grep -v select_by_go | grep -v retrieve > prgm_list.txt; gtftk -p > test_list.txt; for i in $$(cat prgm_list.txt); do cat test_list.txt | grep -E "@test \"$$i" -A 3 | grep -v "^\-\-$$" > $$i.bats; done
%.completed : %.bats
@bats -t $<
@echo "completed" > $@
%.completed_travis : %.bats_travis
@bats -t $<
@echo "completed" > $@
OUTPUT = $(eval OUTPUT := $$(shell gtftk -l |sort -r 2>/dev/null))$(OUTPUT)
OUTPUT2 = $(addsuffix .completed, $(OUTPUT))
test_para: $(OUTPUT2)
OUTPUT3 = $(eval OUTPUT3 := $$(shell gtftk -l |sort -r | grep -v select_by_go | grep -v retrieve 2>/dev/null))$(OUTPUT3)
OUTPUT4 = $(addsuffix .completed, $(OUTPUT3))
test_para_travis: $(OUTPUT4)
clean:
@make bats_cmd CMD=clean
@git checkout docs/source/conf.py pygtftk/version.py; rm -rf rm -rf .DS_Store .RData .Rhistory conda/.DS_Store docs/.DS_Store log.txt pygtftk/.DS_Store pygtftk/data/.DS_Store mk_matrix_6 ologram_output* H3K36me3_ologram_stats.tsv H3K79me2_ologram_stats.tsv hg38_chr1_counts_ENCFF630HEX.tsv H3K4me3_ologram_stats.tsv expected_s* ids* diff_fasta.py chr1_hg38_10M.fa* observed_s* order_fasta.py simple* control_list_reference.txt control_list_data.txt add_attr_to_pos.tab test.py pygtftk.egg-info build airway_love.txt* ENCFF630HEX_Total_RNAseq_K562_count_mini.txt STDIN.e* closest_1.tsv STDIN.o* dist cmd_list.txt example_list.txt tmp_list.txt simple.chromInfo prgm_list.txt test_list.txt *.bats *.completed *mini_real* merged_ologram_runs.tsv multiple_overlap_trivial_ologram_stats.tsv tree_multi.dot heatmap_* tx_classes* *~ \#* hh profile_* toto tott; cd docs/; make clean; cd ..; find . -type f -name '*~' -exec rm -f '{}' \;
check_cmd_has_example:
@for i in $$(gtftk -l); do if grep -q "^$$i" docs/source/*.rst; then echo "" >/dev/null; else echo $$i; fi; done
check_example_has_cmd:
@gtftk -l > cmd_list.txt
@grep "~~" -B 1 docs/source/*.rst | grep -v "^$$" | grep -v " " |grep -v "^~~" | grep -v "^\-\-" > example_list.txt
@for i in $$(cat example_list.txt); do if $$(cat cmd_list.txt | grep -q "^$$i") ; then echo "" >/dev/null; else echo $$i; fi; done
@#rm -f cmd_list.txt example_list.txt tmp_list.txt
nb_test:
@gtftk -p| perl -ne 'BEGIN{$$/="{"}{/\@test\s+"(\w+)_\d+"/; print $$1,"\n"}'| sort | uniq -c | sort -nr
#------------------------------------------------------------------
# Creating a release
#------------------------------------------------------------------
__check_defined_VER:
@[ "$(VER)" ] || ( echo ">> VER is not set"; exit 1 )
release: __check_defined_VER
@ echo "#-----------------------------------------------#"
@ echo "# Starting the release $(VER) #"
@ echo "#-----------------------------------------------#"
@touch release_in_progress
release_bump: release
@ echo "#-----------------------------------------------#"
@ echo "# Bumping the program version #"
@ echo "#-----------------------------------------------#"
@ git checkout docs/source/conf.py
@ git checkout setup.cfg
@ git checkout pygtftk/version.py
@ python setup.py install
@ cat pygtftk/version.py | perl -npe "s/='(.*)'/='$(VER)'/" > /tmp/pygtftk.bump
@ mv /tmp/pygtftk.bump pygtftk/version.py
@ cat setup.cfg | perl -npe 's/^version = .*/version = $(VER)/' > /tmp/pygtftk.bump
@ mv /tmp/pygtftk.bump setup.cfg
@ cat docs/source/conf.py | perl -npe "s/version = u'\d+\.\d+\.\d+'$$/version = u'$(VER)'/" | perl -npe "s/release = u'\d+\.\d+\.\d+'$$/release = u'$(VER)'/" > /tmp/pygtftk.bump
@ mv /tmp/pygtftk.bump docs/source/conf.py
@ echo "Version was bump to $(VER)"
@ make install
@ echo "#-----------------------------------------------#"
@ echo "# Check gtftk version #"
@ echo "#-----------------------------------------------#"
@ echo `gtftk -v`
@ git add docs/source/conf.py pygtftk/version.py setup.cfg
@ git commit -m 'Bumped version $(VER)'
release_test:
@ echo "#-----------------------------------------------#"
@ echo "# Performing tests (bats) #"
@ echo "#-----------------------------------------------#"
@ make test_para -j 14
release_nose:
@ echo "#-----------------------------------------------#"
@ echo "# Performing tests (nose) #"
@ echo "#-----------------------------------------------#"
@ make nose
release_doc:
@ echo "#-----------------------------------------------#"
@ echo "# Building doc #"
@ echo "#-----------------------------------------------#"
@ make doc
@ git pull
@ git add docs/source/*png
@ git add docs/source/*pdf
@ cp docs/source/*png docs/source/_static
@ cp docs/source/*pdf docs/source/_static
@ git add docs/source/_static/*png
@ git add docs/source/_static/*pdf
@ git add docs/source/example*png
@ git add docs/source/example*pdf
@ cp docs/source/example*png docs/build/html/_static
@ cp docs/source/example*pdf docs/build/html/_static
@ cp -r docs/build/html/* docs
@ rm -rf docs/build
@ make clean
@ rm -rf docs/workflow/*/.snakemake
@ git add docs/*
@ git commit -m "Updated img in source and source/_static "
@ git push
release_pip_unix:
@ echo "#-----------------------------------------------#"
@ echo "# Creating manylinux compliant package (pip) #"
@ echo "#-----------------------------------------------#"
@rm -rf /tmp/tmp ; \
rm -f manylinux/pygtftk-*whl ; \
cd manylinux ; \
docker rmi -f manylinux ; \
docker rm -f imanylinux || true ; \
docker build --no-cache -t manylinux . ; \
docker create -t --name imanylinux manylinux /bin/bash ; \
docker cp imanylinux:/tmp/ /tmp ; \
rm -rf ../wheels ; \
mkdir -p ../wheels ; \
cp /tmp/tmp/wheelhouse_manylinux/pygtftk-*whl ../wheels ; \
cp /tmp/tmp/log ../wheels/log_unix.txt ; \
echo "Manylinux wheels should be in wheels folder." ; \
echo "Have a look at log in wheels/log and upload user twine if OK."
release_pip_osx:
@ echo "#-----------------------------------------------#"
@ echo "# Creating osx compliant package (pip) #"
@ echo "#-----------------------------------------------#"
@ mkdir -p wheels
@ conda create -n python_dev_39 python=3.9 -y; \
conda activate python_dev_39 ; \
pip install -r requirements.txt ; \
rm -rf dist build; python3.9 setup.py bdist_wheel ; \
cp dist/*whl wheels ; \
rm -rf dist build
release_pip: release_pip_unix release_pip_osx
@ echo "#-----------------------------------------------#"
@ echo "# Creating unix/osx pip compliant package #"
@ echo "#-----------------------------------------------#"
unrelease:
@rm -f release_in_progress