Generate cov3 files used in DEMIC
Project description
pycov3
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pycov3-2.0.2.tar.gz
.
File metadata
- Download URL: pycov3-2.0.2.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | aafc999cbf5946b0a99db0e7bbfb5d11db812b0c3670ebeb285de12b093c67f5 |
|
MD5 | 2298d127ad07b7d59bdf473b4fa8ef88 |
|
BLAKE2b-256 | f4dd68c8447b82911dd591eb886add23e41a432a0ccea350c42581768cc18b66 |
File details
Details for the file pycov3-2.0.2-py3-none-any.whl
.
File metadata
- Download URL: pycov3-2.0.2-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0b62355289232d9004677576140cb369805ba9485a6c775b6005774238175df |
|
MD5 | 7cde564c38a06ae5d8f36633e2979268 |
|
BLAKE2b-256 | 68daa2e681a47965c89b45e60a6c609d7382cd111520fc0cca1454dd02880ee4 |