diff --git a/__init__.py b/__init__.py deleted file mode 100755 index e69de29..0000000 diff --git a/docs/source/Installation.rst b/docs/source/Installation.rst index 00a8535..6ae4051 100644 --- a/docs/source/Installation.rst +++ b/docs/source/Installation.rst @@ -9,7 +9,7 @@ Kaptive requires the following software and libraries to be installed and availa * `Python `_ >=3.9 * `Biopython `_ >=1.83 -* `minimap2 `_. +* `minimap2 `_ * `DNA Features Viewer `_ @@ -18,10 +18,14 @@ Download and install Kaptive With pip:: - git clone https://github.com/klebgenomics/Kaptive.git - pip install Kaptive/ - + pip install kaptive With conda:: - conda install -c bioconda kaptive + conda install -c bioconda kaptive + +From source:: + + git clone https://github.com/klebgenomics/Kaptive.git + python -m pip install Kaptive/ + diff --git a/kaptive/__main__.py b/kaptive/__main__.py index 2181194..7500802 100644 --- a/kaptive/__main__.py +++ b/kaptive/__main__.py @@ -26,7 +26,8 @@ from kaptive.version import __version__ from kaptive.log import bold, quit_with_error -from kaptive.misc import check_python_version, check_programs, get_logo, check_cpus, check_dir, check_file +from kaptive.misc import (check_python_version, check_biopython_version, check_programs, get_logo, check_cpus, + check_dir, check_file) from kaptive.database import Database, get_database from kaptive.assembly import typing_pipeline, TypingResult @@ -276,7 +277,8 @@ def plot_result(result: TypingResult, outdir: Path, fmt: str): # Main ----------------------------------------------------------------------------------------------------------------- def main(): - check_python_version() + check_python_version(3, 9) + check_biopython_version(1, 83) args = parse_args(sys.argv[1:]) # Assembly mode ---------------------------------------------------------------------------------------------------- diff --git a/kaptive/assembly.py b/kaptive/assembly.py index 6d0c7e9..b2e6b1e 100644 --- a/kaptive/assembly.py +++ b/kaptive/assembly.py @@ -236,6 +236,8 @@ def typing_pipeline( previous_result = gene_result # Set the previous result to the current result # FINALISE CONTIG --------------------------------------------------------------------------------------------- for piece in pieces: # Add sequences to pieces and add them to the result + if not piece.expected_genes: # If the piece has no expected genes, skip it + continue piece.strand = "+" if max(i.strand == i.gene.strand for i in piece.expected_genes) else "-" piece.sequence = contig.sequence[piece.start:piece.end] if piece.strand == "+" else \ contig.sequence[piece.start:piece.end].reverse_complement() diff --git a/kaptive/misc.py b/kaptive/misc.py index 816c8b2..4d32e82 100644 --- a/kaptive/misc.py +++ b/kaptive/misc.py @@ -88,6 +88,15 @@ def check_python_version(major: int = 3, minor: int = 8): quit_with_error(f'Python version {major}.{minor} or greater required') +def check_biopython_version(major: int = 1, minor: int = 79): + try: + from Bio import __version__ as biopython_version + except ImportError: + quit_with_error('BioPython is required') + if (major_version := int(biopython_version.split('.')[0])) < major or (minor_version := int(biopython_version.split('.')[1])) < minor: + quit_with_error(f'Biopython version {major}.{minor} or greater required, got {major_version}.{minor_version}') + + def parse_fasta(fasta: Path, skip_plasmids: bool = False, verbose: bool = False) -> Generator[tuple[str, str, str], None, None]: log(f'Parsing {fasta.name}', verbose) with open(fasta, 'rb') as f: # Read the first two bytes to determine the compression format diff --git a/kaptive/typing.py b/kaptive/typing.py index 0728907..01edb57 100644 --- a/kaptive/typing.py +++ b/kaptive/typing.py @@ -130,7 +130,7 @@ def phenotype(self) -> str: def problems(self) -> str: if self._problems is not None: return self._problems - problems = f'?{x}' if (x := len(self.pieces)) > 1 else '' + problems = f'?{x}' if (x := len(self.pieces)) != 1 else '' problems += '-' if self.missing_genes else '' problems += '+' if self.unexpected_genes_inside_locus else '' problems += '*' if any( diff --git a/kaptive/version.py b/kaptive/version.py index 78c2139..c667313 100644 --- a/kaptive/version.py +++ b/kaptive/version.py @@ -14,4 +14,4 @@ If not, see . """ -__version__ = '3.0.0b' +__version__ = '3.0.0b1' diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..0b6ed89 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,34 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "kaptive" +authors = [ + {name="Tom Stanton", email="tomdstanton@gmail.com" }, +] +description = "In silico serotyping" +readme = {file = "README.md", content-type = "text/markdown"} +requires-python = ">=3.9" +dependencies = ["biopython", "dna_features_viewer"] +keywords = ["bioinformatics", "serotyping", "microbiology"] +license = {file = "LICENSE"} +classifiers = [ + "Environment :: Console", + "Operating System :: OS Independent", + "Programming Language :: Python", +] +dynamic = ["version"] + +[project.scripts] +kaptive = "kaptive.__main__:main" + +[tool.setuptools.packages.find] +include = ["kaptive"] +exclude = ["test", 'development'] + +[tool.setuptools.package-data] +kaptive = ['../reference_database/*'] + +[tool.setuptools.dynamic] +version = {attr = "kaptive.version.__version__"} diff --git a/reference_database/Klebsiella_o_locus_primary_reference.gbk b/reference_database/Klebsiella_o_locus_primary_reference.gbk index b4a9b1d..61f7aa6 100644 --- a/reference_database/Klebsiella_o_locus_primary_reference.gbk +++ b/reference_database/Klebsiella_o_locus_primary_reference.gbk @@ -48,7 +48,7 @@ FEATURES Location/Qualifiers RDWLYVEDHARALYKVATEGKSGETYNIGGHNERKNIDVVRTICTILDKVVAQKPGNIT HFADLITFVTDRPGHDLRYAIDATKIQHDLGWVPQETFESGIEKTVHWYLNNQTWWQRV LDGSYAGERLGLNN" - /locus_tag="OL101_01_rfbB" + /locus_tag="OL13_01_rfbB" gene 1092..1961 /gene="rfbA" CDS 1092..1961 @@ -67,7 +67,7 @@ FEATURES Location/Qualifiers PKSDWAVTGLYFYDNNVVEMAKDVKPSERGELEITTLNQMYLEQGDLHVELLGRGFAWL DTGTHDSLMDASQFIHTIEKRQGMKVACLEEIAYRNQWLSAEGVAAQAERLKKTEYGAY LKRLLNER" - /locus_tag="OL101_02_rfbA" + /locus_tag="OL13_02_rfbA" gene 1993..2883 /gene="rfbD" CDS 1993..2883 @@ -86,7 +86,7 @@ FEATURES Location/Qualifiers KTMLRLAGEKETLTIIDDQHGAPTGAELLADCTATAIRETLRNPALAGTYHLVASGETS WCDYARYVFEVARAHGAELAIQEVKGIPTTAYPTPAKRPLNSRLSNEKFQQAFGVTLPD WRQGVARVVTEVLGK" - /locus_tag="OL101_03_rfbD" + /locus_tag="OL13_03_rfbD" gene 2898..3452 /gene="rfbC" CDS 2898..3452 @@ -103,7 +103,7 @@ FEATURES Location/Qualifiers VQDNHSQSQKGVLRGLHYQLDPHAQGKLVRCVEGEVFDVAVDIRRSSSTFGKWVGAVLS AENKRQLWIPEGFAHGFMALSDTVQFVYKATNYYAPQSERSIIWNDPEIGIDWPALNDC ALSLSEKDLQAHTLATAEVYA" - /locus_tag="OL101_04_rfbC" + /locus_tag="OL13_04_rfbC" gene 3539..4369 /gene="wbbL" CDS 3539..4369 @@ -121,7 +121,7 @@ FEATURES Location/Qualifiers LVSFAWVNEYNFVSPQIIYKNGERQYSCRLLPTPSNLFLRRFLPTTAIKYDATYELKDA EYDKVFSPPSVSGCFMLLTNVLLQKLNGFDERYFMYLEDVDLCRRALQLTKIYYCPETT IVHVFNKGSYKSKLLLWYHVRSAITYFNKWGWFFDKKRYAYNESALRNIPRKLS" - /locus_tag="OL101_05_wbbL" + /locus_tag="OL13_05_wbbL" gene 4398..5231 /gene="wzm" CDS 4398..5231 @@ -138,7 +138,7 @@ FEATURES Location/Qualifiers QIILNNTNYVKKVIFPLETLSVISLVAALFHTTISLLVLLTAFVIFNGFIHWTIIFIPL VFLPLVIFSLGLSWILASLGVFLRDVSQTTVIITTVLMFLSPVFFPISALPEKYHIWIM LNPVTFIIEQARTVLIWGGLPNFMGILLYTVGASIVAWLGFVFFQKTRKGFADVL" - /locus_tag="OL101_06_wzm" + /locus_tag="OL13_06_wzm" gene 5221..6552 /gene="wzt" CDS 5221..6552 @@ -159,7 +159,7 @@ FEATURES Location/Qualifiers AIQNTQTNSEVDEKRFGSGRAIIEDFSIMKADGTPLSEKPLVKPNEEIYFSFKLNSSEN INDVVLGVSLSRTQGGDIWGDNNIFAGHKIDLAPGLRKLKYKVKLPINTGDYLVHCGLA CFNNGEREELDQRRPIAKVKFWSSRELGGVIHSPVNVIEGDELS" - /locus_tag="OL101_07_wzt" + /locus_tag="OL13_07_wzt" gene 6549..10115 /gene="wbbB" CDS 6549..10115 @@ -192,7 +192,7 @@ FEATURES Location/Qualifiers RIINWDISFQRMSELWRQAIADFDGFFQQQSVDPMPDVSSETRVDHFYRDYYIRDSWWR ESELGRIDFKTLIDSFYSSDNITIVEEKISQPQGRKEKLLAILWMLRQNPALSWVTKLI PYRLQRYVKRQLSRRALHEIVR" - /locus_tag="OL101_08_wbbB" + /locus_tag="OL13_08_wbbB" gene complement(10274..12064) /gene="glycosylhydrolase" CDS complement(10274..12064) @@ -215,7 +215,7 @@ FEATURES Location/Qualifiers GRERTFSHQIAPMFNADWNEEKIAAEDSLKKNNHYNIGLNTYGSAFYGDYLFNWLKTSG IERYGIPEVHPMVENEEVIYDALEHHHNNGAIFISPYYLEIKPDSFGVDKEHEKFSINE NNTNYYSSSFYHALKKIMKE" - /locus_tag="OL101_09_glycosylhydrolase" + /locus_tag="OL13_09_glycosylhydrolase" ORIGIN 1 atgaagattc ttgtcaccgg gggtgcaggc tttatcggtt ctgccgtggt tcgtcatatc 61 attgaaaata ccctggacga agtccgtgtg atggactgcc tgacctacgc cggcaacctt diff --git a/setup.py b/setup.py deleted file mode 100755 index 08a5324..0000000 --- a/setup.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python3 -""" -Copyright 2023 Tom Stanton (tomdstanton@gmail.com) -https://github.com/klebgenomics/Kaptive - -This file is part of Kaptive. Kaptive is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by the Free Software Foundation, -either version 3 of the License, or (at your option) any later version. Kaptive is distributed -in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. You should have received a copy of the GNU General Public License along with Kaptive. -If not, see . -""" - -from setuptools import setup -with open('README.md', 'rb') as readme: - long_description = readme.read() -if not isinstance(long_description, str): - long_description = long_description.decode() - -# Get the version from kaptive.__version__.py. -__version__ = '0.0.0' -with open('kaptive/version.py') as ver_file: - exec(ver_file.read()) -print(__version__) - -setup( - name='kaptive', - version=__version__, - description='In silico serotyping', - long_description=long_description, - url='http://github.com/klebgenomics/Kaptive', - author='Tom Stanton', - author_email='tomdstanton@gmail.com', - license='GPLv3', - install_requires=['biopython', 'dna_features_viewer'], - packages=['kaptive'], - package_data={'kaptive': ['../reference_database/*']}, - include_package_data=True, - package_dir={'kaptive': 'kaptive'}, - entry_points={'console_scripts': ['kaptive = kaptive.__main__:main']} -)