modos.genomics.formats#

Attributes#

Classes#

GenomicFileSuffix

Enumeration of all supported genomic file suffixes.

Functions#

read_pysam(path[, region])

Automatically instantiate a pysam file object from input path and passes any additional kwarg to it.

get_index(file_path)

is_encrypted(file_path)

add_suffix(file_path, suffix)

Return the file path with specific suffix.

remove_suffix(file_path, suffix)

Return the file path without specific suffix.

Module Contents#

modos.genomics.formats.MAGIC_NUMBER = b'crypt4gh'[source]#
class modos.genomics.formats.GenomicFileSuffix[source]#

Bases: tuple, enum.Enum

Enumeration of all supported genomic file suffixes.

CRAM = ('.cram',)[source]#
BAM = ('.bam',)[source]#
SAM = ('.sam',)[source]#
VCF = ('.vcf', '.vcf.gz')[source]#
BCF = ('.bcf',)[source]#
FASTA = ('.fasta', '.fa')[source]#
FASTQ = ('.fastq', '.fq')[source]#
classmethod list_formats()[source]#
classmethod from_path(path)[source]#
Parameters:

path (pathlib.Path)

Return type:

GenomicFileSuffix

get_index_suffix()[source]#

Return the supported index suffix related to a genomic filetype

Return type:

str

to_htsget_endpoint()[source]#

Return the htsget endpoint for a genomic file type

Return type:

str

modos.genomics.formats.read_pysam(path, region=None, **kwargs)[source]#

Automatically instantiate a pysam file object from input path and passes any additional kwarg to it.

Parameters:
Return type:

Iterator[pysam.AlignedSegment | pysam.VariantRecord]

modos.genomics.formats.get_index(file_path)[source]#
Parameters:

file_path (pathlib.Path)

Return type:

Optional[pathlib.Path]

modos.genomics.formats.is_encrypted(file_path)[source]#
modos.genomics.formats.add_suffix(file_path, suffix)[source]#

Return the file path with specific suffix.

Parameters:
Return type:

pathlib.Path

modos.genomics.formats.remove_suffix(file_path, suffix)[source]#

Return the file path without specific suffix.

Parameters:
Return type:

pathlib.Path