You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

242 lines
7.7 KiB

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