Skip to content

Commit d780346

Browse files
author
genommewalker
committed
initial commit
0 parents  commit d780346

19 files changed

+3654
-0
lines changed

.gitignore

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.coverage
41+
.coverage.*
42+
.cache
43+
nosetests.xml
44+
coverage.xml
45+
*,cover
46+
.hypothesis/
47+
48+
# Translations
49+
*.mo
50+
*.pot
51+
52+
# Django stuff:
53+
*.log
54+
55+
# Sphinx documentation
56+
docs/_build/
57+
58+
# PyBuilder
59+
target/
60+
61+
# pyenv python configuration file
62+
.python-version
63+
.vscode/

LICENSE

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
GNU GENERAL PUBLIC LICENSE
2+
Version 3, 29 June 2007
3+
4+
A simple genome de-replication tool with fastANI
5+
Copyright (C) 2020 Antonio Fernandez-Guerra
6+
7+
This program is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
This program is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
20+
Also add information on how to contact you by electronic and paper mail.
21+
22+
You should also get your employer (if you work as a programmer) or school,
23+
if any, to sign a "copyright disclaimer" for the program, if necessary.
24+
For more information on this, and how to apply and follow the GNU GPL, see
25+
<http://www.gnu.org/licenses/>.
26+
27+
The GNU General Public License does not permit incorporating your program
28+
into proprietary programs. If your program is a subroutine library, you
29+
may consider it more useful to permit linking proprietary applications with
30+
the library. If this is what you want to do, use the GNU Lesser General
31+
Public License instead of this License. But first, please read
32+
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
33+

MANIFEST.in

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include versioneer.py
2+
include bam_filter/_version.py

README.md

+284
Large diffs are not rendered by default.

appveyor.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
environment:
2+
global:
3+
# SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
4+
# /E:ON and /V:ON options are not enabled in the batch script intepreter
5+
# See: http://stackoverflow.com/a/13751649/163740
6+
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\tools\\appveyor\\run_with_env.cmd"
7+
8+
matrix:
9+
- PYTHON: "C:\\Miniconda36-x64"
10+
PYTHON_VERSION: "3.6"
11+
PYTHON_ARCH: "64"
12+
13+
- PYTHON: "C:\\Miniconda-x64"
14+
PYTHON_VERSION: "2.7"
15+
PYTHON_ARCH: "64"
16+
17+
init:
18+
- ECHO %PYTHON% %PYTHON_VERSION% %PYTHON_ARCH% %HOME%
19+
20+
install:
21+
# If there is a newer build queued for the same PR, cancel this one.
22+
# The AppVeyor 'rollout builds' option is supposed to serve the same
23+
# purpose but it is problematic because it tends to cancel builds pushed
24+
# directly to master instead of just PR builds (or the converse).
25+
# credits: JuliaLang developers.
26+
- ps:
27+
if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
28+
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
29+
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
30+
throw "There are newer queued builds for this pull request, failing early." }
31+
# these correspond to folder naming of miniconda installs on appveyor. See
32+
# https://www.appveyor.com/docs/installed-software#python
33+
- if "%PYTHON_VERSION%" == "3.6" set "BASE_PYTHON_VERSION=36"
34+
- if "%PYTHON_ARCH%" == "64" set "ARCH_LABEL=-x64"
35+
- call "C:\Miniconda%BASE_PYTHON_VERSION%%ARCH_LABEL%\Scripts\activate.bat"
36+
- conda config --set always_yes yes
37+
- conda update -q conda
38+
- conda config --set auto_update_conda no
39+
- conda update -q --all
40+
- conda install -q pytest pytest-cov conda-build anaconda-client
41+
- conda info
42+
# this is to ensure dependencies
43+
- conda build conda.recipe --no-test
44+
- conda install --use-local bam_filter
45+
46+
# Not a .NET project, we build package in the install step instead
47+
build: false
48+
49+
test_script:
50+
- py.test --color=yes -v --cov bam_filter --cov-report xml tests
51+
52+
on_success:
53+
- conda install -c conda-forge codecov
54+
- codecov --env PYTHON_VERSION --file C:\projects\bam-filter\coverage.xml

bam_filter/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from ._version import get_versions
2+
3+
__version__ = get_versions()["version"]
4+
del get_versions

bam_filter/__main__.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
"""
2+
This program is free software: you can redistribute it and/or modify it under the terms of the GNU
3+
General Public License as published by the Free Software Foundation, either version 3 of the
4+
License, or (at your option) any later version.
5+
6+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
7+
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8+
General Public License for more details.
9+
10+
You should have received a copy of the GNU General Public License along with this program. If not,
11+
see <https://www.gnu.org/licenses/>.
12+
"""
13+
14+
15+
import logging
16+
17+
from bam_filter.sam_utils import processBam, filterReferenceBAMfile
18+
19+
from bam_filter.utils import (
20+
get_arguments,
21+
)
22+
23+
log = logging.getLogger("my_logger")
24+
25+
26+
def main():
27+
28+
logging.basicConfig(
29+
level=logging.DEBUG, format="%(levelname)s ::: %(asctime)s ::: %(message)s"
30+
)
31+
32+
args = get_arguments()
33+
logging.getLogger("my_logger").setLevel(
34+
logging.DEBUG if args.debug else logging.INFO
35+
)
36+
datadf = processBam(bam=args.bam, threads=args.threads)
37+
datadf_filtered = datadf.loc[
38+
(datadf["breadthExpRatio"] > args.breadthExpRatio)
39+
& (datadf["covEvenness"] > args.covEvenness)
40+
& (datadf["nReads"] > args.nReads)
41+
]
42+
datadf.to_csv(args.output, sep="\t", index=False)
43+
refs_dict = dict(zip(datadf["chromosome"], datadf["referenceLength"]))
44+
filterReferenceBAMfile(args.bam, refs_dict, outBAMfile="test.bam")
45+
46+
47+
if __name__ == "__main__":
48+
main()

0 commit comments

Comments
 (0)