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