Skip to content

Commit

Permalink
Merge pull request #30 from klebgenomics/development
Browse files Browse the repository at this point in the history
Bump to version 3.0.0b1
  • Loading branch information
tomdstanton authored Apr 25, 2024
2 parents 0fd362f + 40f2bda commit cc691ab
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 60 deletions.
Empty file removed __init__.py
Empty file.
14 changes: 9 additions & 5 deletions docs/source/Installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Kaptive requires the following software and libraries to be installed and availa

* `Python <https://python.org/>`_ >=3.9
* `Biopython <https://biopython.org/>`_ >=1.83
* `minimap2 <https://lh3.github.io/minimap2/>`_.
* `minimap2 <https://lh3.github.io/minimap2/>`_
* `DNA Features Viewer <https://edinburgh-genome-foundry.github.io/DnaFeaturesViewer/>`_


Expand All @@ -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/

6 changes: 4 additions & 2 deletions kaptive/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 ----------------------------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions kaptive/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 9 additions & 0 deletions kaptive/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion kaptive/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion kaptive/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
If not, see <https://www.gnu.org/licenses/>.
"""

__version__ = '3.0.0b'
__version__ = '3.0.0b1'
34 changes: 34 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "kaptive"
authors = [
{name="Tom Stanton", email="[email protected]" },
]
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__"}
18 changes: 9 additions & 9 deletions reference_database/Klebsiella_o_locus_primary_reference.gbk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
42 changes: 0 additions & 42 deletions setup.py

This file was deleted.

0 comments on commit cc691ab

Please sign in to comment.