| 1 |
import array |
| 2 |
import sys |
| 3 |
from typing import ( |
| 4 |
Any, |
| 5 |
Dict, |
| 6 |
Type, |
| 7 |
NamedTuple, |
| 8 |
Tuple, |
| 9 |
Optional, |
| 10 |
Sequence, |
| 11 |
Union, |
| 12 |
Callable, |
| 13 |
List, |
| 14 |
Iterable, |
| 15 |
) |
| 16 |
|
| 17 |
if sys.version_info < (3, 8): |
| 18 |
from typing_extensions import Literal |
| 19 |
else: |
| 20 |
from typing import Literal |
| 21 |
|
| 22 |
from pysam.libchtslib import HTSFile, _HasFileNo |
| 23 |
from pysam.libcalignedsegment import AlignedSegment, PileupColumn |
| 24 |
from pysam.libcfaidx import FastaFile |
| 25 |
|
| 26 |
class IndexStats(NamedTuple): |
| 27 |
contig: str |
| 28 |
mapped: int |
| 29 |
unmapped: int |
| 30 |
total: int |
| 31 |
|
| 32 |
VALID_HEADER_TYPES: Dict[str, Type] |
| 33 |
VALID_HEADERS: Tuple[str] |
| 34 |
KNOWN_HEADER_FIELDS: Dict[str, Dict[str, Type]] |
| 35 |
VALID_HEADER_ORDER: Dict[str, Tuple[str]] |
| 36 |
|
| 37 |
def build_header_line(fields: Dict[str, str], record: str) -> str: ... |
| 38 |
|
| 39 |
class AlignmentHeader: |
| 40 |
def __init__(self) -> None: ... |
| 41 |
@classmethod |
| 42 |
def _from_text_and_lengths( |
| 43 |
cls, |
| 44 |
text: Optional[str], |
| 45 |
reference_names: Optional[Sequence[str]], |
| 46 |
reference_lengths: Optional[Sequence[int]], |
| 47 |
) -> AlignmentHeader: ... |
| 48 |
@classmethod |
| 49 |
def from_text(cls, text: str) -> AlignmentHeader: ... |
| 50 |
@classmethod |
| 51 |
def from_dict(cls, header_dict: Dict) -> AlignmentHeader: ... |
| 52 |
@classmethod |
| 53 |
def from_references( |
| 54 |
cls, |
| 55 |
reference_names: Sequence[str], |
| 56 |
reference_lengths: Sequence[int], |
| 57 |
text: Optional[str] = ..., |
| 58 |
add_sq_text: bool = ..., |
| 59 |
) -> AlignmentHeader: ... |
| 60 |
def __bool__(self) -> bool: ... |
| 61 |
def copy(self) -> AlignmentHeader: ... |
| 62 |
@property |
| 63 |
def nreferences(self) -> int: ... |
| 64 |
@property |
| 65 |
def references(self) -> Tuple[str]: ... |
| 66 |
@property |
| 67 |
def lengths(self) -> Tuple[int]: ... |
| 68 |
def to_dict(self) -> Dict: ... |
| 69 |
def get_reference_name(self, tid: int) -> Optional[str]: ... |
| 70 |
def get_reference_length(self, reference: str) -> int: ... |
| 71 |
def is_valid_tid(self, tid: int) -> bool: ... |
| 72 |
def get_tid(self, reference: str) -> int: ... |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
AlignmentFileIterator = AlignmentFile |
| 77 |
|
| 78 |
class AlignmentFile(HTSFile): |
| 79 |
def __init__( |
| 80 |
self, |
| 81 |
filename: Union[str, bytes, int, _HasFileNo], |
| 82 |
mode: Optional[ |
| 83 |
Literal["r", "w", "wh", "rb", "wb", "wbu", "wb0", "rc", "wc"] |
| 84 |
] = ..., |
| 85 |
template: Optional[AlignmentFile] = ..., |
| 86 |
reference_names: Optional[Sequence[str]] = ..., |
| 87 |
reference_lengths: Optional[Sequence[int]] = ..., |
| 88 |
reference_filename: Optional[str] = ..., |
| 89 |
text: Optional[str] = ..., |
| 90 |
header: Union[None, Dict, AlignmentHeader] = ..., |
| 91 |
add_sq_text: bool = ..., |
| 92 |
add_sam_header: bool = ..., |
| 93 |
check_sq: bool = ..., |
| 94 |
index_filename: Optional[str] = ..., |
| 95 |
filepath_index: Optional[str] = ..., |
| 96 |
require_index: bool = ..., |
| 97 |
duplicate_filehandle: bool = ..., |
| 98 |
ignore_truncation: bool = ..., |
| 99 |
format_options: Optional[Sequence[str]] = ..., |
| 100 |
threads: int = ..., |
| 101 |
) -> None: ... |
| 102 |
def has_index(self) -> bool: ... |
| 103 |
def check_index(self) -> bool: ... |
| 104 |
def fetch( |
| 105 |
self, |
| 106 |
contig: Optional[str] = ..., |
| 107 |
start: Optional[int] = ..., |
| 108 |
stop: Optional[int] = ..., |
| 109 |
region: Optional[str] = ..., |
| 110 |
tid: Optional[int] = ..., |
| 111 |
until_eof: bool = ..., |
| 112 |
multiple_iterators: bool = ..., |
| 113 |
reference: Optional[str] = ..., |
| 114 |
end: int = ..., |
| 115 |
) -> IteratorRow: ... |
| 116 |
def head(self, n: int, multiple_iterators: bool = ...) -> IteratorRow: ... |
| 117 |
def mate(self, read: AlignedSegment) -> AlignedSegment: ... |
| 118 |
def pileup( |
| 119 |
self, |
| 120 |
contig: Optional[str] = ..., |
| 121 |
start: Optional[int] = ..., |
| 122 |
stop: Optional[int] = ..., |
| 123 |
region: Optional[str] = ..., |
| 124 |
reference: Optional[str] = ..., |
| 125 |
end: Optional[int] = ..., |
| 126 |
truncate: bool = ..., |
| 127 |
max_depth: int = ..., |
| 128 |
stepper: str = ..., |
| 129 |
fastafile: Optional[FastaFile] = ..., |
| 130 |
ignore_overlaps: bool = ..., |
| 131 |
flag_filter: int = ..., |
| 132 |
flag_require: int = ..., |
| 133 |
ignore_orphans: bool = ..., |
| 134 |
min_base_quality: int = ..., |
| 135 |
adjust_capq_threshold: int = ..., |
| 136 |
min_mapping_quality: int = ..., |
| 137 |
compute_baq: bool = ..., |
| 138 |
redo_baq: bool = ..., |
| 139 |
) -> IteratorColumn: ... |
| 140 |
def count( |
| 141 |
self, |
| 142 |
contig: Optional[str] = ..., |
| 143 |
start: Optional[int] = ..., |
| 144 |
stop: Optional[int] = ..., |
| 145 |
region: Optional[str] = ..., |
| 146 |
until_eof: bool = ..., |
| 147 |
read_callback: Union[str, Callable[[AlignedSegment], bool]] = ..., |
| 148 |
reference: Optional[str] = ..., |
| 149 |
end: Optional[int] = ..., |
| 150 |
) -> int: ... |
| 151 |
def count_coverage( |
| 152 |
self, |
| 153 |
contig: Optional[str] = ..., |
| 154 |
start: Optional[int] = ..., |
| 155 |
stop: Optional[int] = ..., |
| 156 |
region: Optional[str] = ..., |
| 157 |
quality_threshold: int = ..., |
| 158 |
read_callback: Union[str, Callable[[AlignedSegment], bool]] = ..., |
| 159 |
reference: Optional[str] = ..., |
| 160 |
end: Optional[int] = ..., |
| 161 |
) -> Tuple[array.array, array.array, array.array, array.array]: ... |
| 162 |
def find_introns_slow( |
| 163 |
self, read_iterator: Iterable[AlignedSegment] |
| 164 |
) -> Dict[Tuple[int, int], int]: ... |
| 165 |
def find_introns( |
| 166 |
self, read_iterator: Iterable[AlignedSegment] |
| 167 |
) -> Dict[Tuple[int, int], int]: ... |
| 168 |
def close(self) -> None: ... |
| 169 |
def write(self, read: AlignedSegment) -> int: ... |
| 170 |
def __enter__(self) -> AlignmentFile: ... |
| 171 |
def __exit__(self, exc_type, exc_value, traceback): ... |
| 172 |
@property |
| 173 |
def mapped(self) -> int: ... |
| 174 |
@property |
| 175 |
def unmapped(self) -> int: ... |
| 176 |
@property |
| 177 |
def nocoordinate(self) -> int: ... |
| 178 |
def get_index_statistics(self) -> List[IndexStats]: ... |
| 179 |
def __iter__(self) -> AlignmentFileIterator: ... |
| 180 |
def __next__(self) -> AlignedSegment: ... |
| 181 |
def is_valid_tid(self, tid: int) -> bool: ... |
| 182 |
def get_tid(self, reference: str) -> int: ... |
| 183 |
def get_reference_name(self, tid: int) -> str: ... |
| 184 |
def get_reference_length(self, reference: str) -> int: ... |
| 185 |
@property |
| 186 |
def nreferences(self) -> int: ... |
| 187 |
@property |
| 188 |
def references(self) -> Tuple[str, ...]: ... |
| 189 |
@property |
| 190 |
def lengths(self) -> Tuple[int, ...]: ... |
| 191 |
@property |
| 192 |
def reference_filename(self) -> Optional[str]: ... |
| 193 |
@property |
| 194 |
def header(self) -> AlignmentHeader: ... |
| 195 |
|
| 196 |
class IteratorRow: |
| 197 |
def __iter__(self) -> IteratorRow: ... |
| 198 |
def __next__(self) -> AlignedSegment: ... |
| 199 |
|
| 200 |
class IteratorRowAll(IteratorRow): ... |
| 201 |
class IteratorRowAllRefs(IteratorRow): ... |
| 202 |
class IteratorRowHead(IteratorRow): ... |
| 203 |
class IteratorRowRegion(IteratorRow): ... |
| 204 |
class IteratorRowSelection(IteratorRow): ... |
| 205 |
|
| 206 |
class IteratorColumn: |
| 207 |
def __iter__(self) -> IteratorColumn: ... |
| 208 |
def __next__(self) -> PileupColumn: ... |
| 209 |
@property |
| 210 |
def seq_len(self) -> int: ... |
| 211 |
def add_reference(self, fastafile: FastaFile) -> None: ... |
| 212 |
def has_reference(self) -> bool: ... |
| 213 |
|
| 214 |
class IteratorColumnAll(IteratorColumn): ... |
| 215 |
class IteratorColumnAllRefs(IteratorColumn): ... |
| 216 |
class IteratorColumnRegion(IteratorColumn): ... |
| 217 |
|
| 218 |
class SNPCall: |
| 219 |
@property |
| 220 |
def tid(self) -> int: ... |
| 221 |
@property |
| 222 |
def pos(self) -> int: ... |
| 223 |
@property |
| 224 |
def reference_base(self) -> str: ... |
| 225 |
@property |
| 226 |
def genotype(self) -> str: ... |
| 227 |
@property |
| 228 |
def consensus_quality(self) -> int: ... |
| 229 |
@property |
| 230 |
def snp_quality(self) -> int: ... |
| 231 |
@property |
| 232 |
def mapping_quality(self) -> int: ... |
| 233 |
@property |
| 234 |
def coverage(self) -> int: ... |
| 235 |
|
| 236 |
class IndexedReads: |
| 237 |
def __init__( |
| 238 |
self, samfile: AlignmentFile, multiple_iterators: bool = ... |
| 239 |
) -> None: ... |
| 240 |
def build(self) -> None: ... |
| 241 |
def find(self, query_name: str) -> IteratorRow: ... |