Samwell provides elegant utilities for managing biological data.
First install samwell:
pip install samwell
Samwell provides easy utilities for reading/writing BAMs:
from samwell import sam
with sam.writer("my-output-file.bam") as out_bam:
with sam.reader("myfile.bam") as in_bam:
for read in fp:
if read.is_paired:
out_bam.write(read)
You can use samwell
to easily realign fastq records as necessary
from samwell import sam
from samwell import bwa_mem
with sam.reader("myfile.bam") as in_bam:
with sam.writer("outfile.bam") as out_bam:
fastq_gen = (FastqRecord.build(read) for read in in_bam)
gen = clip_specific_reads(fastq_gen)
out_bam.write(bwa_mem.align(gen))
See samwell.bwa_mem
module for more detail.
Samwell uses poetry
for dependency managment.
Please install poetry
using the instructions in the above link.
Then simply execute:
poetry install
poetry run flake8 --config=flake8.cfg samwell
poetry run mypy -p samwell --config=mypy.ini
poetry run python -m pytest --cov=samwell --cov-branch