Skip to main content

Generate cov3 files used in DEMIC

Project description

pycov3

CI codecov Super-Linter Codacy Badge PyPI version

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.

Install it from PyPI

pip install pycov3

Usage

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())
$ python -m pycov3 -h
#or
$ pycov3 -h

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.1.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

pycov3-2.0.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file pycov3-2.0.1.tar.gz.

File metadata

  • Download URL: pycov3-2.0.1.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for pycov3-2.0.1.tar.gz
Algorithm Hash digest
SHA256 bd6c43c209c70363d288c175187eeb8cf2691abf34875164ee5aef31334e70df
MD5 67d4700f11eb4a2b7d62334854d5406f
BLAKE2b-256 299685b59d5c04fcb3eee207bc5d4ed03ca74ed84708f3158c6c9e44a1c8cd7e

See more details on using hashes here.

File details

Details for the file pycov3-2.0.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for pycov3-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e86cacb70cb803be2ae4ebe98fa347e55d3d10b2f92dd8ec7fd980b903788bc5
MD5 0a12705d5023c66a9a65d0d6993e4935
BLAKE2b-256 744ed21d6a78ff55005b4d743aa9d276fe45a12cd6247a267b6dcfe980457280

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