Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented rustic CLI for the makefile #783

Merged
merged 9 commits into from
Feb 20, 2015
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2015-02-19 Daniel Standage <daniel.standage@gmail.com>

* Makefile: add a new Makefile target `help` to list and describe all
common targets.
* khmer/utils.py, tests/test_functions.py: minor style fixes.

2015-02-16 Titus Brown <titus@idyll.org>

* khmer/utils.py: added 'check_is_pair', 'broken_paired_reader', and
Expand Down
28 changes: 27 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,23 @@ CPPCHECK=ls lib/*.cc khmer/_khmermodule.cc | grep -v test | cppcheck -DNDEBUG \
--quiet -Ilib -Ithird-party/bzip2 -Ithird-party/zlib \
-Ithird-party/smhasher

all: khmer/_khmermodule.so

## all : default task; compile C++ code, build shared object library
all: sharedobj

## help : print this help message and exit
help: Makefile
@sed -n 's/^##//p' $<

## install-dep : install most of the development dependencies via pip
install-dep: install-dependencies

install-dependencies:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any issue with me changing this from install-dependencies to install-dep? It would make the help message more readable, but I don't know how many places in the documentation I would need to update this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several places. An alias is fine:
install-dep: install-dependencies

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that works.

pip2 install --upgrade $(DEVPKGS) || pip install --upgrade $(DEVPKGS)

## sharedobj : build khmer shared object file
sharedobj: khmer/_khmermodule.so

khmer/_khmermodule.so: $(CPPSOURCES)
./setup.py build_ext --inplace

Expand All @@ -31,14 +43,17 @@ coverage-debug: $(CPPSOURCES)
build_ext --debug --inplace --libraries gcov
touch coverage-debug

## install : install the khmer module and scripts
install: FORCE
./setup.py build install

## dist : create a module package for distribution
dist: dist/khmer-$(VERSION).tar.gz

dist/khmer-$(VERSION).tar.gz: $(SOURCES)
./setup.py sdist

## clean : clean up all temporary / machine-generated files
clean: FORCE
cd lib && ${MAKE} clean || true
cd tests && rm -rf khmertest_* || true
Expand All @@ -52,6 +67,7 @@ debug: FORCE
export CFLAGS="-pg -fprofile-arcs"; python setup.py build_ext --debug \
--inplace

## doc : render documentation in HTML
doc: build/sphinx/html/index.html

build/sphinx/html/index.html: $(SOURCES) $(wildcard doc/*.txt) doc/conf.py all
Expand All @@ -60,6 +76,7 @@ build/sphinx/html/index.html: $(SOURCES) $(wildcard doc/*.txt) doc/conf.py all
@echo '--> docs in build/sphinx/html <--'
@echo ''

## pdf : render documentation as a PDF file
pdf: build/sphinx/latex/khmer.pdf

build/sphinx/latex/khmer.pdf: $(SOURCES) doc/conf.py $(wildcard doc/*.txt)
Expand All @@ -71,9 +88,11 @@ build/sphinx/latex/khmer.pdf: $(SOURCES) doc/conf.py $(wildcard doc/*.txt)
cppcheck-result.xml: $(CPPSOURCES)
${CPPCHECK} --xml-version=2 2> cppcheck-result.xml

## cppcheck : run static analysis on C++ code
cppcheck: $(CPPSOURCES)
${CPPCHECK}

## pep8 : check Python code style
pep8: $(PYSOURCES) $(wildcard tests/*.py)
pep8 --exclude=_version.py setup.py khmer/ scripts/ tests/ || true

Expand All @@ -84,17 +103,21 @@ pep8_report.txt: $(PYSOURCES) $(wildcard tests/*.py)
diff_pep8_report: pep8_report.txt
diff-quality --violations=pep8 pep8_report.txt

## astyle : fix most C++ code indentation and formatting
astyle: $(CPPSOURCES)
astyle -A10 --max-code-length=80 $(CPPSOURCES)

## autopep8 : fix most Python code indentation and formatting
autopep8: $(PYSOURCES) $(wildcard tests/*.py)
autopep8 --recursive --in-place --exclude _version.py --ignore E309 \
setup.py khmer/*.py scripts/*.py tests/*.py

# A command to automatically run astyle and autopep8 on appropriate files
## format : check/fix all code indentation and formatting (runs astyle and autopep8)
format: astyle autopep8
# Do nothing

## pylint : run static code analysis on Python code
pylint: $(PYSOURCES) $(wildcard tests/*.py)
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
setup.py khmer/[!_]*.py khmer/__init__.py scripts/*.py tests \
Expand Down Expand Up @@ -141,6 +164,7 @@ diff-cover.html: coverage-gcovr.xml coverage.xml
nosetests.xml: FORCE
./setup.py nosetests --with-xunit

## doxygen : generate documentation of the C++ and Python code
doxygen: doc/doxygen/html/index.html

doc/doxygen/html/index.html: ${CPPSOURCES} ${PYSOURCES}
Expand All @@ -153,6 +177,7 @@ lib:
cd lib && \
$(MAKE)

## test : run the khmer test suite
test: FORCE
./setup.py develop
./setup.py nosetests
Expand All @@ -161,6 +186,7 @@ sloccount.sc: ${CPPSOURCES} ${PYSOURCES} $(wildcard tests/*.py) Makefile
sloccount --duplicates --wide --details lib khmer scripts tests \
setup.py Makefile > sloccount.sc

## sloccount : count lines of code
sloccount:
sloccount lib khmer scripts tests setup.py Makefile

Expand Down
4 changes: 2 additions & 2 deletions khmer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ def write_record(record, fileobj):
fileobj.write(
'@{name}\n{seq}\n'
'+\n{qual}\n'.format(name=record.name,
seq=record.sequence,
qual=record.quality))
seq=record.sequence,
qual=record.quality))
else:
fileobj.write(
'>{name}\n{seq}\n'.format(name=record.name,
Expand Down
10 changes: 5 additions & 5 deletions tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@ def test_check_is_pair_7():


class Test_BrokenPairedReader(object):
stream = [FakeFastaRead(name='seq1/1', sequence='A'*5),
FakeFastaRead(name='seq1/2', sequence='A'*4),
FakeFastaRead(name='seq2/1', sequence='A'*5),
FakeFastaRead(name='seq3/1', sequence='A'*3),
FakeFastaRead(name='seq3/2', sequence='A'*5)]
stream = [FakeFastaRead(name='seq1/1', sequence='A' * 5),
FakeFastaRead(name='seq1/2', sequence='A' * 4),
FakeFastaRead(name='seq2/1', sequence='A' * 5),
FakeFastaRead(name='seq3/1', sequence='A' * 3),
FakeFastaRead(name='seq3/2', sequence='A' * 5)]

def gather(self, **kw):
iter = broken_paired_reader(self.stream, **kw)
Expand Down