Skip to main content

Generate cov3 files used in DEMIC

Project description

pycov3

Tests codecov Renovate enabled Codacy Badge PyPI Bioconda DockerHub

A package for generating cov3 files which are generated from sam files giving coverage information and a fasta file giving binned contigs. Cov3 files are used as input for the DEMIC R package which calculates PTR, an estimate for bacterial growth rates.

Installation

PyPi

pip install pycov3
pycov3 -h

Bioconda

conda create -n pycov3 -c conda-forge -c bioconda pycov3
conda activate pycov3
pycov3 -h

DockerHub

docker pull ctbushman/pycov3:latest
docker run --rm --name pycov3 pycov3 pycov3 -h

GitHub

git clone https://github.com/Ulthran/pycov3.git
cd pycov3/
pip install .
pycov3 -h

Usage

Use -h to see options for running the CLI.

$ pycov3 -h

You can also use the library in your own code. Create a SAM directory and FASTA directory, set any non-default window or coverage parameters, then create a COV3 directory and use it to generate a COV3 file for each contig set in the FASTA directory.

    from pycov3.Directory import Cov3Dir, FastaDir, SamDir

    sam_d = SamDir(Path("/path/to/sams/"), False)

    window_params = {
        "window_size": None,
        "window_step": None,
        "edge_length": sam_d.calculate_edge_length(),
    }
    coverage_params = {
        "mapq_cutoff": None,
        "mapl_cutoff": None,
        "max_mismatch_ratio": None,
    }
    window_params = {k: v for k, v in window_params.items() if v is not None}
    coverage_params = {k: v for k, v in coverage_params.items() if v is not None}

    fasta_d = FastaDir(Path("/path/to/fastas/"), False)

    cov3_d = Cov3Dir(
        Path(args.out_dir),
        False,
        fasta_d.get_filenames(),
        window_params,
        coverage_params,
    )

    cov3_d.generate(sam_d, fasta_d)

Alternatively, to use the bare application logic and do all the file handling yourself, you can use the Cov3Generator class which takes a list of generators as SAM inputs and a generator as a FASTA input.

    from pycov3.Cov3Generator import Cov3Generator
    from pycov3.File import Cov3File

    cov3_generator = Cov3Generator(
        sam_generators,
        fasta_generator,
        sample,
        bin_name,
        window_params,
        **coverage_params,
    )

    cov3_dict = cov3_generator.generate_cov3()

    # Write output
    cov3_file = Cov3File(Path(/path/to/output/), "001")
    cov3_file.write_generator(cov3_generator.generate_cov3())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycov3-2.0.4.dev0.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

pycov3-2.0.4.dev0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file pycov3-2.0.4.dev0.tar.gz.

File metadata

  • Download URL: pycov3-2.0.4.dev0.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for pycov3-2.0.4.dev0.tar.gz
Algorithm Hash digest
SHA256 2f66853f5a90a028bace45cf92459ae80716f5e7548768fd8bd8a7052d07967c
MD5 feeec6875d49976776173113ec1c89ad
BLAKE2b-256 4fdd7825b4838e8c4d2938b241baff686d8c5c5ad9450d80f8651b33699c8e91

See more details on using hashes here.

File details

Details for the file pycov3-2.0.4.dev0-py3-none-any.whl.

File metadata

  • Download URL: pycov3-2.0.4.dev0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for pycov3-2.0.4.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 f640203974411516d819f52877fe83d63068d3568935e9ef331560a0f9c7319e
MD5 af1af83117645080dd1c4a66fdd0b12a
BLAKE2b-256 397e0986faec6b364d802e256ecb441093512f8a0c7028593df8556b69b5e226

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page