oxbow.from_bam#
- oxbow.from_bam(source: str | Path | Callable[[], IO[bytes] | str], compression: Literal['bgzf', None] = 'bgzf', *, fields: Literal['*'] | list[str] | None = '*', tag_defs: list[tuple[str, str]] | None = None, regions: str | list[str] | None = None, index: str | Path | Callable[[], IO[bytes] | str] | None = None, batch_size: int = 131072) BamFile#
Create a BAM file data source.
Changed in version 0.7.0: The
tag_scan_rowsparameter was removed and tag definitions are no longer discovered by default. Thetag_defsparameter now defaults to omitting tag definitions (None). To perform tag discovery, use thewith_tags()method on the returned data source, which accepts ascan_rowsparameter to control how many records are scanned.- Parameters:
source (str, pathlib.Path, or Callable) – The URI or path to the BAM file, or a callable that opens the file as a file-like object.
compression (Literal["bgzf", None], default: "bgzf") – Compression of the source bytestream. By default, BAM sources are assumed to be BGZF-compressed. If None, the source is assumed to be uncompressed. For more custom decoding, provide a callable
sourceinstead.fields (list[str] or "*", optional [default: "*"]) – Standard SAM fields to include. By default, all standard fields are included.
tag_defs (list[tuple[str, str]], optional [default: None]) – Definitions for tags to project. These will be nested in a “tags” column. If None, tag definitions are omitted. To discover tag definitions, use the
with_tags()method on the returned data source.regions (str | list[str], optional) – One or more genomic regions to query. Only applicable if an associated index file is available.
index (str, pathlib.Path, or Callable, optional) – An optional index file associated with the BAM file. If
sourceis a URI or path, is BGZF-compressed, and the index file shares the same name with a “.tbi” or “.csi” extension, the index file is automatically detected.batch_size (int, optional [default: 131072]) – The number of records to read in each batch.
- Returns:
A data source object representing the BAM file.
- Return type:
Notes
Binary Alignment Map (BAM) is a binary representation of SAM files.