jpayne@68: import sys jpayne@68: from typing import ( jpayne@68: Optional, jpayne@68: Union, jpayne@68: Any, jpayne@68: Sequence, jpayne@68: Tuple, jpayne@68: Iterator, jpayne@68: List, jpayne@68: Iterable, jpayne@68: Dict, jpayne@68: overload, jpayne@68: TypeVar, jpayne@68: Mapping, jpayne@68: Generic, jpayne@68: ) jpayne@68: jpayne@68: if sys.version_info < (3, 8): jpayne@68: from typing_extensions import Literal jpayne@68: else: jpayne@68: from typing import Literal jpayne@68: jpayne@68: from pysam.libchtslib import HTSFile, _HasFileNo jpayne@68: jpayne@68: _D = TypeVar("_D") jpayne@68: _K = TypeVar("_K", str, Union[int, str]) jpayne@68: _V = TypeVar("_V") jpayne@68: jpayne@68: class _Mapping(Generic[_K, _V]): jpayne@68: def __len__(self) -> int: ... jpayne@68: def __contains__(self, key: _K) -> bool: ... jpayne@68: def __iter__(self) -> Iterator[_K]: ... jpayne@68: def iterkeys(self) -> Iterator[_K]: ... jpayne@68: def itervalues(self) -> Iterator[_V]: ... jpayne@68: def iteritems(self) -> Iterator[Tuple[_K, _V]]: ... jpayne@68: def keys(self) -> List[_K]: ... jpayne@68: def items(self) -> List[Tuple[_K, _V]]: ... jpayne@68: def values(self) -> List[_V]: ... jpayne@68: def __bool__(self) -> bool: ... jpayne@68: def __getitem__(self, key: _K) -> _V: ... jpayne@68: def get(self, key: _K, default: _D = ...) -> Union[_D, _V]: ... jpayne@68: jpayne@68: class VariantHeaderRecord(_Mapping[str, str]): jpayne@68: @property jpayne@68: def header(self) -> VariantHeader: ... jpayne@68: @property jpayne@68: def type(self) -> Optional[str]: ... jpayne@68: @property jpayne@68: def key(self) -> Optional[str]: ... jpayne@68: @property jpayne@68: def value(self) -> Optional[str]: ... jpayne@68: @property jpayne@68: def attrs(self) -> Sequence[Tuple[str, str]]: ... jpayne@68: def update(self, items: Union[Iterable, Dict] = ..., **kwargs) -> None: ... jpayne@68: def pop(self, key: str, default: str = ...) -> str: ... jpayne@68: def remove(self) -> None: ... # crashes jpayne@68: jpayne@68: class VariantHeaderRecords: jpayne@68: @property jpayne@68: def header(self) -> VariantHeader: ... jpayne@68: def __len__(self) -> int: ... jpayne@68: def __bool__(self) -> bool: ... jpayne@68: def __getitem__(self, index) -> VariantHeaderRecord: ... jpayne@68: def __iter__(self) -> Iterator[VariantHeaderRecord]: ... jpayne@68: jpayne@68: class VariantMetadata: jpayne@68: @property jpayne@68: def header(self) -> VariantHeader: ... jpayne@68: @property jpayne@68: def name(self) -> str: ... jpayne@68: # @property # should this be exposed? jpayne@68: # def id(self) -> int: ... jpayne@68: @property jpayne@68: def number(self) -> Optional[str]: ... jpayne@68: @property jpayne@68: def type(self) -> Optional[str]: ... jpayne@68: @property jpayne@68: def description(self) -> Optional[str]: ... jpayne@68: @property jpayne@68: def record(self) -> Optional[VariantHeaderRecord]: ... jpayne@68: def remove_header(self) -> None: ... jpayne@68: jpayne@68: class VariantHeaderMetadata(_Mapping[str, VariantMetadata]): jpayne@68: @property jpayne@68: def header(self) -> VariantHeader: ... jpayne@68: def add( jpayne@68: self, jpayne@68: id: str, jpayne@68: number: Optional[Union[int, str]], jpayne@68: type: Optional[str], jpayne@68: description: str, jpayne@68: **kwargs jpayne@68: ) -> None: ... jpayne@68: def remove_header(self, key: str) -> None: ... jpayne@68: def clear_header(self) -> None: ... jpayne@68: jpayne@68: class VariantContig: jpayne@68: @property jpayne@68: def header(self) -> VariantHeader: ... jpayne@68: @property jpayne@68: def name(self) -> str: ... jpayne@68: @property jpayne@68: def id(self) -> int: ... jpayne@68: @property jpayne@68: def length(self) -> Optional[int]: ... jpayne@68: @property jpayne@68: def header_record(self) -> VariantHeaderRecord: ... jpayne@68: def remove_header(self) -> None: ... jpayne@68: jpayne@68: class VariantHeaderContigs(_Mapping[Union[int, str], VariantContig]): jpayne@68: @property jpayne@68: def header(self) -> VariantHeader: ... jpayne@68: def remove_header(self, key: Union[int, str]) -> None: ... jpayne@68: def clear_header(self) -> None: ... jpayne@68: def add(self, id: str, length: Optional[int] = ..., **kwargs) -> None: ... jpayne@68: jpayne@68: class VariantHeaderSamples: jpayne@68: @property jpayne@68: def header(self) -> VariantHeader: ... jpayne@68: def __len__(self) -> int: ... jpayne@68: def __bool__(self) -> bool: ... jpayne@68: def __getitem__(self, index: int) -> str: ... jpayne@68: def __iter__(self) -> Iterator[str]: ... jpayne@68: def __contains__(self, key: str) -> bool: ... jpayne@68: def add(self, name: str) -> None: ... jpayne@68: jpayne@68: class VariantHeader: jpayne@68: def __init__(self) -> None: ... jpayne@68: def __bool__(self) -> bool: ... jpayne@68: def copy(self) -> VariantHeader: ... jpayne@68: def merge(self, header: VariantHeader) -> None: ... jpayne@68: @property jpayne@68: def version(self) -> str: ... jpayne@68: @property jpayne@68: def samples(self) -> VariantHeaderSamples: ... jpayne@68: @property jpayne@68: def records(self) -> VariantHeaderRecords: ... jpayne@68: @property jpayne@68: def contigs(self) -> VariantHeaderContigs: ... jpayne@68: @property jpayne@68: def filters(self) -> VariantHeaderMetadata: ... jpayne@68: @property jpayne@68: def info(self) -> VariantHeaderMetadata: ... jpayne@68: @property jpayne@68: def formats(self) -> VariantHeaderMetadata: ... jpayne@68: @property jpayne@68: def alts(self) -> Dict[str, VariantHeaderRecord]: ... jpayne@68: def new_record( jpayne@68: self, jpayne@68: contig: Optional[str] = ..., jpayne@68: start: int = ..., jpayne@68: stop: int = ..., jpayne@68: alleles: Optional[Tuple[str, ...]] = ..., jpayne@68: id: Optional[str] = ..., jpayne@68: qual: Optional[float] = ..., jpayne@68: filter: Optional[Any] = ..., jpayne@68: info: Optional[Mapping[str, _InfoValue]] = ..., jpayne@68: samples: Optional[Iterable[Optional[Mapping[str, _FormatValue]]]] = ..., jpayne@68: **kwargs jpayne@68: ) -> VariantRecord: ... jpayne@68: def add_record(self, record: VariantHeaderRecord) -> None: ... jpayne@68: def add_line(self, line: str) -> None: ... jpayne@68: @overload jpayne@68: def add_meta( jpayne@68: self, key: str, value: None = ..., items: Iterable[Tuple[str, str]] = ... jpayne@68: ) -> None: ... jpayne@68: @overload jpayne@68: def add_meta(self, key: str, value: str = ..., items: None = ...) -> None: ... jpayne@68: def add_sample(self, name: str) -> None: ... jpayne@68: def add_samples(self, *args: Union[str, Iterable[str]]) -> None: ... jpayne@68: jpayne@68: class VariantRecordFilter(_Mapping[Union[int, str], VariantMetadata]): jpayne@68: def add(self, key: str) -> None: ... jpayne@68: def __delitem__(self, key: Union[int, str]) -> None: ... jpayne@68: def clear(self) -> None: ... jpayne@68: def __eq__(self, other) -> bool: ... jpayne@68: def __ne__(self, other) -> bool: ... jpayne@68: jpayne@68: class VariantRecordFormat(_Mapping[str, VariantMetadata]): jpayne@68: def __delitem__(self, key: str) -> None: ... jpayne@68: def clear(self) -> None: ... jpayne@68: jpayne@68: _InfoValue = Any # TODO see bcf_info_get_value jpayne@68: jpayne@68: class VariantRecordInfo(_Mapping[str, _InfoValue]): jpayne@68: def __setitem__(self, key: str, object: _InfoValue) -> None: ... jpayne@68: def __delitem__(self, key: str) -> None: ... jpayne@68: def clear(self) -> None: ... jpayne@68: def update( jpayne@68: self, items: Optional[_Mapping[str, _InfoValue]] = ..., **kwargs jpayne@68: ) -> None: ... jpayne@68: def pop(self, key: str, default: _D = ...) -> Union[_D, _InfoValue]: ... jpayne@68: def __eq__(self, other) -> bool: ... jpayne@68: def __ne__(self, other) -> bool: ... jpayne@68: jpayne@68: class VariantRecordSamples(_Mapping[Union[str, int], "VariantRecordSample"]): jpayne@68: def __eq__(self, other) -> bool: ... jpayne@68: def __ne__(self, other) -> bool: ... jpayne@68: # TODO Do these work? Isn’t the container read only? jpayne@68: def update( jpayne@68: self, jpayne@68: items: Optional[Mapping[Union[str, int], VariantRecordSample]] = ..., jpayne@68: **kwargs jpayne@68: ) -> None: ... jpayne@68: def pop( jpayne@68: self, key: Union[str, int], default: _D = ... jpayne@68: ) -> Union[_D, VariantRecordSample]: ... jpayne@68: jpayne@68: class VariantRecord: jpayne@68: @property jpayne@68: def header(self) -> VariantHeader: ... jpayne@68: def copy(self) -> VariantRecord: ... jpayne@68: def translate(self, dst_header: VariantHeader) -> None: ... jpayne@68: rid: int jpayne@68: chrom: str jpayne@68: contig: str jpayne@68: pos: int jpayne@68: start: int jpayne@68: stop: int jpayne@68: rlen: int jpayne@68: qual: Optional[float] jpayne@68: id: Optional[str] jpayne@68: ref: Optional[str] jpayne@68: alleles: Optional[Tuple[str, ...]] jpayne@68: alts: Optional[Tuple[str, ...]] jpayne@68: @property jpayne@68: def filter(self) -> VariantRecordFilter: ... jpayne@68: @property jpayne@68: def info(self) -> VariantRecordInfo: ... jpayne@68: @property jpayne@68: def format(self) -> VariantRecordFormat: ... jpayne@68: @property jpayne@68: def samples(self) -> VariantRecordSamples: ... jpayne@68: def __eq__(self, other) -> bool: ... jpayne@68: def __ne__(self, other) -> bool: ... jpayne@68: jpayne@68: _FormatValue = Any # TODO see bcf_format_get_value jpayne@68: jpayne@68: class VariantRecordSample(_Mapping[str, _FormatValue]): jpayne@68: @property jpayne@68: def index(self) -> int: ... jpayne@68: @property jpayne@68: def name(self) -> str: ... jpayne@68: allele_indices: Optional[Tuple[Optional[int], ...]] jpayne@68: alleles: Optional[Tuple[Optional[str], ...]] jpayne@68: phased: bool jpayne@68: def __setitem__(self, key: str, value: _FormatValue) -> None: ... jpayne@68: def __delitem__(self, key: str) -> None: ... jpayne@68: def clear(self) -> None: ... jpayne@68: def update( jpayne@68: self, items: Optional[Mapping[str, _FormatValue]] = ..., **kwargs jpayne@68: ) -> None: ... jpayne@68: def pop(self, key: str, default: _D = ...) -> Union[_D, _FormatValue]: ... jpayne@68: def __eq__(self, other) -> Any: ... jpayne@68: def __ne__(self, other) -> Any: ... jpayne@68: jpayne@68: class BaseIndex(_Mapping[Union[int, str], str]): jpayne@68: refs: Sequence[str] jpayne@68: refmap: Dict[str, str] jpayne@68: def __init__(self) -> None: ... jpayne@68: # TODO Do these work? Isn’t the container read only? jpayne@68: def update(self, items: Optional[Mapping[str, str]] = ..., **kwargs) -> None: ... jpayne@68: def pop(self, key: str, default: _D = ...) -> Union[_D, str]: ... jpayne@68: jpayne@68: class BCFIndex(BaseIndex): jpayne@68: @property jpayne@68: def header(self) -> VariantHeader: ... jpayne@68: def __init__(self) -> None: ... jpayne@68: def fetch( jpayne@68: self, jpayne@68: bcf: VariantFile, jpayne@68: contig: str, jpayne@68: start: Optional[int], jpayne@68: stop: Optional[int], jpayne@68: reopen: bool, jpayne@68: ) -> BCFIterator: ... jpayne@68: jpayne@68: class TabixIndex(BaseIndex): jpayne@68: def __init__(self) -> None: ... jpayne@68: def fetch( jpayne@68: self, jpayne@68: bcf: VariantFile, jpayne@68: contig: str, jpayne@68: start: Optional[int], jpayne@68: stop: Optional[int], jpayne@68: reopen: bool, jpayne@68: ) -> TabixIterator: ... jpayne@68: jpayne@68: class BaseIterator: jpayne@68: def __init__(self) -> None: ... jpayne@68: jpayne@68: class BCFIterator(BaseIterator): jpayne@68: def __init__( jpayne@68: self, jpayne@68: bcf: VariantFile, jpayne@68: contig: str, jpayne@68: start: Optional[int] = ..., jpayne@68: stop: Optional[int] = ..., jpayne@68: reopen: bool = ..., jpayne@68: ) -> None: ... jpayne@68: def __iter__(self) -> BCFIterator: ... jpayne@68: def __next__(self) -> VariantRecord: ... jpayne@68: jpayne@68: class TabixIterator(BaseIterator): jpayne@68: def __init__( jpayne@68: self, jpayne@68: bcf: VariantFile, jpayne@68: contig: str, jpayne@68: start: Optional[int] = ..., jpayne@68: stop: Optional[int] = ..., jpayne@68: reopen: bool = ..., jpayne@68: ) -> None: ... jpayne@68: def __iter__(self) -> TabixIterator: ... jpayne@68: def __next__(self) -> VariantRecord: ... jpayne@68: jpayne@68: class VariantFile(HTSFile): jpayne@68: @property jpayne@68: def header(self) -> VariantHeader: ... jpayne@68: @property jpayne@68: def index(self) -> BaseIndex: ... jpayne@68: @property jpayne@68: def drop_samples(self) -> bool: ... jpayne@68: @property jpayne@68: def is_reading(self) -> bool: ... jpayne@68: @property jpayne@68: def header_written(self) -> bool: ... jpayne@68: def __init__( jpayne@68: self, jpayne@68: filename: Union[str, bytes, int, _HasFileNo], jpayne@68: mode: Optional[Literal["r", "w", "wh", "rb", "wb", "wbu", "wb0"]] = ..., jpayne@68: index_filename: Optional[str] = ..., jpayne@68: header: Optional[VariantHeader] = ..., jpayne@68: drop_samples: bool = ..., jpayne@68: duplicate_filehandle: bool = ..., jpayne@68: ignore_truncation: bool = ..., jpayne@68: threads: int = ..., jpayne@68: ) -> None: ... jpayne@68: def close(self) -> None: ... jpayne@68: def __iter__(self) -> VariantFile: ... jpayne@68: def __next__(self) -> VariantRecord: ... jpayne@68: def copy(self) -> VariantFile: ... jpayne@68: def open( jpayne@68: self, jpayne@68: filename: Union[str, bytes, int, _HasFileNo], jpayne@68: mode: Optional[Literal["r", "w", "wh", "rb", "wb", "wbu", "wb0"]] = ..., jpayne@68: index_filename: Optional[str] = ..., jpayne@68: header: Optional[VariantHeader] = ..., jpayne@68: drop_samples: bool = ..., jpayne@68: duplicate_filehandle: bool = ..., jpayne@68: ignore_truncation: bool = ..., jpayne@68: threads: int = ..., jpayne@68: ) -> None: ... jpayne@68: def reset(self) -> None: ... jpayne@68: def is_valid_tid(self, tid: int) -> bool: ... jpayne@68: def get_tid(self, reference: str) -> int: ... jpayne@68: def get_reference_name(self, tid: int) -> str: ... jpayne@68: def fetch( jpayne@68: self, jpayne@68: contig: Optional[str] = ..., jpayne@68: start: Optional[int] = ..., jpayne@68: stop: Optional[int] = ..., jpayne@68: region: Optional[str] = ..., jpayne@68: reopen: bool = ..., jpayne@68: end: Optional[int] = ..., jpayne@68: reference: Optional[str] = ..., jpayne@68: ) -> Iterator[VariantRecord]: ... jpayne@68: def new_record(self, *args, **kwargs) -> Any: ... jpayne@68: def write(self, record: VariantRecord) -> int: ... jpayne@68: def subset_samples(self, include_samples: Iterable[str]) -> None: ...