├── .gitignore
├── .install-htslib.sh
├── .travis.yml
├── LICENSE
├── MANIFEST.in
├── README.md
├── docs
├── .nojekyll
├── Makefile
├── _sources
│ └── index.rst.txt
├── _static
│ ├── ajax-loader.gif
│ ├── alabaster.css
│ ├── basic.css
│ ├── comment-bright.png
│ ├── comment-close.png
│ ├── comment.png
│ ├── custom.css
│ ├── doctools.js
│ ├── down-pressed.png
│ ├── down.png
│ ├── file.png
│ ├── jquery-3.1.0.js
│ ├── jquery.js
│ ├── minus.png
│ ├── plus.png
│ ├── pygments.css
│ ├── searchtools.js
│ ├── underscore-1.3.1.js
│ ├── underscore.js
│ ├── up-pressed.png
│ ├── up.png
│ └── websupport.js
├── conf.py
├── genindex.html
├── index.html
├── index.rst
├── objects.inv
├── search.html
└── searchindex.js
├── hts
├── __init__.py
├── bam.py
├── fai.py
├── fisher.py
├── hts_concat.h
├── hts_extra.c
├── hts_extra.h
├── htsffi.py
├── tbx.py
├── test
│ ├── __init__.py
│ ├── e.sam
│ ├── example.gtf.gz
│ ├── example.gtf.gz.tbi
│ ├── small.bam
│ ├── small.bam.bai
│ ├── t.fa
│ ├── t.fa.fai
│ ├── t.sam
│ ├── t2.fa
│ ├── t2.fa.fai
│ ├── test.query.vcf
│ ├── test_hts.py
│ └── test_tbx.py
└── vcf.py
├── nose.cfg
├── requirements.txt
├── setup.cfg
└── setup.py
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 | *.so
3 |
4 | .installed.cfg
5 | bin
6 | develop-eggs
7 | __pycache__
8 |
9 | *.egg-info
10 |
11 | tmp
12 | build
13 | _build
14 | dist
15 |
16 | .coverage
17 |
18 | docs/html
19 | docs/doctrees
20 |
--------------------------------------------------------------------------------
/.install-htslib.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -ex
3 | DIR=${TRAVIS_BUILD_DIR}
4 | git clone https://github.com/samtools/htslib.git ${DIR}/htslib
5 | cd ${DIR}/htslib
6 | git checkout develop
7 |
8 | sudo make install
9 |
10 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)
11 | export C_INCLUDE_PATH=$(pwd):${DIR}:/usr/local/include/:/usr/include/
12 |
13 | sudo ldconfig
14 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: required
2 | language: python
3 | python:
4 | - "2.7"
5 |
6 | install:
7 | - ./.install-htslib.sh
8 | - pip install cffi nose coverage coveralls codecov sphinx
9 | - python setup.py develop
10 |
11 | script:
12 | - cd docs && make htmls && cd ..
13 | - coverage run --source=hts setup.py nosetests
14 |
15 | after_success:
16 | - codecov
17 | #- coveralls
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 brent pedersen
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | include hts/hts_concat.h
2 | include hts/test/*
3 | include hts/hts_extra.h
4 | include hts/hts_extra.c
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | hts-python has moved **[here](https://github.com/quinlan-lab/hts-python)**
2 |
--------------------------------------------------------------------------------
/docs/.nojekyll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brentp/hts-python/d27f873f7e8e770f6afd5630beb253edc2f7ca05/docs/.nojekyll
--------------------------------------------------------------------------------
/docs/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line.
5 | SPHINXOPTS =
6 | SPHINXBUILD = sphinx-build
7 | SPHINXPROJ = hts-python
8 | SOURCEDIR = .
9 | BUILDDIR = $(SOURCEDIR)
10 |
11 | # Put it first so that "make" without argument is like "make help".
12 | help:
13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 |
15 | .PHONY: help Makefile
16 |
17 | htmls:
18 | make html
19 | cp -r html/* .
20 |
21 | # Catch-all target: route all unknown targets to Sphinx using the new
22 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
23 | %: Makefile
24 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
25 |
26 |
--------------------------------------------------------------------------------
/docs/_sources/index.rst.txt:
--------------------------------------------------------------------------------
1 | .. hts-python documentation master file, created by
2 | sphinx-quickstart on Wed Mar 1 09:40:03 2017.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | hts-python
7 | ==========
8 |
9 | hts-python is a pythonic wrapper for `htslib `_ using python `cffi `_.
10 |
11 | A taste of hts-python...
12 |
13 | .. code-block:: python
14 |
15 | >>> import os.path as op
16 |
17 | >>> from hts import Bam
18 | >>> bam = Bam("hts/test/small.bam")
19 | >>> list(bam.header.seqs)
20 | ['chr2L', 'chr2R', 'chr3L', 'chr3R', 'chr4', 'chrX']
21 |
22 | >>> a = next(bam('chr2L:9000-11000'))
23 | >>> a
24 | Alignment('HWUSI-NAME:2:69:512:1017#0')
25 | >>> a.target, a.pos, a.strand
26 | ('chr2L', 9329, '-')
27 | >>> a.qlen, a.rlen
28 | (36, 36)
29 | >>> a.strand
30 | '-'
31 | >>> a.seq
32 | 'TACAAATCTTACGTAAACACTCCAAGCATGAATTCG'
33 | >>> a.qual[:10]
34 | [56, 63, 53, 62, 64, 62, 51, 44, 58, 59]
35 |
36 | >>> a.flag, a.flag_str
37 | (16, 'REVERSE')
38 |
39 | >>> a.cigar
40 | Cigar('36M')
41 |
42 | >>> str(a)[:40]
43 | 'HWUSI-NAME:2:69:512:1017#0\t16\tchr2L\t9330'
44 |
45 | See Also
46 | ========
47 |
48 | .. toctree::
49 | :maxdepth: 2
50 |
51 |
--------------------------------------------------------------------------------
/docs/_static/ajax-loader.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brentp/hts-python/d27f873f7e8e770f6afd5630beb253edc2f7ca05/docs/_static/ajax-loader.gif
--------------------------------------------------------------------------------
/docs/_static/alabaster.css:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | @import url("basic.css");
54 |
55 | /* -- page layout ----------------------------------------------------------- */
56 |
57 | body {
58 | font-family: 'goudy old style', 'minion pro', 'bell mt', Georgia, 'Hiragino Mincho Pro', serif;
59 | font-size: 17px;
60 | background-color: #fff;
61 | color: #000;
62 | margin: 0;
63 | padding: 0;
64 | }
65 |
66 |
67 | div.document {
68 | width: 940px;
69 | margin: 30px auto 0 auto;
70 | }
71 |
72 | div.documentwrapper {
73 | float: left;
74 | width: 100%;
75 | }
76 |
77 | div.bodywrapper {
78 | margin: 0 0 0 220px;
79 | }
80 |
81 | div.sphinxsidebar {
82 | width: 220px;
83 | font-size: 14px;
84 | line-height: 1.5;
85 | }
86 |
87 | hr {
88 | border: 1px solid #B1B4B6;
89 | }
90 |
91 | div.body {
92 | background-color: #fff;
93 | color: #3E4349;
94 | padding: 0 30px 0 30px;
95 | }
96 |
97 | div.body > .section {
98 | text-align: left;
99 | }
100 |
101 | div.footer {
102 | width: 940px;
103 | margin: 20px auto 30px auto;
104 | font-size: 14px;
105 | color: #888;
106 | text-align: right;
107 | }
108 |
109 | div.footer a {
110 | color: #888;
111 | }
112 |
113 | p.caption {
114 | font-family: inherit;
115 | font-size: inherit;
116 | }
117 |
118 |
119 | div.relations {
120 | display: none;
121 | }
122 |
123 |
124 | div.sphinxsidebar a {
125 | color: #444;
126 | text-decoration: none;
127 | border-bottom: 1px dotted #999;
128 | }
129 |
130 | div.sphinxsidebar a:hover {
131 | border-bottom: 1px solid #999;
132 | }
133 |
134 | div.sphinxsidebarwrapper {
135 | padding: 18px 10px;
136 | }
137 |
138 | div.sphinxsidebarwrapper p.logo {
139 | padding: 0;
140 | margin: -10px 0 0 0px;
141 | text-align: center;
142 | }
143 |
144 | div.sphinxsidebarwrapper h1.logo {
145 | margin-top: -10px;
146 | text-align: center;
147 | margin-bottom: 5px;
148 | text-align: left;
149 | }
150 |
151 | div.sphinxsidebarwrapper h1.logo-name {
152 | margin-top: 0px;
153 | }
154 |
155 | div.sphinxsidebarwrapper p.blurb {
156 | margin-top: 0;
157 | font-style: normal;
158 | }
159 |
160 | div.sphinxsidebar h3,
161 | div.sphinxsidebar h4 {
162 | font-family: 'Garamond', 'Georgia', serif;
163 | color: #444;
164 | font-size: 24px;
165 | font-weight: normal;
166 | margin: 0 0 5px 0;
167 | padding: 0;
168 | }
169 |
170 | div.sphinxsidebar h4 {
171 | font-size: 20px;
172 | }
173 |
174 | div.sphinxsidebar h3 a {
175 | color: #444;
176 | }
177 |
178 | div.sphinxsidebar p.logo a,
179 | div.sphinxsidebar h3 a,
180 | div.sphinxsidebar p.logo a:hover,
181 | div.sphinxsidebar h3 a:hover {
182 | border: none;
183 | }
184 |
185 | div.sphinxsidebar p {
186 | color: #555;
187 | margin: 10px 0;
188 | }
189 |
190 | div.sphinxsidebar ul {
191 | margin: 10px 0;
192 | padding: 0;
193 | color: #000;
194 | }
195 |
196 | div.sphinxsidebar ul li.toctree-l1 > a {
197 | font-size: 120%;
198 | }
199 |
200 | div.sphinxsidebar ul li.toctree-l2 > a {
201 | font-size: 110%;
202 | }
203 |
204 | div.sphinxsidebar input {
205 | border: 1px solid #CCC;
206 | font-family: 'goudy old style', 'minion pro', 'bell mt', Georgia, 'Hiragino Mincho Pro', serif;
207 | font-size: 1em;
208 | }
209 |
210 | div.sphinxsidebar hr {
211 | border: none;
212 | height: 1px;
213 | color: #AAA;
214 | background: #AAA;
215 |
216 | text-align: left;
217 | margin-left: 0;
218 | width: 50%;
219 | }
220 |
221 | /* -- body styles ----------------------------------------------------------- */
222 |
223 | a {
224 | color: #004B6B;
225 | text-decoration: underline;
226 | }
227 |
228 | a:hover {
229 | color: #6D4100;
230 | text-decoration: underline;
231 | }
232 |
233 | div.body h1,
234 | div.body h2,
235 | div.body h3,
236 | div.body h4,
237 | div.body h5,
238 | div.body h6 {
239 | font-family: 'Garamond', 'Georgia', serif;
240 | font-weight: normal;
241 | margin: 30px 0px 10px 0px;
242 | padding: 0;
243 | }
244 |
245 | div.body h1 { margin-top: 0; padding-top: 0; font-size: 240%; }
246 | div.body h2 { font-size: 180%; }
247 | div.body h3 { font-size: 150%; }
248 | div.body h4 { font-size: 130%; }
249 | div.body h5 { font-size: 100%; }
250 | div.body h6 { font-size: 100%; }
251 |
252 | a.headerlink {
253 | color: #DDD;
254 | padding: 0 4px;
255 | text-decoration: none;
256 | }
257 |
258 | a.headerlink:hover {
259 | color: #444;
260 | background: #EAEAEA;
261 | }
262 |
263 | div.body p, div.body dd, div.body li {
264 | line-height: 1.4em;
265 | }
266 |
267 | div.admonition {
268 | margin: 20px 0px;
269 | padding: 10px 30px;
270 | background-color: #EEE;
271 | border: 1px solid #CCC;
272 | }
273 |
274 | div.admonition tt.xref, div.admonition code.xref, div.admonition a tt {
275 | background-color: #FBFBFB;
276 | border-bottom: 1px solid #fafafa;
277 | }
278 |
279 | div.admonition p.admonition-title {
280 | font-family: 'Garamond', 'Georgia', serif;
281 | font-weight: normal;
282 | font-size: 24px;
283 | margin: 0 0 10px 0;
284 | padding: 0;
285 | line-height: 1;
286 | }
287 |
288 | div.admonition p.last {
289 | margin-bottom: 0;
290 | }
291 |
292 | div.highlight {
293 | background-color: #fff;
294 | }
295 |
296 | dt:target, .highlight {
297 | background: #FAF3E8;
298 | }
299 |
300 | div.warning {
301 | background-color: #FCC;
302 | border: 1px solid #FAA;
303 | }
304 |
305 | div.danger {
306 | background-color: #FCC;
307 | border: 1px solid #FAA;
308 | -moz-box-shadow: 2px 2px 4px #D52C2C;
309 | -webkit-box-shadow: 2px 2px 4px #D52C2C;
310 | box-shadow: 2px 2px 4px #D52C2C;
311 | }
312 |
313 | div.error {
314 | background-color: #FCC;
315 | border: 1px solid #FAA;
316 | -moz-box-shadow: 2px 2px 4px #D52C2C;
317 | -webkit-box-shadow: 2px 2px 4px #D52C2C;
318 | box-shadow: 2px 2px 4px #D52C2C;
319 | }
320 |
321 | div.caution {
322 | background-color: #FCC;
323 | border: 1px solid #FAA;
324 | }
325 |
326 | div.attention {
327 | background-color: #FCC;
328 | border: 1px solid #FAA;
329 | }
330 |
331 | div.important {
332 | background-color: #EEE;
333 | border: 1px solid #CCC;
334 | }
335 |
336 | div.note {
337 | background-color: #EEE;
338 | border: 1px solid #CCC;
339 | }
340 |
341 | div.tip {
342 | background-color: #EEE;
343 | border: 1px solid #CCC;
344 | }
345 |
346 | div.hint {
347 | background-color: #EEE;
348 | border: 1px solid #CCC;
349 | }
350 |
351 | div.seealso {
352 | background-color: #EEE;
353 | border: 1px solid #CCC;
354 | }
355 |
356 | div.topic {
357 | background-color: #EEE;
358 | }
359 |
360 | p.admonition-title {
361 | display: inline;
362 | }
363 |
364 | p.admonition-title:after {
365 | content: ":";
366 | }
367 |
368 | pre, tt, code {
369 | font-family: 'Consolas', 'Menlo', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
370 | font-size: 0.9em;
371 | }
372 |
373 | .hll {
374 | background-color: #FFC;
375 | margin: 0 -12px;
376 | padding: 0 12px;
377 | display: block;
378 | }
379 |
380 | img.screenshot {
381 | }
382 |
383 | tt.descname, tt.descclassname, code.descname, code.descclassname {
384 | font-size: 0.95em;
385 | }
386 |
387 | tt.descname, code.descname {
388 | padding-right: 0.08em;
389 | }
390 |
391 | img.screenshot {
392 | -moz-box-shadow: 2px 2px 4px #EEE;
393 | -webkit-box-shadow: 2px 2px 4px #EEE;
394 | box-shadow: 2px 2px 4px #EEE;
395 | }
396 |
397 | table.docutils {
398 | border: 1px solid #888;
399 | -moz-box-shadow: 2px 2px 4px #EEE;
400 | -webkit-box-shadow: 2px 2px 4px #EEE;
401 | box-shadow: 2px 2px 4px #EEE;
402 | }
403 |
404 | table.docutils td, table.docutils th {
405 | border: 1px solid #888;
406 | padding: 0.25em 0.7em;
407 | }
408 |
409 | table.field-list, table.footnote {
410 | border: none;
411 | -moz-box-shadow: none;
412 | -webkit-box-shadow: none;
413 | box-shadow: none;
414 | }
415 |
416 | table.footnote {
417 | margin: 15px 0;
418 | width: 100%;
419 | border: 1px solid #EEE;
420 | background: #FDFDFD;
421 | font-size: 0.9em;
422 | }
423 |
424 | table.footnote + table.footnote {
425 | margin-top: -15px;
426 | border-top: none;
427 | }
428 |
429 | table.field-list th {
430 | padding: 0 0.8em 0 0;
431 | }
432 |
433 | table.field-list td {
434 | padding: 0;
435 | }
436 |
437 | table.field-list p {
438 | margin-bottom: 0.8em;
439 | }
440 |
441 | /* Cloned from
442 | * https://github.com/sphinx-doc/sphinx/commit/ef60dbfce09286b20b7385333d63a60321784e68
443 | */
444 | .field-name {
445 | -moz-hyphens: manual;
446 | -ms-hyphens: manual;
447 | -webkit-hyphens: manual;
448 | hyphens: manual;
449 | }
450 |
451 | table.footnote td.label {
452 | width: .1px;
453 | padding: 0.3em 0 0.3em 0.5em;
454 | }
455 |
456 | table.footnote td {
457 | padding: 0.3em 0.5em;
458 | }
459 |
460 | dl {
461 | margin: 0;
462 | padding: 0;
463 | }
464 |
465 | dl dd {
466 | margin-left: 30px;
467 | }
468 |
469 | blockquote {
470 | margin: 0 0 0 30px;
471 | padding: 0;
472 | }
473 |
474 | ul, ol {
475 | /* Matches the 30px from the narrow-screen "li > ul" selector below */
476 | margin: 10px 0 10px 30px;
477 | padding: 0;
478 | }
479 |
480 | pre {
481 | background: #EEE;
482 | padding: 7px 30px;
483 | margin: 15px 0px;
484 | line-height: 1.3em;
485 | }
486 |
487 | div.viewcode-block:target {
488 | background: #ffd;
489 | }
490 |
491 | dl pre, blockquote pre, li pre {
492 | margin-left: 0;
493 | padding-left: 30px;
494 | }
495 |
496 | tt, code {
497 | background-color: #ecf0f3;
498 | color: #222;
499 | /* padding: 1px 2px; */
500 | }
501 |
502 | tt.xref, code.xref, a tt {
503 | background-color: #FBFBFB;
504 | border-bottom: 1px solid #fff;
505 | }
506 |
507 | a.reference {
508 | text-decoration: none;
509 | border-bottom: 1px dotted #004B6B;
510 | }
511 |
512 | /* Don't put an underline on images */
513 | a.image-reference, a.image-reference:hover {
514 | border-bottom: none;
515 | }
516 |
517 | a.reference:hover {
518 | border-bottom: 1px solid #6D4100;
519 | }
520 |
521 | a.footnote-reference {
522 | text-decoration: none;
523 | font-size: 0.7em;
524 | vertical-align: top;
525 | border-bottom: 1px dotted #004B6B;
526 | }
527 |
528 | a.footnote-reference:hover {
529 | border-bottom: 1px solid #6D4100;
530 | }
531 |
532 | a:hover tt, a:hover code {
533 | background: #EEE;
534 | }
535 |
536 |
537 | @media screen and (max-width: 870px) {
538 |
539 | div.sphinxsidebar {
540 | display: none;
541 | }
542 |
543 | div.document {
544 | width: 100%;
545 |
546 | }
547 |
548 | div.documentwrapper {
549 | margin-left: 0;
550 | margin-top: 0;
551 | margin-right: 0;
552 | margin-bottom: 0;
553 | }
554 |
555 | div.bodywrapper {
556 | margin-top: 0;
557 | margin-right: 0;
558 | margin-bottom: 0;
559 | margin-left: 0;
560 | }
561 |
562 | ul {
563 | margin-left: 0;
564 | }
565 |
566 | li > ul {
567 | /* Matches the 30px from the "ul, ol" selector above */
568 | margin-left: 30px;
569 | }
570 |
571 | .document {
572 | width: auto;
573 | }
574 |
575 | .footer {
576 | width: auto;
577 | }
578 |
579 | .bodywrapper {
580 | margin: 0;
581 | }
582 |
583 | .footer {
584 | width: auto;
585 | }
586 |
587 | .github {
588 | display: none;
589 | }
590 |
591 |
592 |
593 | }
594 |
595 |
596 |
597 | @media screen and (max-width: 875px) {
598 |
599 | body {
600 | margin: 0;
601 | padding: 20px 30px;
602 | }
603 |
604 | div.documentwrapper {
605 | float: none;
606 | background: #fff;
607 | }
608 |
609 | div.sphinxsidebar {
610 | display: block;
611 | float: none;
612 | width: 102.5%;
613 | margin: 50px -30px -20px -30px;
614 | padding: 10px 20px;
615 | background: #333;
616 | color: #FFF;
617 | }
618 |
619 | div.sphinxsidebar h3, div.sphinxsidebar h4, div.sphinxsidebar p,
620 | div.sphinxsidebar h3 a {
621 | color: #fff;
622 | }
623 |
624 | div.sphinxsidebar a {
625 | color: #AAA;
626 | }
627 |
628 | div.sphinxsidebar p.logo {
629 | display: none;
630 | }
631 |
632 | div.document {
633 | width: 100%;
634 | margin: 0;
635 | }
636 |
637 | div.footer {
638 | display: none;
639 | }
640 |
641 | div.bodywrapper {
642 | margin: 0;
643 | }
644 |
645 | div.body {
646 | min-height: 0;
647 | padding: 0;
648 | }
649 |
650 | .rtd_doc_footer {
651 | display: none;
652 | }
653 |
654 | .document {
655 | width: auto;
656 | }
657 |
658 | .footer {
659 | width: auto;
660 | }
661 |
662 | .footer {
663 | width: auto;
664 | }
665 |
666 | .github {
667 | display: none;
668 | }
669 | }
670 |
671 |
672 | /* misc. */
673 |
674 | .revsys-inline {
675 | display: none!important;
676 | }
677 |
678 | /* Make nested-list/multi-paragraph items look better in Releases changelog
679 | * pages. Without this, docutils' magical list fuckery causes inconsistent
680 | * formatting between different release sub-lists.
681 | */
682 | div#changelog > div.section > ul > li > p:only-child {
683 | margin-bottom: 0;
684 | }
685 |
686 | /* Hide fugly table cell borders in ..bibliography:: directive output */
687 | table.docutils.citation, table.docutils.citation td, table.docutils.citation th {
688 | border: none;
689 | /* Below needed in some edge cases; if not applied, bottom shadows appear */
690 | -moz-box-shadow: none;
691 | -webkit-box-shadow: none;
692 | box-shadow: none;
693 | }
--------------------------------------------------------------------------------
/docs/_static/basic.css:
--------------------------------------------------------------------------------
1 | /*
2 | * basic.css
3 | * ~~~~~~~~~
4 | *
5 | * Sphinx stylesheet -- basic theme.
6 | *
7 | * :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
8 | * :license: BSD, see LICENSE for details.
9 | *
10 | */
11 |
12 | /* -- main layout ----------------------------------------------------------- */
13 |
14 | div.clearer {
15 | clear: both;
16 | }
17 |
18 | /* -- relbar ---------------------------------------------------------------- */
19 |
20 | div.related {
21 | width: 100%;
22 | font-size: 90%;
23 | }
24 |
25 | div.related h3 {
26 | display: none;
27 | }
28 |
29 | div.related ul {
30 | margin: 0;
31 | padding: 0 0 0 10px;
32 | list-style: none;
33 | }
34 |
35 | div.related li {
36 | display: inline;
37 | }
38 |
39 | div.related li.right {
40 | float: right;
41 | margin-right: 5px;
42 | }
43 |
44 | /* -- sidebar --------------------------------------------------------------- */
45 |
46 | div.sphinxsidebarwrapper {
47 | padding: 10px 5px 0 10px;
48 | }
49 |
50 | div.sphinxsidebar {
51 | float: left;
52 | width: 230px;
53 | margin-left: -100%;
54 | font-size: 90%;
55 | word-wrap: break-word;
56 | overflow-wrap : break-word;
57 | }
58 |
59 | div.sphinxsidebar ul {
60 | list-style: none;
61 | }
62 |
63 | div.sphinxsidebar ul ul,
64 | div.sphinxsidebar ul.want-points {
65 | margin-left: 20px;
66 | list-style: square;
67 | }
68 |
69 | div.sphinxsidebar ul ul {
70 | margin-top: 0;
71 | margin-bottom: 0;
72 | }
73 |
74 | div.sphinxsidebar form {
75 | margin-top: 10px;
76 | }
77 |
78 | div.sphinxsidebar input {
79 | border: 1px solid #98dbcc;
80 | font-family: sans-serif;
81 | font-size: 1em;
82 | }
83 |
84 | div.sphinxsidebar #searchbox input[type="text"] {
85 | width: 170px;
86 | }
87 |
88 | img {
89 | border: 0;
90 | max-width: 100%;
91 | }
92 |
93 | /* -- search page ----------------------------------------------------------- */
94 |
95 | ul.search {
96 | margin: 10px 0 0 20px;
97 | padding: 0;
98 | }
99 |
100 | ul.search li {
101 | padding: 5px 0 5px 20px;
102 | background-image: url(file.png);
103 | background-repeat: no-repeat;
104 | background-position: 0 7px;
105 | }
106 |
107 | ul.search li a {
108 | font-weight: bold;
109 | }
110 |
111 | ul.search li div.context {
112 | color: #888;
113 | margin: 2px 0 0 30px;
114 | text-align: left;
115 | }
116 |
117 | ul.keywordmatches li.goodmatch a {
118 | font-weight: bold;
119 | }
120 |
121 | /* -- index page ------------------------------------------------------------ */
122 |
123 | table.contentstable {
124 | width: 90%;
125 | margin-left: auto;
126 | margin-right: auto;
127 | }
128 |
129 | table.contentstable p.biglink {
130 | line-height: 150%;
131 | }
132 |
133 | a.biglink {
134 | font-size: 1.3em;
135 | }
136 |
137 | span.linkdescr {
138 | font-style: italic;
139 | padding-top: 5px;
140 | font-size: 90%;
141 | }
142 |
143 | /* -- general index --------------------------------------------------------- */
144 |
145 | table.indextable {
146 | width: 100%;
147 | }
148 |
149 | table.indextable td {
150 | text-align: left;
151 | vertical-align: top;
152 | }
153 |
154 | table.indextable ul {
155 | margin-top: 0;
156 | margin-bottom: 0;
157 | list-style-type: none;
158 | }
159 |
160 | table.indextable > tbody > tr > td > ul {
161 | padding-left: 0em;
162 | }
163 |
164 | table.indextable tr.pcap {
165 | height: 10px;
166 | }
167 |
168 | table.indextable tr.cap {
169 | margin-top: 10px;
170 | background-color: #f2f2f2;
171 | }
172 |
173 | img.toggler {
174 | margin-right: 3px;
175 | margin-top: 3px;
176 | cursor: pointer;
177 | }
178 |
179 | div.modindex-jumpbox {
180 | border-top: 1px solid #ddd;
181 | border-bottom: 1px solid #ddd;
182 | margin: 1em 0 1em 0;
183 | padding: 0.4em;
184 | }
185 |
186 | div.genindex-jumpbox {
187 | border-top: 1px solid #ddd;
188 | border-bottom: 1px solid #ddd;
189 | margin: 1em 0 1em 0;
190 | padding: 0.4em;
191 | }
192 |
193 | /* -- domain module index --------------------------------------------------- */
194 |
195 | table.modindextable td {
196 | padding: 2px;
197 | border-collapse: collapse;
198 | }
199 |
200 | /* -- general body styles --------------------------------------------------- */
201 |
202 | div.body p, div.body dd, div.body li, div.body blockquote {
203 | -moz-hyphens: auto;
204 | -ms-hyphens: auto;
205 | -webkit-hyphens: auto;
206 | hyphens: auto;
207 | }
208 |
209 | a.headerlink {
210 | visibility: hidden;
211 | }
212 |
213 | h1:hover > a.headerlink,
214 | h2:hover > a.headerlink,
215 | h3:hover > a.headerlink,
216 | h4:hover > a.headerlink,
217 | h5:hover > a.headerlink,
218 | h6:hover > a.headerlink,
219 | dt:hover > a.headerlink,
220 | caption:hover > a.headerlink,
221 | p.caption:hover > a.headerlink,
222 | div.code-block-caption:hover > a.headerlink {
223 | visibility: visible;
224 | }
225 |
226 | div.body p.caption {
227 | text-align: inherit;
228 | }
229 |
230 | div.body td {
231 | text-align: left;
232 | }
233 |
234 | .first {
235 | margin-top: 0 !important;
236 | }
237 |
238 | p.rubric {
239 | margin-top: 30px;
240 | font-weight: bold;
241 | }
242 |
243 | img.align-left, .figure.align-left, object.align-left {
244 | clear: left;
245 | float: left;
246 | margin-right: 1em;
247 | }
248 |
249 | img.align-right, .figure.align-right, object.align-right {
250 | clear: right;
251 | float: right;
252 | margin-left: 1em;
253 | }
254 |
255 | img.align-center, .figure.align-center, object.align-center {
256 | display: block;
257 | margin-left: auto;
258 | margin-right: auto;
259 | }
260 |
261 | .align-left {
262 | text-align: left;
263 | }
264 |
265 | .align-center {
266 | text-align: center;
267 | }
268 |
269 | .align-right {
270 | text-align: right;
271 | }
272 |
273 | /* -- sidebars -------------------------------------------------------------- */
274 |
275 | div.sidebar {
276 | margin: 0 0 0.5em 1em;
277 | border: 1px solid #ddb;
278 | padding: 7px 7px 0 7px;
279 | background-color: #ffe;
280 | width: 40%;
281 | float: right;
282 | }
283 |
284 | p.sidebar-title {
285 | font-weight: bold;
286 | }
287 |
288 | /* -- topics ---------------------------------------------------------------- */
289 |
290 | div.topic {
291 | border: 1px solid #ccc;
292 | padding: 7px 7px 0 7px;
293 | margin: 10px 0 10px 0;
294 | }
295 |
296 | p.topic-title {
297 | font-size: 1.1em;
298 | font-weight: bold;
299 | margin-top: 10px;
300 | }
301 |
302 | /* -- admonitions ----------------------------------------------------------- */
303 |
304 | div.admonition {
305 | margin-top: 10px;
306 | margin-bottom: 10px;
307 | padding: 7px;
308 | }
309 |
310 | div.admonition dt {
311 | font-weight: bold;
312 | }
313 |
314 | div.admonition dl {
315 | margin-bottom: 0;
316 | }
317 |
318 | p.admonition-title {
319 | margin: 0px 10px 5px 0px;
320 | font-weight: bold;
321 | }
322 |
323 | div.body p.centered {
324 | text-align: center;
325 | margin-top: 25px;
326 | }
327 |
328 | /* -- tables ---------------------------------------------------------------- */
329 |
330 | table.docutils {
331 | border: 0;
332 | border-collapse: collapse;
333 | }
334 |
335 | table caption span.caption-number {
336 | font-style: italic;
337 | }
338 |
339 | table caption span.caption-text {
340 | }
341 |
342 | table.docutils td, table.docutils th {
343 | padding: 1px 8px 1px 5px;
344 | border-top: 0;
345 | border-left: 0;
346 | border-right: 0;
347 | border-bottom: 1px solid #aaa;
348 | }
349 |
350 | table.footnote td, table.footnote th {
351 | border: 0 !important;
352 | }
353 |
354 | th {
355 | text-align: left;
356 | padding-right: 5px;
357 | }
358 |
359 | table.citation {
360 | border-left: solid 1px gray;
361 | margin-left: 1px;
362 | }
363 |
364 | table.citation td {
365 | border-bottom: none;
366 | }
367 |
368 | /* -- figures --------------------------------------------------------------- */
369 |
370 | div.figure {
371 | margin: 0.5em;
372 | padding: 0.5em;
373 | }
374 |
375 | div.figure p.caption {
376 | padding: 0.3em;
377 | }
378 |
379 | div.figure p.caption span.caption-number {
380 | font-style: italic;
381 | }
382 |
383 | div.figure p.caption span.caption-text {
384 | }
385 |
386 | /* -- field list styles ----------------------------------------------------- */
387 |
388 | table.field-list td, table.field-list th {
389 | border: 0 !important;
390 | }
391 |
392 | .field-list ul {
393 | margin: 0;
394 | padding-left: 1em;
395 | }
396 |
397 | .field-list p {
398 | margin: 0;
399 | }
400 |
401 | /* -- other body styles ----------------------------------------------------- */
402 |
403 | ol.arabic {
404 | list-style: decimal;
405 | }
406 |
407 | ol.loweralpha {
408 | list-style: lower-alpha;
409 | }
410 |
411 | ol.upperalpha {
412 | list-style: upper-alpha;
413 | }
414 |
415 | ol.lowerroman {
416 | list-style: lower-roman;
417 | }
418 |
419 | ol.upperroman {
420 | list-style: upper-roman;
421 | }
422 |
423 | dl {
424 | margin-bottom: 15px;
425 | }
426 |
427 | dd p {
428 | margin-top: 0px;
429 | }
430 |
431 | dd ul, dd table {
432 | margin-bottom: 10px;
433 | }
434 |
435 | dd {
436 | margin-top: 3px;
437 | margin-bottom: 10px;
438 | margin-left: 30px;
439 | }
440 |
441 | dt:target, .highlighted {
442 | background-color: #fbe54e;
443 | }
444 |
445 | dl.glossary dt {
446 | font-weight: bold;
447 | font-size: 1.1em;
448 | }
449 |
450 | .optional {
451 | font-size: 1.3em;
452 | }
453 |
454 | .sig-paren {
455 | font-size: larger;
456 | }
457 |
458 | .versionmodified {
459 | font-style: italic;
460 | }
461 |
462 | .system-message {
463 | background-color: #fda;
464 | padding: 5px;
465 | border: 3px solid red;
466 | }
467 |
468 | .footnote:target {
469 | background-color: #ffa;
470 | }
471 |
472 | .line-block {
473 | display: block;
474 | margin-top: 1em;
475 | margin-bottom: 1em;
476 | }
477 |
478 | .line-block .line-block {
479 | margin-top: 0;
480 | margin-bottom: 0;
481 | margin-left: 1.5em;
482 | }
483 |
484 | .guilabel, .menuselection {
485 | font-family: sans-serif;
486 | }
487 |
488 | .accelerator {
489 | text-decoration: underline;
490 | }
491 |
492 | .classifier {
493 | font-style: oblique;
494 | }
495 |
496 | abbr, acronym {
497 | border-bottom: dotted 1px;
498 | cursor: help;
499 | }
500 |
501 | /* -- code displays --------------------------------------------------------- */
502 |
503 | pre {
504 | overflow: auto;
505 | overflow-y: hidden; /* fixes display issues on Chrome browsers */
506 | }
507 |
508 | span.pre {
509 | -moz-hyphens: none;
510 | -ms-hyphens: none;
511 | -webkit-hyphens: none;
512 | hyphens: none;
513 | }
514 |
515 | td.linenos pre {
516 | padding: 5px 0px;
517 | border: 0;
518 | background-color: transparent;
519 | color: #aaa;
520 | }
521 |
522 | table.highlighttable {
523 | margin-left: 0.5em;
524 | }
525 |
526 | table.highlighttable td {
527 | padding: 0 0.5em 0 0.5em;
528 | }
529 |
530 | div.code-block-caption {
531 | padding: 2px 5px;
532 | font-size: small;
533 | }
534 |
535 | div.code-block-caption code {
536 | background-color: transparent;
537 | }
538 |
539 | div.code-block-caption + div > div.highlight > pre {
540 | margin-top: 0;
541 | }
542 |
543 | div.code-block-caption span.caption-number {
544 | padding: 0.1em 0.3em;
545 | font-style: italic;
546 | }
547 |
548 | div.code-block-caption span.caption-text {
549 | }
550 |
551 | div.literal-block-wrapper {
552 | padding: 1em 1em 0;
553 | }
554 |
555 | div.literal-block-wrapper div.highlight {
556 | margin: 0;
557 | }
558 |
559 | code.descname {
560 | background-color: transparent;
561 | font-weight: bold;
562 | font-size: 1.2em;
563 | }
564 |
565 | code.descclassname {
566 | background-color: transparent;
567 | }
568 |
569 | code.xref, a code {
570 | background-color: transparent;
571 | font-weight: bold;
572 | }
573 |
574 | h1 code, h2 code, h3 code, h4 code, h5 code, h6 code {
575 | background-color: transparent;
576 | }
577 |
578 | .viewcode-link {
579 | float: right;
580 | }
581 |
582 | .viewcode-back {
583 | float: right;
584 | font-family: sans-serif;
585 | }
586 |
587 | div.viewcode-block:target {
588 | margin: -1px -10px;
589 | padding: 0 10px;
590 | }
591 |
592 | /* -- math display ---------------------------------------------------------- */
593 |
594 | img.math {
595 | vertical-align: middle;
596 | }
597 |
598 | div.body div.math p {
599 | text-align: center;
600 | }
601 |
602 | span.eqno {
603 | float: right;
604 | }
605 |
606 | span.eqno a.headerlink {
607 | position: relative;
608 | left: 0px;
609 | z-index: 1;
610 | }
611 |
612 | div.math:hover a.headerlink {
613 | visibility: visible;
614 | }
615 |
616 | /* -- printout stylesheet --------------------------------------------------- */
617 |
618 | @media print {
619 | div.document,
620 | div.documentwrapper,
621 | div.bodywrapper {
622 | margin: 0 !important;
623 | width: 100%;
624 | }
625 |
626 | div.sphinxsidebar,
627 | div.related,
628 | div.footer,
629 | #top-link {
630 | display: none;
631 | }
632 | }
--------------------------------------------------------------------------------
/docs/_static/comment-bright.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brentp/hts-python/d27f873f7e8e770f6afd5630beb253edc2f7ca05/docs/_static/comment-bright.png
--------------------------------------------------------------------------------
/docs/_static/comment-close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brentp/hts-python/d27f873f7e8e770f6afd5630beb253edc2f7ca05/docs/_static/comment-close.png
--------------------------------------------------------------------------------
/docs/_static/comment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brentp/hts-python/d27f873f7e8e770f6afd5630beb253edc2f7ca05/docs/_static/comment.png
--------------------------------------------------------------------------------
/docs/_static/custom.css:
--------------------------------------------------------------------------------
1 | /* This file intentionally left blank. */
2 |
--------------------------------------------------------------------------------
/docs/_static/doctools.js:
--------------------------------------------------------------------------------
1 | /*
2 | * doctools.js
3 | * ~~~~~~~~~~~
4 | *
5 | * Sphinx JavaScript utilities for all documentation.
6 | *
7 | * :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
8 | * :license: BSD, see LICENSE for details.
9 | *
10 | */
11 |
12 | /**
13 | * select a different prefix for underscore
14 | */
15 | $u = _.noConflict();
16 |
17 | /**
18 | * make the code below compatible with browsers without
19 | * an installed firebug like debugger
20 | if (!window.console || !console.firebug) {
21 | var names = ["log", "debug", "info", "warn", "error", "assert", "dir",
22 | "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace",
23 | "profile", "profileEnd"];
24 | window.console = {};
25 | for (var i = 0; i < names.length; ++i)
26 | window.console[names[i]] = function() {};
27 | }
28 | */
29 |
30 | /**
31 | * small helper function to urldecode strings
32 | */
33 | jQuery.urldecode = function(x) {
34 | return decodeURIComponent(x).replace(/\+/g, ' ');
35 | };
36 |
37 | /**
38 | * small helper function to urlencode strings
39 | */
40 | jQuery.urlencode = encodeURIComponent;
41 |
42 | /**
43 | * This function returns the parsed url parameters of the
44 | * current request. Multiple values per key are supported,
45 | * it will always return arrays of strings for the value parts.
46 | */
47 | jQuery.getQueryParameters = function(s) {
48 | if (typeof s == 'undefined')
49 | s = document.location.search;
50 | var parts = s.substr(s.indexOf('?') + 1).split('&');
51 | var result = {};
52 | for (var i = 0; i < parts.length; i++) {
53 | var tmp = parts[i].split('=', 2);
54 | var key = jQuery.urldecode(tmp[0]);
55 | var value = jQuery.urldecode(tmp[1]);
56 | if (key in result)
57 | result[key].push(value);
58 | else
59 | result[key] = [value];
60 | }
61 | return result;
62 | };
63 |
64 | /**
65 | * highlight a given string on a jquery object by wrapping it in
66 | * span elements with the given class name.
67 | */
68 | jQuery.fn.highlightText = function(text, className) {
69 | function highlight(node) {
70 | if (node.nodeType == 3) {
71 | var val = node.nodeValue;
72 | var pos = val.toLowerCase().indexOf(text);
73 | if (pos >= 0 && !jQuery(node.parentNode).hasClass(className)) {
74 | var span = document.createElement("span");
75 | span.className = className;
76 | span.appendChild(document.createTextNode(val.substr(pos, text.length)));
77 | node.parentNode.insertBefore(span, node.parentNode.insertBefore(
78 | document.createTextNode(val.substr(pos + text.length)),
79 | node.nextSibling));
80 | node.nodeValue = val.substr(0, pos);
81 | }
82 | }
83 | else if (!jQuery(node).is("button, select, textarea")) {
84 | jQuery.each(node.childNodes, function() {
85 | highlight(this);
86 | });
87 | }
88 | }
89 | return this.each(function() {
90 | highlight(this);
91 | });
92 | };
93 |
94 | /*
95 | * backward compatibility for jQuery.browser
96 | * This will be supported until firefox bug is fixed.
97 | */
98 | if (!jQuery.browser) {
99 | jQuery.uaMatch = function(ua) {
100 | ua = ua.toLowerCase();
101 |
102 | var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
103 | /(webkit)[ \/]([\w.]+)/.exec(ua) ||
104 | /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
105 | /(msie) ([\w.]+)/.exec(ua) ||
106 | ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
107 | [];
108 |
109 | return {
110 | browser: match[ 1 ] || "",
111 | version: match[ 2 ] || "0"
112 | };
113 | };
114 | jQuery.browser = {};
115 | jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true;
116 | }
117 |
118 | /**
119 | * Small JavaScript module for the documentation.
120 | */
121 | var Documentation = {
122 |
123 | init : function() {
124 | this.fixFirefoxAnchorBug();
125 | this.highlightSearchWords();
126 | this.initIndexTable();
127 |
128 | },
129 |
130 | /**
131 | * i18n support
132 | */
133 | TRANSLATIONS : {},
134 | PLURAL_EXPR : function(n) { return n == 1 ? 0 : 1; },
135 | LOCALE : 'unknown',
136 |
137 | // gettext and ngettext don't access this so that the functions
138 | // can safely bound to a different name (_ = Documentation.gettext)
139 | gettext : function(string) {
140 | var translated = Documentation.TRANSLATIONS[string];
141 | if (typeof translated == 'undefined')
142 | return string;
143 | return (typeof translated == 'string') ? translated : translated[0];
144 | },
145 |
146 | ngettext : function(singular, plural, n) {
147 | var translated = Documentation.TRANSLATIONS[singular];
148 | if (typeof translated == 'undefined')
149 | return (n == 1) ? singular : plural;
150 | return translated[Documentation.PLURALEXPR(n)];
151 | },
152 |
153 | addTranslations : function(catalog) {
154 | for (var key in catalog.messages)
155 | this.TRANSLATIONS[key] = catalog.messages[key];
156 | this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')');
157 | this.LOCALE = catalog.locale;
158 | },
159 |
160 | /**
161 | * add context elements like header anchor links
162 | */
163 | addContextElements : function() {
164 | $('div[id] > :header:first').each(function() {
165 | $('').
166 | attr('href', '#' + this.id).
167 | attr('title', _('Permalink to this headline')).
168 | appendTo(this);
169 | });
170 | $('dt[id]').each(function() {
171 | $('').
172 | attr('href', '#' + this.id).
173 | attr('title', _('Permalink to this definition')).
174 | appendTo(this);
175 | });
176 | },
177 |
178 | /**
179 | * workaround a firefox stupidity
180 | * see: https://bugzilla.mozilla.org/show_bug.cgi?id=645075
181 | */
182 | fixFirefoxAnchorBug : function() {
183 | if (document.location.hash)
184 | window.setTimeout(function() {
185 | document.location.href += '';
186 | }, 10);
187 | },
188 |
189 | /**
190 | * highlight the search words provided in the url in the text
191 | */
192 | highlightSearchWords : function() {
193 | var params = $.getQueryParameters();
194 | var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : [];
195 | if (terms.length) {
196 | var body = $('div.body');
197 | if (!body.length) {
198 | body = $('body');
199 | }
200 | window.setTimeout(function() {
201 | $.each(terms, function() {
202 | body.highlightText(this.toLowerCase(), 'highlighted');
203 | });
204 | }, 10);
205 | $('
' + _('Hide Search Matches') + '
')
207 | .appendTo($('#searchbox'));
208 | }
209 | },
210 |
211 | /**
212 | * init the domain index toggle buttons
213 | */
214 | initIndexTable : function() {
215 | var togglers = $('img.toggler').click(function() {
216 | var src = $(this).attr('src');
217 | var idnum = $(this).attr('id').substr(7);
218 | $('tr.cg-' + idnum).toggle();
219 | if (src.substr(-9) == 'minus.png')
220 | $(this).attr('src', src.substr(0, src.length-9) + 'plus.png');
221 | else
222 | $(this).attr('src', src.substr(0, src.length-8) + 'minus.png');
223 | }).css('display', '');
224 | if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) {
225 | togglers.click();
226 | }
227 | },
228 |
229 | /**
230 | * helper function to hide the search marks again
231 | */
232 | hideSearchWords : function() {
233 | $('#searchbox .highlight-link').fadeOut(300);
234 | $('span.highlighted').removeClass('highlighted');
235 | },
236 |
237 | /**
238 | * make the url absolute
239 | */
240 | makeURL : function(relativeURL) {
241 | return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL;
242 | },
243 |
244 | /**
245 | * get the current relative url
246 | */
247 | getCurrentURL : function() {
248 | var path = document.location.pathname;
249 | var parts = path.split(/\//);
250 | $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() {
251 | if (this == '..')
252 | parts.pop();
253 | });
254 | var url = parts.join('/');
255 | return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
256 | },
257 |
258 | initOnKeyListeners: function() {
259 | $(document).keyup(function(event) {
260 | var activeElementType = document.activeElement.tagName;
261 | // don't navigate when in search box or textarea
262 | if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT') {
263 | switch (event.keyCode) {
264 | case 37: // left
265 | var prevHref = $('link[rel="prev"]').prop('href');
266 | if (prevHref) {
267 | window.location.href = prevHref;
268 | return false;
269 | }
270 | case 39: // right
271 | var nextHref = $('link[rel="next"]').prop('href');
272 | if (nextHref) {
273 | window.location.href = nextHref;
274 | return false;
275 | }
276 | }
277 | }
278 | });
279 | }
280 | };
281 |
282 | // quick alias for translations
283 | _ = Documentation.gettext;
284 |
285 | $(document).ready(function() {
286 | Documentation.init();
287 | });
--------------------------------------------------------------------------------
/docs/_static/down-pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brentp/hts-python/d27f873f7e8e770f6afd5630beb253edc2f7ca05/docs/_static/down-pressed.png
--------------------------------------------------------------------------------
/docs/_static/down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brentp/hts-python/d27f873f7e8e770f6afd5630beb253edc2f7ca05/docs/_static/down.png
--------------------------------------------------------------------------------
/docs/_static/file.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brentp/hts-python/d27f873f7e8e770f6afd5630beb253edc2f7ca05/docs/_static/file.png
--------------------------------------------------------------------------------
/docs/_static/minus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brentp/hts-python/d27f873f7e8e770f6afd5630beb253edc2f7ca05/docs/_static/minus.png
--------------------------------------------------------------------------------
/docs/_static/plus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brentp/hts-python/d27f873f7e8e770f6afd5630beb253edc2f7ca05/docs/_static/plus.png
--------------------------------------------------------------------------------
/docs/_static/pygments.css:
--------------------------------------------------------------------------------
1 | .highlight .hll { background-color: #ffffcc }
2 | .highlight { background: #eeffcc; }
3 | .highlight .c { color: #408090; font-style: italic } /* Comment */
4 | .highlight .err { border: 1px solid #FF0000 } /* Error */
5 | .highlight .k { color: #007020; font-weight: bold } /* Keyword */
6 | .highlight .o { color: #666666 } /* Operator */
7 | .highlight .ch { color: #408090; font-style: italic } /* Comment.Hashbang */
8 | .highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */
9 | .highlight .cp { color: #007020 } /* Comment.Preproc */
10 | .highlight .cpf { color: #408090; font-style: italic } /* Comment.PreprocFile */
11 | .highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */
12 | .highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
13 | .highlight .gd { color: #A00000 } /* Generic.Deleted */
14 | .highlight .ge { font-style: italic } /* Generic.Emph */
15 | .highlight .gr { color: #FF0000 } /* Generic.Error */
16 | .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
17 | .highlight .gi { color: #00A000 } /* Generic.Inserted */
18 | .highlight .go { color: #333333 } /* Generic.Output */
19 | .highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
20 | .highlight .gs { font-weight: bold } /* Generic.Strong */
21 | .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
22 | .highlight .gt { color: #0044DD } /* Generic.Traceback */
23 | .highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
24 | .highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
25 | .highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
26 | .highlight .kp { color: #007020 } /* Keyword.Pseudo */
27 | .highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
28 | .highlight .kt { color: #902000 } /* Keyword.Type */
29 | .highlight .m { color: #208050 } /* Literal.Number */
30 | .highlight .s { color: #4070a0 } /* Literal.String */
31 | .highlight .na { color: #4070a0 } /* Name.Attribute */
32 | .highlight .nb { color: #007020 } /* Name.Builtin */
33 | .highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
34 | .highlight .no { color: #60add5 } /* Name.Constant */
35 | .highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */
36 | .highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */
37 | .highlight .ne { color: #007020 } /* Name.Exception */
38 | .highlight .nf { color: #06287e } /* Name.Function */
39 | .highlight .nl { color: #002070; font-weight: bold } /* Name.Label */
40 | .highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
41 | .highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */
42 | .highlight .nv { color: #bb60d5 } /* Name.Variable */
43 | .highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */
44 | .highlight .w { color: #bbbbbb } /* Text.Whitespace */
45 | .highlight .mb { color: #208050 } /* Literal.Number.Bin */
46 | .highlight .mf { color: #208050 } /* Literal.Number.Float */
47 | .highlight .mh { color: #208050 } /* Literal.Number.Hex */
48 | .highlight .mi { color: #208050 } /* Literal.Number.Integer */
49 | .highlight .mo { color: #208050 } /* Literal.Number.Oct */
50 | .highlight .sa { color: #4070a0 } /* Literal.String.Affix */
51 | .highlight .sb { color: #4070a0 } /* Literal.String.Backtick */
52 | .highlight .sc { color: #4070a0 } /* Literal.String.Char */
53 | .highlight .dl { color: #4070a0 } /* Literal.String.Delimiter */
54 | .highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
55 | .highlight .s2 { color: #4070a0 } /* Literal.String.Double */
56 | .highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
57 | .highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */
58 | .highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
59 | .highlight .sx { color: #c65d09 } /* Literal.String.Other */
60 | .highlight .sr { color: #235388 } /* Literal.String.Regex */
61 | .highlight .s1 { color: #4070a0 } /* Literal.String.Single */
62 | .highlight .ss { color: #517918 } /* Literal.String.Symbol */
63 | .highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */
64 | .highlight .fm { color: #06287e } /* Name.Function.Magic */
65 | .highlight .vc { color: #bb60d5 } /* Name.Variable.Class */
66 | .highlight .vg { color: #bb60d5 } /* Name.Variable.Global */
67 | .highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */
68 | .highlight .vm { color: #bb60d5 } /* Name.Variable.Magic */
69 | .highlight .il { color: #208050 } /* Literal.Number.Integer.Long */
--------------------------------------------------------------------------------
/docs/_static/searchtools.js:
--------------------------------------------------------------------------------
1 | /*
2 | * searchtools.js_t
3 | * ~~~~~~~~~~~~~~~~
4 | *
5 | * Sphinx JavaScript utilities for the full-text search.
6 | *
7 | * :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
8 | * :license: BSD, see LICENSE for details.
9 | *
10 | */
11 |
12 |
13 | /* Non-minified version JS is _stemmer.js if file is provided */
14 | /**
15 | * Porter Stemmer
16 | */
17 | var Stemmer = function() {
18 |
19 | var step2list = {
20 | ational: 'ate',
21 | tional: 'tion',
22 | enci: 'ence',
23 | anci: 'ance',
24 | izer: 'ize',
25 | bli: 'ble',
26 | alli: 'al',
27 | entli: 'ent',
28 | eli: 'e',
29 | ousli: 'ous',
30 | ization: 'ize',
31 | ation: 'ate',
32 | ator: 'ate',
33 | alism: 'al',
34 | iveness: 'ive',
35 | fulness: 'ful',
36 | ousness: 'ous',
37 | aliti: 'al',
38 | iviti: 'ive',
39 | biliti: 'ble',
40 | logi: 'log'
41 | };
42 |
43 | var step3list = {
44 | icate: 'ic',
45 | ative: '',
46 | alize: 'al',
47 | iciti: 'ic',
48 | ical: 'ic',
49 | ful: '',
50 | ness: ''
51 | };
52 |
53 | var c = "[^aeiou]"; // consonant
54 | var v = "[aeiouy]"; // vowel
55 | var C = c + "[^aeiouy]*"; // consonant sequence
56 | var V = v + "[aeiou]*"; // vowel sequence
57 |
58 | var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0
59 | var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1
60 | var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1
61 | var s_v = "^(" + C + ")?" + v; // vowel in stem
62 |
63 | this.stemWord = function (w) {
64 | var stem;
65 | var suffix;
66 | var firstch;
67 | var origword = w;
68 |
69 | if (w.length < 3)
70 | return w;
71 |
72 | var re;
73 | var re2;
74 | var re3;
75 | var re4;
76 |
77 | firstch = w.substr(0,1);
78 | if (firstch == "y")
79 | w = firstch.toUpperCase() + w.substr(1);
80 |
81 | // Step 1a
82 | re = /^(.+?)(ss|i)es$/;
83 | re2 = /^(.+?)([^s])s$/;
84 |
85 | if (re.test(w))
86 | w = w.replace(re,"$1$2");
87 | else if (re2.test(w))
88 | w = w.replace(re2,"$1$2");
89 |
90 | // Step 1b
91 | re = /^(.+?)eed$/;
92 | re2 = /^(.+?)(ed|ing)$/;
93 | if (re.test(w)) {
94 | var fp = re.exec(w);
95 | re = new RegExp(mgr0);
96 | if (re.test(fp[1])) {
97 | re = /.$/;
98 | w = w.replace(re,"");
99 | }
100 | }
101 | else if (re2.test(w)) {
102 | var fp = re2.exec(w);
103 | stem = fp[1];
104 | re2 = new RegExp(s_v);
105 | if (re2.test(stem)) {
106 | w = stem;
107 | re2 = /(at|bl|iz)$/;
108 | re3 = new RegExp("([^aeiouylsz])\\1$");
109 | re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
110 | if (re2.test(w))
111 | w = w + "e";
112 | else if (re3.test(w)) {
113 | re = /.$/;
114 | w = w.replace(re,"");
115 | }
116 | else if (re4.test(w))
117 | w = w + "e";
118 | }
119 | }
120 |
121 | // Step 1c
122 | re = /^(.+?)y$/;
123 | if (re.test(w)) {
124 | var fp = re.exec(w);
125 | stem = fp[1];
126 | re = new RegExp(s_v);
127 | if (re.test(stem))
128 | w = stem + "i";
129 | }
130 |
131 | // Step 2
132 | re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
133 | if (re.test(w)) {
134 | var fp = re.exec(w);
135 | stem = fp[1];
136 | suffix = fp[2];
137 | re = new RegExp(mgr0);
138 | if (re.test(stem))
139 | w = stem + step2list[suffix];
140 | }
141 |
142 | // Step 3
143 | re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
144 | if (re.test(w)) {
145 | var fp = re.exec(w);
146 | stem = fp[1];
147 | suffix = fp[2];
148 | re = new RegExp(mgr0);
149 | if (re.test(stem))
150 | w = stem + step3list[suffix];
151 | }
152 |
153 | // Step 4
154 | re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;
155 | re2 = /^(.+?)(s|t)(ion)$/;
156 | if (re.test(w)) {
157 | var fp = re.exec(w);
158 | stem = fp[1];
159 | re = new RegExp(mgr1);
160 | if (re.test(stem))
161 | w = stem;
162 | }
163 | else if (re2.test(w)) {
164 | var fp = re2.exec(w);
165 | stem = fp[1] + fp[2];
166 | re2 = new RegExp(mgr1);
167 | if (re2.test(stem))
168 | w = stem;
169 | }
170 |
171 | // Step 5
172 | re = /^(.+?)e$/;
173 | if (re.test(w)) {
174 | var fp = re.exec(w);
175 | stem = fp[1];
176 | re = new RegExp(mgr1);
177 | re2 = new RegExp(meq1);
178 | re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
179 | if (re.test(stem) || (re2.test(stem) && !(re3.test(stem))))
180 | w = stem;
181 | }
182 | re = /ll$/;
183 | re2 = new RegExp(mgr1);
184 | if (re.test(w) && re2.test(w)) {
185 | re = /.$/;
186 | w = w.replace(re,"");
187 | }
188 |
189 | // and turn initial Y back to y
190 | if (firstch == "y")
191 | w = firstch.toLowerCase() + w.substr(1);
192 | return w;
193 | }
194 | }
195 |
196 |
197 |
198 | /**
199 | * Simple result scoring code.
200 | */
201 | var Scorer = {
202 | // Implement the following function to further tweak the score for each result
203 | // The function takes a result array [filename, title, anchor, descr, score]
204 | // and returns the new score.
205 | /*
206 | score: function(result) {
207 | return result[4];
208 | },
209 | */
210 |
211 | // query matches the full name of an object
212 | objNameMatch: 11,
213 | // or matches in the last dotted part of the object name
214 | objPartialMatch: 6,
215 | // Additive scores depending on the priority of the object
216 | objPrio: {0: 15, // used to be importantResults
217 | 1: 5, // used to be objectResults
218 | 2: -5}, // used to be unimportantResults
219 | // Used when the priority is not in the mapping.
220 | objPrioDefault: 0,
221 |
222 | // query found in title
223 | title: 15,
224 | // query found in terms
225 | term: 5
226 | };
227 |
228 |
229 |
230 |
231 |
232 | var splitChars = (function() {
233 | var result = {};
234 | var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648,
235 | 1748, 1809, 2416, 2473, 2481, 2526, 2601, 2609, 2612, 2615, 2653, 2702,
236 | 2706, 2729, 2737, 2740, 2857, 2865, 2868, 2910, 2928, 2948, 2961, 2971,
237 | 2973, 3085, 3089, 3113, 3124, 3213, 3217, 3241, 3252, 3295, 3341, 3345,
238 | 3369, 3506, 3516, 3633, 3715, 3721, 3736, 3744, 3748, 3750, 3756, 3761,
239 | 3781, 3912, 4239, 4347, 4681, 4695, 4697, 4745, 4785, 4799, 4801, 4823,
240 | 4881, 5760, 5901, 5997, 6313, 7405, 8024, 8026, 8028, 8030, 8117, 8125,
241 | 8133, 8181, 8468, 8485, 8487, 8489, 8494, 8527, 11311, 11359, 11687, 11695,
242 | 11703, 11711, 11719, 11727, 11735, 12448, 12539, 43010, 43014, 43019, 43587,
243 | 43696, 43713, 64286, 64297, 64311, 64317, 64319, 64322, 64325, 65141];
244 | var i, j, start, end;
245 | for (i = 0; i < singles.length; i++) {
246 | result[singles[i]] = true;
247 | }
248 | var ranges = [[0, 47], [58, 64], [91, 94], [123, 169], [171, 177], [182, 184], [706, 709],
249 | [722, 735], [741, 747], [751, 879], [888, 889], [894, 901], [1154, 1161],
250 | [1318, 1328], [1367, 1368], [1370, 1376], [1416, 1487], [1515, 1519], [1523, 1568],
251 | [1611, 1631], [1642, 1645], [1750, 1764], [1767, 1773], [1789, 1790], [1792, 1807],
252 | [1840, 1868], [1958, 1968], [1970, 1983], [2027, 2035], [2038, 2041], [2043, 2047],
253 | [2070, 2073], [2075, 2083], [2085, 2087], [2089, 2307], [2362, 2364], [2366, 2383],
254 | [2385, 2391], [2402, 2405], [2419, 2424], [2432, 2436], [2445, 2446], [2449, 2450],
255 | [2483, 2485], [2490, 2492], [2494, 2509], [2511, 2523], [2530, 2533], [2546, 2547],
256 | [2554, 2564], [2571, 2574], [2577, 2578], [2618, 2648], [2655, 2661], [2672, 2673],
257 | [2677, 2692], [2746, 2748], [2750, 2767], [2769, 2783], [2786, 2789], [2800, 2820],
258 | [2829, 2830], [2833, 2834], [2874, 2876], [2878, 2907], [2914, 2917], [2930, 2946],
259 | [2955, 2957], [2966, 2968], [2976, 2978], [2981, 2983], [2987, 2989], [3002, 3023],
260 | [3025, 3045], [3059, 3076], [3130, 3132], [3134, 3159], [3162, 3167], [3170, 3173],
261 | [3184, 3191], [3199, 3204], [3258, 3260], [3262, 3293], [3298, 3301], [3312, 3332],
262 | [3386, 3388], [3390, 3423], [3426, 3429], [3446, 3449], [3456, 3460], [3479, 3481],
263 | [3518, 3519], [3527, 3584], [3636, 3647], [3655, 3663], [3674, 3712], [3717, 3718],
264 | [3723, 3724], [3726, 3731], [3752, 3753], [3764, 3772], [3774, 3775], [3783, 3791],
265 | [3802, 3803], [3806, 3839], [3841, 3871], [3892, 3903], [3949, 3975], [3980, 4095],
266 | [4139, 4158], [4170, 4175], [4182, 4185], [4190, 4192], [4194, 4196], [4199, 4205],
267 | [4209, 4212], [4226, 4237], [4250, 4255], [4294, 4303], [4349, 4351], [4686, 4687],
268 | [4702, 4703], [4750, 4751], [4790, 4791], [4806, 4807], [4886, 4887], [4955, 4968],
269 | [4989, 4991], [5008, 5023], [5109, 5120], [5741, 5742], [5787, 5791], [5867, 5869],
270 | [5873, 5887], [5906, 5919], [5938, 5951], [5970, 5983], [6001, 6015], [6068, 6102],
271 | [6104, 6107], [6109, 6111], [6122, 6127], [6138, 6159], [6170, 6175], [6264, 6271],
272 | [6315, 6319], [6390, 6399], [6429, 6469], [6510, 6511], [6517, 6527], [6572, 6592],
273 | [6600, 6607], [6619, 6655], [6679, 6687], [6741, 6783], [6794, 6799], [6810, 6822],
274 | [6824, 6916], [6964, 6980], [6988, 6991], [7002, 7042], [7073, 7085], [7098, 7167],
275 | [7204, 7231], [7242, 7244], [7294, 7400], [7410, 7423], [7616, 7679], [7958, 7959],
276 | [7966, 7967], [8006, 8007], [8014, 8015], [8062, 8063], [8127, 8129], [8141, 8143],
277 | [8148, 8149], [8156, 8159], [8173, 8177], [8189, 8303], [8306, 8307], [8314, 8318],
278 | [8330, 8335], [8341, 8449], [8451, 8454], [8456, 8457], [8470, 8472], [8478, 8483],
279 | [8506, 8507], [8512, 8516], [8522, 8525], [8586, 9311], [9372, 9449], [9472, 10101],
280 | [10132, 11263], [11493, 11498], [11503, 11516], [11518, 11519], [11558, 11567],
281 | [11622, 11630], [11632, 11647], [11671, 11679], [11743, 11822], [11824, 12292],
282 | [12296, 12320], [12330, 12336], [12342, 12343], [12349, 12352], [12439, 12444],
283 | [12544, 12548], [12590, 12592], [12687, 12689], [12694, 12703], [12728, 12783],
284 | [12800, 12831], [12842, 12880], [12896, 12927], [12938, 12976], [12992, 13311],
285 | [19894, 19967], [40908, 40959], [42125, 42191], [42238, 42239], [42509, 42511],
286 | [42540, 42559], [42592, 42593], [42607, 42622], [42648, 42655], [42736, 42774],
287 | [42784, 42785], [42889, 42890], [42893, 43002], [43043, 43055], [43062, 43071],
288 | [43124, 43137], [43188, 43215], [43226, 43249], [43256, 43258], [43260, 43263],
289 | [43302, 43311], [43335, 43359], [43389, 43395], [43443, 43470], [43482, 43519],
290 | [43561, 43583], [43596, 43599], [43610, 43615], [43639, 43641], [43643, 43647],
291 | [43698, 43700], [43703, 43704], [43710, 43711], [43715, 43738], [43742, 43967],
292 | [44003, 44015], [44026, 44031], [55204, 55215], [55239, 55242], [55292, 55295],
293 | [57344, 63743], [64046, 64047], [64110, 64111], [64218, 64255], [64263, 64274],
294 | [64280, 64284], [64434, 64466], [64830, 64847], [64912, 64913], [64968, 65007],
295 | [65020, 65135], [65277, 65295], [65306, 65312], [65339, 65344], [65371, 65381],
296 | [65471, 65473], [65480, 65481], [65488, 65489], [65496, 65497]];
297 | for (i = 0; i < ranges.length; i++) {
298 | start = ranges[i][0];
299 | end = ranges[i][1];
300 | for (j = start; j <= end; j++) {
301 | result[j] = true;
302 | }
303 | }
304 | return result;
305 | })();
306 |
307 | function splitQuery(query) {
308 | var result = [];
309 | var start = -1;
310 | for (var i = 0; i < query.length; i++) {
311 | if (splitChars[query.charCodeAt(i)]) {
312 | if (start !== -1) {
313 | result.push(query.slice(start, i));
314 | start = -1;
315 | }
316 | } else if (start === -1) {
317 | start = i;
318 | }
319 | }
320 | if (start !== -1) {
321 | result.push(query.slice(start));
322 | }
323 | return result;
324 | }
325 |
326 |
327 |
328 |
329 | /**
330 | * Search Module
331 | */
332 | var Search = {
333 |
334 | _index : null,
335 | _queued_query : null,
336 | _pulse_status : -1,
337 |
338 | init : function() {
339 | var params = $.getQueryParameters();
340 | if (params.q) {
341 | var query = params.q[0];
342 | $('input[name="q"]')[0].value = query;
343 | this.performSearch(query);
344 | }
345 | },
346 |
347 | loadIndex : function(url) {
348 | $.ajax({type: "GET", url: url, data: null,
349 | dataType: "script", cache: true,
350 | complete: function(jqxhr, textstatus) {
351 | if (textstatus != "success") {
352 | document.getElementById("searchindexloader").src = url;
353 | }
354 | }});
355 | },
356 |
357 | setIndex : function(index) {
358 | var q;
359 | this._index = index;
360 | if ((q = this._queued_query) !== null) {
361 | this._queued_query = null;
362 | Search.query(q);
363 | }
364 | },
365 |
366 | hasIndex : function() {
367 | return this._index !== null;
368 | },
369 |
370 | deferQuery : function(query) {
371 | this._queued_query = query;
372 | },
373 |
374 | stopPulse : function() {
375 | this._pulse_status = 0;
376 | },
377 |
378 | startPulse : function() {
379 | if (this._pulse_status >= 0)
380 | return;
381 | function pulse() {
382 | var i;
383 | Search._pulse_status = (Search._pulse_status + 1) % 4;
384 | var dotString = '';
385 | for (i = 0; i < Search._pulse_status; i++)
386 | dotString += '.';
387 | Search.dots.text(dotString);
388 | if (Search._pulse_status > -1)
389 | window.setTimeout(pulse, 500);
390 | }
391 | pulse();
392 | },
393 |
394 | /**
395 | * perform a search for something (or wait until index is loaded)
396 | */
397 | performSearch : function(query) {
398 | // create the required interface elements
399 | this.out = $('#search-results');
400 | this.title = $('' + _('Searching') + ' ').appendTo(this.out);
401 | this.dots = $(' ').appendTo(this.title);
402 | this.status = $('
').appendTo(this.out);
403 | this.output = $('').appendTo(this.out);
404 |
405 | $('#search-progress').text(_('Preparing search...'));
406 | this.startPulse();
407 |
408 | // index already loaded, the browser was quick!
409 | if (this.hasIndex())
410 | this.query(query);
411 | else
412 | this.deferQuery(query);
413 | },
414 |
415 | /**
416 | * execute search (requires search index to be loaded)
417 | */
418 | query : function(query) {
419 | var i;
420 | var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"];
421 |
422 | // stem the searchterms and add them to the correct list
423 | var stemmer = new Stemmer();
424 | var searchterms = [];
425 | var excluded = [];
426 | var hlterms = [];
427 | var tmp = splitQuery(query);
428 | var objectterms = [];
429 | for (i = 0; i < tmp.length; i++) {
430 | if (tmp[i] !== "") {
431 | objectterms.push(tmp[i].toLowerCase());
432 | }
433 |
434 | if ($u.indexOf(stopwords, tmp[i].toLowerCase()) != -1 || tmp[i].match(/^\d+$/) ||
435 | tmp[i] === "") {
436 | // skip this "word"
437 | continue;
438 | }
439 | // stem the word
440 | var word = stemmer.stemWord(tmp[i].toLowerCase());
441 | // prevent stemmer from cutting word smaller than two chars
442 | if(word.length < 3 && tmp[i].length >= 3) {
443 | word = tmp[i];
444 | }
445 | var toAppend;
446 | // select the correct list
447 | if (word[0] == '-') {
448 | toAppend = excluded;
449 | word = word.substr(1);
450 | }
451 | else {
452 | toAppend = searchterms;
453 | hlterms.push(tmp[i].toLowerCase());
454 | }
455 | // only add if not already in the list
456 | if (!$u.contains(toAppend, word))
457 | toAppend.push(word);
458 | }
459 | var highlightstring = '?highlight=' + $.urlencode(hlterms.join(" "));
460 |
461 | // console.debug('SEARCH: searching for:');
462 | // console.info('required: ', searchterms);
463 | // console.info('excluded: ', excluded);
464 |
465 | // prepare search
466 | var terms = this._index.terms;
467 | var titleterms = this._index.titleterms;
468 |
469 | // array of [filename, title, anchor, descr, score]
470 | var results = [];
471 | $('#search-progress').empty();
472 |
473 | // lookup as object
474 | for (i = 0; i < objectterms.length; i++) {
475 | var others = [].concat(objectterms.slice(0, i),
476 | objectterms.slice(i+1, objectterms.length));
477 | results = results.concat(this.performObjectSearch(objectterms[i], others));
478 | }
479 |
480 | // lookup as search terms in fulltext
481 | results = results.concat(this.performTermsSearch(searchterms, excluded, terms, titleterms));
482 |
483 | // let the scorer override scores with a custom scoring function
484 | if (Scorer.score) {
485 | for (i = 0; i < results.length; i++)
486 | results[i][4] = Scorer.score(results[i]);
487 | }
488 |
489 | // now sort the results by score (in opposite order of appearance, since the
490 | // display function below uses pop() to retrieve items) and then
491 | // alphabetically
492 | results.sort(function(a, b) {
493 | var left = a[4];
494 | var right = b[4];
495 | if (left > right) {
496 | return 1;
497 | } else if (left < right) {
498 | return -1;
499 | } else {
500 | // same score: sort alphabetically
501 | left = a[1].toLowerCase();
502 | right = b[1].toLowerCase();
503 | return (left > right) ? -1 : ((left < right) ? 1 : 0);
504 | }
505 | });
506 |
507 | // for debugging
508 | //Search.lastresults = results.slice(); // a copy
509 | //console.info('search results:', Search.lastresults);
510 |
511 | // print the results
512 | var resultCount = results.length;
513 | function displayNextItem() {
514 | // results left, load the summary and display it
515 | if (results.length) {
516 | var item = results.pop();
517 | var listItem = $(' ');
518 | if (DOCUMENTATION_OPTIONS.FILE_SUFFIX === '') {
519 | // dirhtml builder
520 | var dirname = item[0] + '/';
521 | if (dirname.match(/\/index\/$/)) {
522 | dirname = dirname.substring(0, dirname.length-6);
523 | } else if (dirname == 'index/') {
524 | dirname = '';
525 | }
526 | listItem.append($(' ').attr('href',
527 | DOCUMENTATION_OPTIONS.URL_ROOT + dirname +
528 | highlightstring + item[2]).html(item[1]));
529 | } else {
530 | // normal html builders
531 | listItem.append($(' ').attr('href',
532 | item[0] + DOCUMENTATION_OPTIONS.FILE_SUFFIX +
533 | highlightstring + item[2]).html(item[1]));
534 | }
535 | if (item[3]) {
536 | listItem.append($(' (' + item[3] + ') '));
537 | Search.output.append(listItem);
538 | listItem.slideDown(5, function() {
539 | displayNextItem();
540 | });
541 | } else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
542 | var suffix = DOCUMENTATION_OPTIONS.SOURCELINK_SUFFIX;
543 | $.ajax({url: DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + item[5] + (item[5].slice(-suffix.length) === suffix ? '' : suffix),
544 | dataType: "text",
545 | complete: function(jqxhr, textstatus) {
546 | var data = jqxhr.responseText;
547 | if (data !== '' && data !== undefined) {
548 | listItem.append(Search.makeSearchSummary(data, searchterms, hlterms));
549 | }
550 | Search.output.append(listItem);
551 | listItem.slideDown(5, function() {
552 | displayNextItem();
553 | });
554 | }});
555 | } else {
556 | // no source available, just display title
557 | Search.output.append(listItem);
558 | listItem.slideDown(5, function() {
559 | displayNextItem();
560 | });
561 | }
562 | }
563 | // search finished, update title and status message
564 | else {
565 | Search.stopPulse();
566 | Search.title.text(_('Search Results'));
567 | if (!resultCount)
568 | Search.status.text(_('Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.'));
569 | else
570 | Search.status.text(_('Search finished, found %s page(s) matching the search query.').replace('%s', resultCount));
571 | Search.status.fadeIn(500);
572 | }
573 | }
574 | displayNextItem();
575 | },
576 |
577 | /**
578 | * search for object names
579 | */
580 | performObjectSearch : function(object, otherterms) {
581 | var filenames = this._index.filenames;
582 | var docnames = this._index.docnames;
583 | var objects = this._index.objects;
584 | var objnames = this._index.objnames;
585 | var titles = this._index.titles;
586 |
587 | var i;
588 | var results = [];
589 |
590 | for (var prefix in objects) {
591 | for (var name in objects[prefix]) {
592 | var fullname = (prefix ? prefix + '.' : '') + name;
593 | if (fullname.toLowerCase().indexOf(object) > -1) {
594 | var score = 0;
595 | var parts = fullname.split('.');
596 | // check for different match types: exact matches of full name or
597 | // "last name" (i.e. last dotted part)
598 | if (fullname == object || parts[parts.length - 1] == object) {
599 | score += Scorer.objNameMatch;
600 | // matches in last name
601 | } else if (parts[parts.length - 1].indexOf(object) > -1) {
602 | score += Scorer.objPartialMatch;
603 | }
604 | var match = objects[prefix][name];
605 | var objname = objnames[match[1]][2];
606 | var title = titles[match[0]];
607 | // If more than one term searched for, we require other words to be
608 | // found in the name/title/description
609 | if (otherterms.length > 0) {
610 | var haystack = (prefix + ' ' + name + ' ' +
611 | objname + ' ' + title).toLowerCase();
612 | var allfound = true;
613 | for (i = 0; i < otherterms.length; i++) {
614 | if (haystack.indexOf(otherterms[i]) == -1) {
615 | allfound = false;
616 | break;
617 | }
618 | }
619 | if (!allfound) {
620 | continue;
621 | }
622 | }
623 | var descr = objname + _(', in ') + title;
624 |
625 | var anchor = match[3];
626 | if (anchor === '')
627 | anchor = fullname;
628 | else if (anchor == '-')
629 | anchor = objnames[match[1]][1] + '-' + fullname;
630 | // add custom score for some objects according to scorer
631 | if (Scorer.objPrio.hasOwnProperty(match[2])) {
632 | score += Scorer.objPrio[match[2]];
633 | } else {
634 | score += Scorer.objPrioDefault;
635 | }
636 | results.push([docnames[match[0]], fullname, '#'+anchor, descr, score, filenames[match[0]]]);
637 | }
638 | }
639 | }
640 |
641 | return results;
642 | },
643 |
644 | /**
645 | * search for full-text terms in the index
646 | */
647 | performTermsSearch : function(searchterms, excluded, terms, titleterms) {
648 | var docnames = this._index.docnames;
649 | var filenames = this._index.filenames;
650 | var titles = this._index.titles;
651 |
652 | var i, j, file;
653 | var fileMap = {};
654 | var scoreMap = {};
655 | var results = [];
656 |
657 | // perform the search on the required terms
658 | for (i = 0; i < searchterms.length; i++) {
659 | var word = searchterms[i];
660 | var files = [];
661 | var _o = [
662 | {files: terms[word], score: Scorer.term},
663 | {files: titleterms[word], score: Scorer.title}
664 | ];
665 |
666 | // no match but word was a required one
667 | if ($u.every(_o, function(o){return o.files === undefined;})) {
668 | break;
669 | }
670 | // found search word in contents
671 | $u.each(_o, function(o) {
672 | var _files = o.files;
673 | if (_files === undefined)
674 | return
675 |
676 | if (_files.length === undefined)
677 | _files = [_files];
678 | files = files.concat(_files);
679 |
680 | // set score for the word in each file to Scorer.term
681 | for (j = 0; j < _files.length; j++) {
682 | file = _files[j];
683 | if (!(file in scoreMap))
684 | scoreMap[file] = {}
685 | scoreMap[file][word] = o.score;
686 | }
687 | });
688 |
689 | // create the mapping
690 | for (j = 0; j < files.length; j++) {
691 | file = files[j];
692 | if (file in fileMap)
693 | fileMap[file].push(word);
694 | else
695 | fileMap[file] = [word];
696 | }
697 | }
698 |
699 | // now check if the files don't contain excluded terms
700 | for (file in fileMap) {
701 | var valid = true;
702 |
703 | // check if all requirements are matched
704 | if (fileMap[file].length != searchterms.length)
705 | continue;
706 |
707 | // ensure that none of the excluded terms is in the search result
708 | for (i = 0; i < excluded.length; i++) {
709 | if (terms[excluded[i]] == file ||
710 | titleterms[excluded[i]] == file ||
711 | $u.contains(terms[excluded[i]] || [], file) ||
712 | $u.contains(titleterms[excluded[i]] || [], file)) {
713 | valid = false;
714 | break;
715 | }
716 | }
717 |
718 | // if we have still a valid result we can add it to the result list
719 | if (valid) {
720 | // select one (max) score for the file.
721 | // for better ranking, we should calculate ranking by using words statistics like basic tf-idf...
722 | var score = $u.max($u.map(fileMap[file], function(w){return scoreMap[file][w]}));
723 | results.push([docnames[file], titles[file], '', null, score, filenames[file]]);
724 | }
725 | }
726 | return results;
727 | },
728 |
729 | /**
730 | * helper function to return a node containing the
731 | * search summary for a given text. keywords is a list
732 | * of stemmed words, hlwords is the list of normal, unstemmed
733 | * words. the first one is used to find the occurrence, the
734 | * latter for highlighting it.
735 | */
736 | makeSearchSummary : function(text, keywords, hlwords) {
737 | var textLower = text.toLowerCase();
738 | var start = 0;
739 | $.each(keywords, function() {
740 | var i = textLower.indexOf(this.toLowerCase());
741 | if (i > -1)
742 | start = i;
743 | });
744 | start = Math.max(start - 120, 0);
745 | var excerpt = ((start > 0) ? '...' : '') +
746 | $.trim(text.substr(start, 240)) +
747 | ((start + 240 - text.length) ? '...' : '');
748 | var rv = $('
').text(excerpt);
749 | $.each(hlwords, function() {
750 | rv = rv.highlightText(this, 'highlighted');
751 | });
752 | return rv;
753 | }
754 | };
755 |
756 | $(document).ready(function() {
757 | Search.init();
758 | });
--------------------------------------------------------------------------------
/docs/_static/underscore.js:
--------------------------------------------------------------------------------
1 | // Underscore.js 1.3.1
2 | // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
3 | // Underscore is freely distributable under the MIT license.
4 | // Portions of Underscore are inspired or borrowed from Prototype,
5 | // Oliver Steele's Functional, and John Resig's Micro-Templating.
6 | // For all details and documentation:
7 | // http://documentcloud.github.com/underscore
8 | (function(){function q(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return false;switch(e){case "[object String]":return a==String(c);case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==
9 | c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){if(f=a.length,g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&q(a[f],c[f],d)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&q(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c,
10 | h)&&!f--)break;g=!f}}d.pop();return g}var r=this,G=r._,n={},k=Array.prototype,o=Object.prototype,i=k.slice,H=k.unshift,l=o.toString,I=o.hasOwnProperty,w=k.forEach,x=k.map,y=k.reduce,z=k.reduceRight,A=k.filter,B=k.every,C=k.some,p=k.indexOf,D=k.lastIndexOf,o=Array.isArray,J=Object.keys,s=Function.prototype.bind,b=function(a){return new m(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=b;exports._=b}else r._=b;b.VERSION="1.3.1";var j=b.each=
11 | b.forEach=function(a,c,d){if(a!=null)if(w&&a.forEach===w)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e2;a==
12 | null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=
13 | function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e=
14 | e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck=
15 | function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;bd?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,
17 | c,d){d||(d=b.identity);for(var e=0,f=a.length;e>1;d(a[g])=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e=0;d--)b=[a[d].apply(this,b)];return b[0]}};
24 | b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments,
25 | 1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)};
26 | b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"};
27 | b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e /g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.mixin=function(a){j(b.functions(a),
28 | function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+
29 | u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]=
30 | function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain=
31 | true;return this};m.prototype.value=function(){return this._wrapped}}).call(this);
32 |
--------------------------------------------------------------------------------
/docs/_static/up-pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brentp/hts-python/d27f873f7e8e770f6afd5630beb253edc2f7ca05/docs/_static/up-pressed.png
--------------------------------------------------------------------------------
/docs/_static/up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brentp/hts-python/d27f873f7e8e770f6afd5630beb253edc2f7ca05/docs/_static/up.png
--------------------------------------------------------------------------------
/docs/_static/websupport.js:
--------------------------------------------------------------------------------
1 | /*
2 | * websupport.js
3 | * ~~~~~~~~~~~~~
4 | *
5 | * sphinx.websupport utilities for all documentation.
6 | *
7 | * :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
8 | * :license: BSD, see LICENSE for details.
9 | *
10 | */
11 |
12 | (function($) {
13 | $.fn.autogrow = function() {
14 | return this.each(function() {
15 | var textarea = this;
16 |
17 | $.fn.autogrow.resize(textarea);
18 |
19 | $(textarea)
20 | .focus(function() {
21 | textarea.interval = setInterval(function() {
22 | $.fn.autogrow.resize(textarea);
23 | }, 500);
24 | })
25 | .blur(function() {
26 | clearInterval(textarea.interval);
27 | });
28 | });
29 | };
30 |
31 | $.fn.autogrow.resize = function(textarea) {
32 | var lineHeight = parseInt($(textarea).css('line-height'), 10);
33 | var lines = textarea.value.split('\n');
34 | var columns = textarea.cols;
35 | var lineCount = 0;
36 | $.each(lines, function() {
37 | lineCount += Math.ceil(this.length / columns) || 1;
38 | });
39 | var height = lineHeight * (lineCount + 1);
40 | $(textarea).css('height', height);
41 | };
42 | })(jQuery);
43 |
44 | (function($) {
45 | var comp, by;
46 |
47 | function init() {
48 | initEvents();
49 | initComparator();
50 | }
51 |
52 | function initEvents() {
53 | $(document).on("click", 'a.comment-close', function(event) {
54 | event.preventDefault();
55 | hide($(this).attr('id').substring(2));
56 | });
57 | $(document).on("click", 'a.vote', function(event) {
58 | event.preventDefault();
59 | handleVote($(this));
60 | });
61 | $(document).on("click", 'a.reply', function(event) {
62 | event.preventDefault();
63 | openReply($(this).attr('id').substring(2));
64 | });
65 | $(document).on("click", 'a.close-reply', function(event) {
66 | event.preventDefault();
67 | closeReply($(this).attr('id').substring(2));
68 | });
69 | $(document).on("click", 'a.sort-option', function(event) {
70 | event.preventDefault();
71 | handleReSort($(this));
72 | });
73 | $(document).on("click", 'a.show-proposal', function(event) {
74 | event.preventDefault();
75 | showProposal($(this).attr('id').substring(2));
76 | });
77 | $(document).on("click", 'a.hide-proposal', function(event) {
78 | event.preventDefault();
79 | hideProposal($(this).attr('id').substring(2));
80 | });
81 | $(document).on("click", 'a.show-propose-change', function(event) {
82 | event.preventDefault();
83 | showProposeChange($(this).attr('id').substring(2));
84 | });
85 | $(document).on("click", 'a.hide-propose-change', function(event) {
86 | event.preventDefault();
87 | hideProposeChange($(this).attr('id').substring(2));
88 | });
89 | $(document).on("click", 'a.accept-comment', function(event) {
90 | event.preventDefault();
91 | acceptComment($(this).attr('id').substring(2));
92 | });
93 | $(document).on("click", 'a.delete-comment', function(event) {
94 | event.preventDefault();
95 | deleteComment($(this).attr('id').substring(2));
96 | });
97 | $(document).on("click", 'a.comment-markup', function(event) {
98 | event.preventDefault();
99 | toggleCommentMarkupBox($(this).attr('id').substring(2));
100 | });
101 | }
102 |
103 | /**
104 | * Set comp, which is a comparator function used for sorting and
105 | * inserting comments into the list.
106 | */
107 | function setComparator() {
108 | // If the first three letters are "asc", sort in ascending order
109 | // and remove the prefix.
110 | if (by.substring(0,3) == 'asc') {
111 | var i = by.substring(3);
112 | comp = function(a, b) { return a[i] - b[i]; };
113 | } else {
114 | // Otherwise sort in descending order.
115 | comp = function(a, b) { return b[by] - a[by]; };
116 | }
117 |
118 | // Reset link styles and format the selected sort option.
119 | $('a.sel').attr('href', '#').removeClass('sel');
120 | $('a.by' + by).removeAttr('href').addClass('sel');
121 | }
122 |
123 | /**
124 | * Create a comp function. If the user has preferences stored in
125 | * the sortBy cookie, use those, otherwise use the default.
126 | */
127 | function initComparator() {
128 | by = 'rating'; // Default to sort by rating.
129 | // If the sortBy cookie is set, use that instead.
130 | if (document.cookie.length > 0) {
131 | var start = document.cookie.indexOf('sortBy=');
132 | if (start != -1) {
133 | start = start + 7;
134 | var end = document.cookie.indexOf(";", start);
135 | if (end == -1) {
136 | end = document.cookie.length;
137 | by = unescape(document.cookie.substring(start, end));
138 | }
139 | }
140 | }
141 | setComparator();
142 | }
143 |
144 | /**
145 | * Show a comment div.
146 | */
147 | function show(id) {
148 | $('#ao' + id).hide();
149 | $('#ah' + id).show();
150 | var context = $.extend({id: id}, opts);
151 | var popup = $(renderTemplate(popupTemplate, context)).hide();
152 | popup.find('textarea[name="proposal"]').hide();
153 | popup.find('a.by' + by).addClass('sel');
154 | var form = popup.find('#cf' + id);
155 | form.submit(function(event) {
156 | event.preventDefault();
157 | addComment(form);
158 | });
159 | $('#s' + id).after(popup);
160 | popup.slideDown('fast', function() {
161 | getComments(id);
162 | });
163 | }
164 |
165 | /**
166 | * Hide a comment div.
167 | */
168 | function hide(id) {
169 | $('#ah' + id).hide();
170 | $('#ao' + id).show();
171 | var div = $('#sc' + id);
172 | div.slideUp('fast', function() {
173 | div.remove();
174 | });
175 | }
176 |
177 | /**
178 | * Perform an ajax request to get comments for a node
179 | * and insert the comments into the comments tree.
180 | */
181 | function getComments(id) {
182 | $.ajax({
183 | type: 'GET',
184 | url: opts.getCommentsURL,
185 | data: {node: id},
186 | success: function(data, textStatus, request) {
187 | var ul = $('#cl' + id);
188 | var speed = 100;
189 | $('#cf' + id)
190 | .find('textarea[name="proposal"]')
191 | .data('source', data.source);
192 |
193 | if (data.comments.length === 0) {
194 | ul.html('No comments yet. ');
195 | ul.data('empty', true);
196 | } else {
197 | // If there are comments, sort them and put them in the list.
198 | var comments = sortComments(data.comments);
199 | speed = data.comments.length * 100;
200 | appendComments(comments, ul);
201 | ul.data('empty', false);
202 | }
203 | $('#cn' + id).slideUp(speed + 200);
204 | ul.slideDown(speed);
205 | },
206 | error: function(request, textStatus, error) {
207 | showError('Oops, there was a problem retrieving the comments.');
208 | },
209 | dataType: 'json'
210 | });
211 | }
212 |
213 | /**
214 | * Add a comment via ajax and insert the comment into the comment tree.
215 | */
216 | function addComment(form) {
217 | var node_id = form.find('input[name="node"]').val();
218 | var parent_id = form.find('input[name="parent"]').val();
219 | var text = form.find('textarea[name="comment"]').val();
220 | var proposal = form.find('textarea[name="proposal"]').val();
221 |
222 | if (text == '') {
223 | showError('Please enter a comment.');
224 | return;
225 | }
226 |
227 | // Disable the form that is being submitted.
228 | form.find('textarea,input').attr('disabled', 'disabled');
229 |
230 | // Send the comment to the server.
231 | $.ajax({
232 | type: "POST",
233 | url: opts.addCommentURL,
234 | dataType: 'json',
235 | data: {
236 | node: node_id,
237 | parent: parent_id,
238 | text: text,
239 | proposal: proposal
240 | },
241 | success: function(data, textStatus, error) {
242 | // Reset the form.
243 | if (node_id) {
244 | hideProposeChange(node_id);
245 | }
246 | form.find('textarea')
247 | .val('')
248 | .add(form.find('input'))
249 | .removeAttr('disabled');
250 | var ul = $('#cl' + (node_id || parent_id));
251 | if (ul.data('empty')) {
252 | $(ul).empty();
253 | ul.data('empty', false);
254 | }
255 | insertComment(data.comment);
256 | var ao = $('#ao' + node_id);
257 | ao.find('img').attr({'src': opts.commentBrightImage});
258 | if (node_id) {
259 | // if this was a "root" comment, remove the commenting box
260 | // (the user can get it back by reopening the comment popup)
261 | $('#ca' + node_id).slideUp();
262 | }
263 | },
264 | error: function(request, textStatus, error) {
265 | form.find('textarea,input').removeAttr('disabled');
266 | showError('Oops, there was a problem adding the comment.');
267 | }
268 | });
269 | }
270 |
271 | /**
272 | * Recursively append comments to the main comment list and children
273 | * lists, creating the comment tree.
274 | */
275 | function appendComments(comments, ul) {
276 | $.each(comments, function() {
277 | var div = createCommentDiv(this);
278 | ul.append($(document.createElement('li')).html(div));
279 | appendComments(this.children, div.find('ul.comment-children'));
280 | // To avoid stagnating data, don't store the comments children in data.
281 | this.children = null;
282 | div.data('comment', this);
283 | });
284 | }
285 |
286 | /**
287 | * After adding a new comment, it must be inserted in the correct
288 | * location in the comment tree.
289 | */
290 | function insertComment(comment) {
291 | var div = createCommentDiv(comment);
292 |
293 | // To avoid stagnating data, don't store the comments children in data.
294 | comment.children = null;
295 | div.data('comment', comment);
296 |
297 | var ul = $('#cl' + (comment.node || comment.parent));
298 | var siblings = getChildren(ul);
299 |
300 | var li = $(document.createElement('li'));
301 | li.hide();
302 |
303 | // Determine where in the parents children list to insert this comment.
304 | for(i=0; i < siblings.length; i++) {
305 | if (comp(comment, siblings[i]) <= 0) {
306 | $('#cd' + siblings[i].id)
307 | .parent()
308 | .before(li.html(div));
309 | li.slideDown('fast');
310 | return;
311 | }
312 | }
313 |
314 | // If we get here, this comment rates lower than all the others,
315 | // or it is the only comment in the list.
316 | ul.append(li.html(div));
317 | li.slideDown('fast');
318 | }
319 |
320 | function acceptComment(id) {
321 | $.ajax({
322 | type: 'POST',
323 | url: opts.acceptCommentURL,
324 | data: {id: id},
325 | success: function(data, textStatus, request) {
326 | $('#cm' + id).fadeOut('fast');
327 | $('#cd' + id).removeClass('moderate');
328 | },
329 | error: function(request, textStatus, error) {
330 | showError('Oops, there was a problem accepting the comment.');
331 | }
332 | });
333 | }
334 |
335 | function deleteComment(id) {
336 | $.ajax({
337 | type: 'POST',
338 | url: opts.deleteCommentURL,
339 | data: {id: id},
340 | success: function(data, textStatus, request) {
341 | var div = $('#cd' + id);
342 | if (data == 'delete') {
343 | // Moderator mode: remove the comment and all children immediately
344 | div.slideUp('fast', function() {
345 | div.remove();
346 | });
347 | return;
348 | }
349 | // User mode: only mark the comment as deleted
350 | div
351 | .find('span.user-id:first')
352 | .text('[deleted]').end()
353 | .find('div.comment-text:first')
354 | .text('[deleted]').end()
355 | .find('#cm' + id + ', #dc' + id + ', #ac' + id + ', #rc' + id +
356 | ', #sp' + id + ', #hp' + id + ', #cr' + id + ', #rl' + id)
357 | .remove();
358 | var comment = div.data('comment');
359 | comment.username = '[deleted]';
360 | comment.text = '[deleted]';
361 | div.data('comment', comment);
362 | },
363 | error: function(request, textStatus, error) {
364 | showError('Oops, there was a problem deleting the comment.');
365 | }
366 | });
367 | }
368 |
369 | function showProposal(id) {
370 | $('#sp' + id).hide();
371 | $('#hp' + id).show();
372 | $('#pr' + id).slideDown('fast');
373 | }
374 |
375 | function hideProposal(id) {
376 | $('#hp' + id).hide();
377 | $('#sp' + id).show();
378 | $('#pr' + id).slideUp('fast');
379 | }
380 |
381 | function showProposeChange(id) {
382 | $('#pc' + id).hide();
383 | $('#hc' + id).show();
384 | var textarea = $('#pt' + id);
385 | textarea.val(textarea.data('source'));
386 | $.fn.autogrow.resize(textarea[0]);
387 | textarea.slideDown('fast');
388 | }
389 |
390 | function hideProposeChange(id) {
391 | $('#hc' + id).hide();
392 | $('#pc' + id).show();
393 | var textarea = $('#pt' + id);
394 | textarea.val('').removeAttr('disabled');
395 | textarea.slideUp('fast');
396 | }
397 |
398 | function toggleCommentMarkupBox(id) {
399 | $('#mb' + id).toggle();
400 | }
401 |
402 | /** Handle when the user clicks on a sort by link. */
403 | function handleReSort(link) {
404 | var classes = link.attr('class').split(/\s+/);
405 | for (var i=0; iThank you! Your comment will show up '
558 | + 'once it is has been approved by a moderator.');
559 | }
560 | // Prettify the comment rating.
561 | comment.pretty_rating = comment.rating + ' point' +
562 | (comment.rating == 1 ? '' : 's');
563 | // Make a class (for displaying not yet moderated comments differently)
564 | comment.css_class = comment.displayed ? '' : ' moderate';
565 | // Create a div for this comment.
566 | var context = $.extend({}, opts, comment);
567 | var div = $(renderTemplate(commentTemplate, context));
568 |
569 | // If the user has voted on this comment, highlight the correct arrow.
570 | if (comment.vote) {
571 | var direction = (comment.vote == 1) ? 'u' : 'd';
572 | div.find('#' + direction + 'v' + comment.id).hide();
573 | div.find('#' + direction + 'u' + comment.id).show();
574 | }
575 |
576 | if (opts.moderator || comment.text != '[deleted]') {
577 | div.find('a.reply').show();
578 | if (comment.proposal_diff)
579 | div.find('#sp' + comment.id).show();
580 | if (opts.moderator && !comment.displayed)
581 | div.find('#cm' + comment.id).show();
582 | if (opts.moderator || (opts.username == comment.username))
583 | div.find('#dc' + comment.id).show();
584 | }
585 | return div;
586 | }
587 |
588 | /**
589 | * A simple template renderer. Placeholders such as <%id%> are replaced
590 | * by context['id'] with items being escaped. Placeholders such as <#id#>
591 | * are not escaped.
592 | */
593 | function renderTemplate(template, context) {
594 | var esc = $(document.createElement('div'));
595 |
596 | function handle(ph, escape) {
597 | var cur = context;
598 | $.each(ph.split('.'), function() {
599 | cur = cur[this];
600 | });
601 | return escape ? esc.text(cur || "").html() : cur;
602 | }
603 |
604 | return template.replace(/<([%#])([\w\.]*)\1>/g, function() {
605 | return handle(arguments[2], arguments[1] == '%' ? true : false);
606 | });
607 | }
608 |
609 | /** Flash an error message briefly. */
610 | function showError(message) {
611 | $(document.createElement('div')).attr({'class': 'popup-error'})
612 | .append($(document.createElement('div'))
613 | .attr({'class': 'error-message'}).text(message))
614 | .appendTo('body')
615 | .fadeIn("slow")
616 | .delay(2000)
617 | .fadeOut("slow");
618 | }
619 |
620 | /** Add a link the user uses to open the comments popup. */
621 | $.fn.comment = function() {
622 | return this.each(function() {
623 | var id = $(this).attr('id').substring(1);
624 | var count = COMMENT_METADATA[id];
625 | var title = count + ' comment' + (count == 1 ? '' : 's');
626 | var image = count > 0 ? opts.commentBrightImage : opts.commentImage;
627 | var addcls = count == 0 ? ' nocomment' : '';
628 | $(this)
629 | .append(
630 | $(document.createElement('a')).attr({
631 | href: '#',
632 | 'class': 'sphinx-comment-open' + addcls,
633 | id: 'ao' + id
634 | })
635 | .append($(document.createElement('img')).attr({
636 | src: image,
637 | alt: 'comment',
638 | title: title
639 | }))
640 | .click(function(event) {
641 | event.preventDefault();
642 | show($(this).attr('id').substring(2));
643 | })
644 | )
645 | .append(
646 | $(document.createElement('a')).attr({
647 | href: '#',
648 | 'class': 'sphinx-comment-close hidden',
649 | id: 'ah' + id
650 | })
651 | .append($(document.createElement('img')).attr({
652 | src: opts.closeCommentImage,
653 | alt: 'close',
654 | title: 'close'
655 | }))
656 | .click(function(event) {
657 | event.preventDefault();
658 | hide($(this).attr('id').substring(2));
659 | })
660 | );
661 | });
662 | };
663 |
664 | var opts = {
665 | processVoteURL: '/_process_vote',
666 | addCommentURL: '/_add_comment',
667 | getCommentsURL: '/_get_comments',
668 | acceptCommentURL: '/_accept_comment',
669 | deleteCommentURL: '/_delete_comment',
670 | commentImage: '/static/_static/comment.png',
671 | closeCommentImage: '/static/_static/comment-close.png',
672 | loadingImage: '/static/_static/ajax-loader.gif',
673 | commentBrightImage: '/static/_static/comment-bright.png',
674 | upArrow: '/static/_static/up.png',
675 | downArrow: '/static/_static/down.png',
676 | upArrowPressed: '/static/_static/up-pressed.png',
677 | downArrowPressed: '/static/_static/down-pressed.png',
678 | voting: false,
679 | moderator: false
680 | };
681 |
682 | if (typeof COMMENT_OPTIONS != "undefined") {
683 | opts = jQuery.extend(opts, COMMENT_OPTIONS);
684 | }
685 |
686 | var popupTemplate = '\
687 | ';
723 |
724 | var commentTemplate = '\
725 | \
768 | ';
769 |
770 | var replyTemplate = '\
771 | \
772 | \
773 | \
780 |
\
781 | ';
782 |
783 | $(document).ready(function() {
784 | init();
785 | });
786 | })(jQuery);
787 |
788 | $(document).ready(function() {
789 | // add comment anchors for all paragraphs that are commentable
790 | $('.sphinx-has-comment').comment();
791 |
792 | // highlight search words in search results
793 | $("div.context").each(function() {
794 | var params = $.getQueryParameters();
795 | var terms = (params.q) ? params.q[0].split(/\s+/) : [];
796 | var result = $(this);
797 | $.each(terms, function() {
798 | result.highlightText(this.toLowerCase(), 'highlighted');
799 | });
800 | });
801 |
802 | // directly open comment window if requested
803 | var anchor = document.location.hash;
804 | if (anchor.substring(0, 9) == '#comment-') {
805 | $('#ao' + anchor.substring(9)).click();
806 | document.location.hash = '#s' + anchor.substring(9);
807 | }
808 | });
809 |
--------------------------------------------------------------------------------
/docs/conf.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | #
3 | # hts-python documentation build configuration file, created by
4 | # sphinx-quickstart on Fri Mar 3 08:37:08 2017.
5 | #
6 | # This file is execfile()d with the current directory set to its
7 | # containing dir.
8 | #
9 | # Note that not all possible configuration values are present in this
10 | # autogenerated file.
11 | #
12 | # All configuration values have a default; values that are commented out
13 | # serve to show the default.
14 |
15 | # If extensions (or modules to document with autodoc) are in another directory,
16 | # add these directories to sys.path here. If the directory is relative to the
17 | # documentation root, use os.path.abspath to make it absolute, like shown here.
18 | #
19 | # import os
20 | # import sys
21 | # sys.path.insert(0, os.path.abspath('.'))
22 |
23 |
24 | # -- General configuration ------------------------------------------------
25 |
26 | # If your documentation needs a minimal Sphinx version, state it here.
27 | #
28 | # needs_sphinx = '1.0'
29 |
30 | # Add any Sphinx extension module names here, as strings. They can be
31 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
32 | # ones.
33 | extensions = [
34 | 'sphinx.ext.autodoc',
35 | 'sphinx.ext.todo',
36 | 'sphinx.ext.viewcode',
37 | 'sphinx.ext.githubpages',
38 | 'sphinx.ext.napoleon']
39 |
40 | # Add any paths that contain templates here, relative to this directory.
41 | templates_path = ['_templates']
42 |
43 | # The suffix(es) of source filenames.
44 | # You can specify multiple suffix as a list of string:
45 | #
46 | # source_suffix = ['.rst', '.md']
47 | source_suffix = '.rst'
48 |
49 | # The master toctree document.
50 | master_doc = 'index'
51 |
52 | # General information about the project.
53 | project = u'hts-python'
54 | copyright = u'2017, Brent Pedersen'
55 | author = u'Brent Pedersen'
56 |
57 | # The version info for the project you're documenting, acts as replacement for
58 | # |version| and |release|, also used in various other places throughout the
59 | # built documents.
60 | #
61 | # The short X.Y version.
62 | version = u'0.1'
63 | # The full version, including alpha/beta/rc tags.
64 | release = u'0.1'
65 |
66 | # The language for content autogenerated by Sphinx. Refer to documentation
67 | # for a list of supported languages.
68 | #
69 | # This is also used if you do content translation via gettext catalogs.
70 | # Usually you set "language" from the command line for these cases.
71 | language = None
72 |
73 | # List of patterns, relative to source directory, that match files and
74 | # directories to ignore when looking for source files.
75 | # This patterns also effect to html_static_path and html_extra_path
76 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
77 |
78 | # The name of the Pygments (syntax highlighting) style to use.
79 | pygments_style = 'sphinx'
80 |
81 | # If true, `todo` and `todoList` produce output, else they produce nothing.
82 | todo_include_todos = True
83 |
84 |
85 | # -- Options for HTML output ----------------------------------------------
86 |
87 | # The theme to use for HTML and HTML Help pages. See the documentation for
88 | # a list of builtin themes.
89 | #
90 | html_theme = 'alabaster'
91 |
92 | # Theme options are theme-specific and customize the look and feel of a theme
93 | # further. For a list of options available for each theme, see the
94 | # documentation.
95 | #
96 | # html_theme_options = {}
97 |
98 | # Add any paths that contain custom static files (such as style sheets) here,
99 | # relative to this directory. They are copied after the builtin static files,
100 | # so a file named "default.css" will overwrite the builtin "default.css".
101 | html_static_path = ['_static']
102 |
103 |
104 | # -- Options for HTMLHelp output ------------------------------------------
105 |
106 | # Output file base name for HTML help builder.
107 | htmlhelp_basename = 'hts-pythondoc'
108 |
109 |
110 | # -- Options for LaTeX output ---------------------------------------------
111 |
112 | latex_elements = {
113 | # The paper size ('letterpaper' or 'a4paper').
114 | #
115 | # 'papersize': 'letterpaper',
116 |
117 | # The font size ('10pt', '11pt' or '12pt').
118 | #
119 | # 'pointsize': '10pt',
120 |
121 | # Additional stuff for the LaTeX preamble.
122 | #
123 | # 'preamble': '',
124 |
125 | # Latex figure (float) alignment
126 | #
127 | # 'figure_align': 'htbp',
128 | }
129 |
130 | # Grouping the document tree into LaTeX files. List of tuples
131 | # (source start file, target name, title,
132 | # author, documentclass [howto, manual, or own class]).
133 | latex_documents = [
134 | (master_doc, 'hts-python.tex', u'hts-python Documentation',
135 | u'Brent Pedersen', 'manual'),
136 | ]
137 |
138 |
139 | # -- Options for manual page output ---------------------------------------
140 |
141 | # One entry per manual page. List of tuples
142 | # (source start file, name, description, authors, manual section).
143 | man_pages = [
144 | (master_doc, 'hts-python', u'hts-python Documentation',
145 | [author], 1)
146 | ]
147 |
148 |
149 | # -- Options for Texinfo output -------------------------------------------
150 |
151 | # Grouping the document tree into Texinfo files. List of tuples
152 | # (source start file, target name, title, author,
153 | # dir menu entry, description, category)
154 | texinfo_documents = [
155 | (master_doc, 'hts-python', u'hts-python Documentation',
156 | author, 'hts-python', 'One line description of project.',
157 | 'Miscellaneous'),
158 | ]
159 |
160 |
161 |
162 |
--------------------------------------------------------------------------------
/docs/genindex.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | Index — hts-python 0.1 documentation
11 |
12 |
13 |
14 |
15 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
Index
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
79 |
80 |
81 |
89 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | hts-python — hts-python 0.1 documentation
10 |
11 |
12 |
13 |
14 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
hts-python
46 |
hts-python is a pythonic wrapper for htslib using python cffi .
47 |
A taste of hts-python...
48 |
>>> import os.path as op
49 |
50 | >>> from hts import Bam
51 | >>> bam = Bam ( "hts/test/small.bam" )
52 | >>> list ( bam . header . seqs )
53 | ['chr2L', 'chr2R', 'chr3L', 'chr3R', 'chr4', 'chrX']
54 |
55 | >>> a = next ( bam ( 'chr2L:9000-11000' ))
56 | >>> a
57 | Alignment('HWUSI-NAME:2:69:512:1017#0')
58 | >>> a . target , a . pos , a . strand
59 | ('chr2L', 9329, '-')
60 | >>> a . qlen , a . rlen
61 | (36, 36)
62 | >>> a . strand
63 | '-'
64 | >>> a . seq
65 | 'TACAAATCTTACGTAAACACTCCAAGCATGAATTCG'
66 | >>> a . qual [: 10 ]
67 | [56, 63, 53, 62, 64, 62, 51, 44, 58, 59]
68 |
69 | >>> a . flag , a . flag_str
70 | (16, 'REVERSE')
71 |
72 | >>> a . cigar
73 | Cigar('36M')
74 |
75 | >>> str ( a )[: 40 ]
76 | 'HWUSI-NAME:2:69:512:1017#0\t16\tchr2L\t9330'
77 |
78 |
79 |
80 |
81 |
See Also
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
123 |
124 |
125 |
136 |
137 |
138 |
139 |
140 |
141 |
--------------------------------------------------------------------------------
/docs/index.rst:
--------------------------------------------------------------------------------
1 | .. hts-python documentation master file, created by
2 | sphinx-quickstart on Wed Mar 1 09:40:03 2017.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | hts-python
7 | ==========
8 |
9 | hts-python is a pythonic wrapper for `htslib `_ using python `cffi `_.
10 |
11 | A taste of hts-python...
12 |
13 | .. code-block:: python
14 |
15 | >>> import os.path as op
16 |
17 | >>> from hts import Bam
18 | >>> bam = Bam("hts/test/small.bam")
19 | >>> list(bam.header.seqs)
20 | ['chr2L', 'chr2R', 'chr3L', 'chr3R', 'chr4', 'chrX']
21 |
22 | >>> a = next(bam('chr2L:9000-11000'))
23 | >>> a
24 | Alignment('HWUSI-NAME:2:69:512:1017#0')
25 | >>> a.target, a.pos, a.strand
26 | ('chr2L', 9329, '-')
27 | >>> a.qlen, a.rlen
28 | (36, 36)
29 | >>> a.strand
30 | '-'
31 | >>> a.seq
32 | 'TACAAATCTTACGTAAACACTCCAAGCATGAATTCG'
33 | >>> a.qual[:10]
34 | [56, 63, 53, 62, 64, 62, 51, 44, 58, 59]
35 |
36 | >>> a.flag, a.flag_str
37 | (16, 'REVERSE')
38 |
39 | >>> a.cigar
40 | Cigar('36M')
41 |
42 | >>> str(a)[:40]
43 | 'HWUSI-NAME:2:69:512:1017#0\t16\tchr2L\t9330'
44 |
45 | See Also
46 | ========
47 |
48 | .. toctree::
49 | :maxdepth: 2
50 |
51 |
--------------------------------------------------------------------------------
/docs/objects.inv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brentp/hts-python/d27f873f7e8e770f6afd5630beb253edc2f7ca05/docs/objects.inv
--------------------------------------------------------------------------------
/docs/search.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Search — hts-python 0.1 documentation
10 |
11 |
12 |
13 |
14 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
Search
53 |
54 |
55 |
56 | Please activate JavaScript to enable the search
57 | functionality.
58 |
59 |
60 |
61 | From here you can search these documents. Enter your search
62 | words into the box below and click "search". Note that the search
63 | function will automatically search for all of the words. Pages
64 | containing fewer words won't appear in the result list.
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
89 |
90 |
91 |
99 |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/docs/searchindex.js:
--------------------------------------------------------------------------------
1 | Search.setIndex({docnames:["index"],envversion:50,filenames:["index.rst"],objects:{},objnames:{},objtypes:{},terms:{"36m":0,"import":0,align:0,bam:0,cffi:0,chr2l:0,chr2r:0,chr3l:0,chr3r:0,chr4:0,chrx:0,cigar:0,flag:0,flag_str:0,from:0,header:0,htslib:0,hwusi:0,index:[],list:0,modul:[],name:0,next:0,page:[],path:0,pos:0,pybedtool:[],qlen:0,qual:0,revers:0,rlen:0,search:[],seq:0,small:0,stolen:[],str:0,strand:0,t16:0,t9330:0,tacaaatcttacgtaaacactccaagcatgaattcg:0,target:0,tast:0,tchr2l:0,test:0,thank:[],using:0,wrapper:0},titles:["hts-python"],titleterms:{also:0,document:[],hts:0,indic:[],python:0,see:0,tabl:[],welcom:[]}})
--------------------------------------------------------------------------------
/hts/__init__.py:
--------------------------------------------------------------------------------
1 | from .fai import Fai
2 | from .tbx import Tbx
3 | from .bam import Bam
4 | from .vcf import VCF
5 | from .fisher import fisher_exact_test
6 |
7 | __version__ = "0.0.3"
8 |
9 |
10 | def doctests():
11 | import doctest
12 | import hts.htsffi
13 | for name, mod in (("htsffi", hts.htsffi),
14 | ("fai", hts.fai),
15 | ("fisher", hts.fisher),
16 | ("vcf", hts.vcf),
17 | ("bam", hts.bam)):
18 |
19 | mod = getattr(hts, name)
20 | print("%s: %r" % (name, doctest.testmod(m=mod,
21 | optionflags=doctest.REPORT_ONLY_FIRST_FAILURE)))
22 |
--------------------------------------------------------------------------------
/hts/bam.py:
--------------------------------------------------------------------------------
1 | from __future__ import print_function
2 | from .htsffi import libhts, ffi, _raise_if_null
3 | import atexit
4 | import os.path as op
5 | import sys
6 |
7 | class BamHeader(object):
8 | def __init__(self, h):
9 | self._h = h
10 |
11 | @property
12 | def seqs(self):
13 | for i in range(self._h.n_targets):
14 | yield ffi.string(self._h.target_name[i])
15 |
16 | class Cigar(object):
17 |
18 | """
19 | A cigar object usually created from `Alignment`.
20 |
21 | Takes the uin32_t * from bam_get_cigar()
22 |
23 | """
24 |
25 | ops = "MIDNSHP=XB"
26 |
27 | # cigar is the uint32_t * from bam_get_cigar()
28 | def __init__(self, cigar, n_cigar):
29 | self._c = cigar
30 | self.n_cigar = n_cigar
31 | def __str__(self):
32 | """Str."""
33 | cig, s = self._c, []
34 | for k in range(self.n_cigar):
35 | s.extend((str(libhts.bam_cigar_oplen(cig[k])),
36 | libhts.bam_cigar_opchr(cig[k])))
37 | return "".join(s)
38 |
39 | def __repr__(self):
40 | """repr."""
41 | return "Cigar('%s')" % str(self)
42 |
43 | class Alignment(object):
44 |
45 | """Alignment object; usually created by iterating over a `Bam` object."""
46 | __slots__ = ("_b", "_h")
47 |
48 | def __init__(self, bam1_t, bam_hdr_t):
49 | self._b = bam1_t
50 | self._h = bam_hdr_t
51 |
52 | def copy(self):
53 | """Create a copy of the alignment for modification or storage."""
54 | b = libhts.bam_dup1(self._b)
55 | atexit.register(libhts.bam_destroy1, b)
56 | return Alignment(b, self._h)
57 |
58 | @property
59 | def tags(self):
60 | """The auxillary tags from the alignment."""
61 | auxs = []
62 | l = libhts.bam_get_l_aux(self._b)
63 | if not l : return None
64 |
65 | s_aux_ptr = libhts.bam_get_aux(self._b)
66 | i = 0
67 | func = {'Z':libhts.bam_aux2Z, 'A': libhts.bam_aux2Z,
68 | 'i': libhts.bam_aux2i,
69 | 'I': libhts.bam_aux2i,
70 | 'c': libhts.bam_aux2i,
71 | 'C': libhts.bam_aux2i,
72 | 'f': libhts.bam_aux2f,
73 | 'F': libhts.bam_aux2f,
74 | 's': libhts.bam_aux2i,
75 | 'S': libhts.bam_aux2i}
76 |
77 | #print(str(self), file=sys.stderr)
78 | while i < l:
79 | key = "".join(chr(s) for s in s_aux_ptr[i:i + 2])
80 | ftype = chr(s_aux_ptr[i + 2])
81 | val = func[ftype](s_aux_ptr[i + 2:i + 2])
82 | if ftype in 'ZA':
83 | val = ffi.string(val)
84 | auxs.append((key, ftype, val))
85 | i += 3 + libhts.skip_aux(s_aux_ptr[i + 2:l])
86 |
87 | return auxs
88 |
89 | def adjust_overlap_quality(self, other):
90 | """
91 | Adjust base-quality of overlapping reads.
92 |
93 | For paired-end reads, we may not want to double-count both ends.
94 | This function will set (in-place), the base-quality of `other` to
95 | 0 and self to other + self for any overlapping bases.
96 | If bases are not equal then quality of self is set to 80% of its
97 | original value.
98 | """
99 | libhts.tweak_overlap_quality(self._b, other._b)
100 |
101 | @property
102 | def qname(self):
103 | """Read (query) name."""
104 | return ffi.string(libhts.bam_get_qname(self._b))
105 |
106 | @qname.setter
107 | def qname(self, name):
108 | """Set (query) name."""
109 | raise NotImplemented
110 | # need to check if proposed name is longer/shorter
111 | # than current and calloc self._b.data based on that!!!
112 | current_name = libhts.bam_get_qname(self._b)
113 |
114 | @property
115 | def rnext(self):
116 | tid = self._b.core.mtid
117 | if tid == -1:
118 | return None
119 | return ffi.string(self._h.target_name[tid])
120 |
121 | mate_chrom = rnext
122 |
123 | @property
124 | def pnext(self):
125 | return self._b.core.mpos
126 |
127 | mate_chrom = pnext
128 |
129 | @classmethod
130 | def from_sam_str(cls, sam_str, bam_hdr):
131 | s = ffi.new('kstring_t *', {'m': 0, 'l': 0, 's': ffi.NULL})
132 | libhts.kputsn(sam_str, len(sam_str) + 1, s)
133 |
134 | b = libhts.bam_init1()
135 | res = libhts.sam_parse1(s, bam_hdr, b)
136 | assert res <= 0, ("SAM parse error", res)
137 | h2 = libhts.bam_hdr_dup(bam_hdr)
138 | return Alignment(b, h2)
139 |
140 | @property
141 | def rname(self):
142 | """Chromosome or sequence aligned to."""
143 | tid = self._b.core.tid
144 | if tid == -1: # Read is unaligned, have no target
145 | return None
146 |
147 | return ffi.string(self._h.target_name[tid])
148 | target = rname
149 |
150 |
151 | @property
152 | def strand(self):
153 | """Strand of alignment."""
154 | return "-" if libhts.bam_is_rev(self._b) else "+"
155 |
156 | @property
157 | def base_qualities(self):
158 | """Base-qualities of query sequence."""
159 | q_ptr = libhts.bam_get_qual(self._b)
160 | has_qual = q_ptr[0] != 0xff
161 | if not has_qual: return None
162 | return [q_ptr[i] for i in range(self._b.core.l_qseq)]
163 |
164 | qual = base_qualities
165 |
166 | @property
167 | def pos(self):
168 | """Left-most position of alignment."""
169 | return self._b.core.pos
170 |
171 | @pos.setter
172 | def pos(self, value):
173 | """Set the position."""
174 | self._b.core.pos = value
175 |
176 | @property
177 | def isize(self):
178 | """Insert size of alignment if applicable."""
179 | return self._b.core.isize
180 | tlen = isize
181 |
182 | @property
183 | def mapping_quality(self):
184 | """Mapping quality of alignment."""
185 | return self._b.core.qual
186 |
187 | @mapping_quality.setter
188 | def mapping_quality(self, value):
189 | """Set the mapping quality to a new value."""
190 | self._b.core.qual = value
191 |
192 | mapq = mapping_quality
193 |
194 | @property
195 | def cigar(self):
196 | """Cigar object of alignment."""
197 | return Cigar(libhts.bam_get_cigar(self._b), self._b.core.n_cigar)
198 |
199 | @property
200 | def qlen(self):
201 | """Length of alignment by query."""
202 | return libhts.bam_cigar2qlen(self._b.core.n_cigar,
203 | libhts.bam_get_cigar(self._b))
204 |
205 | @property
206 | def rlen(self):
207 | """Length of alignment on reference."""
208 | return libhts.bam_cigar2rlen(self._b.core.n_cigar,
209 | libhts.bam_get_cigar(self._b))
210 |
211 | @property
212 | def seq(self):
213 | """Nucleotide sequence of read."""
214 | kstr = ffi.new('kstring_t *', {'m': 0, 'l': 0, 's': ffi.NULL})
215 | r = libhts.bam_get_read_seq(self._b, kstr)
216 | assert r == kstr.l, (r, kstr.l)
217 | return ffi.string(kstr.s)
218 |
219 | @property
220 | def flag_str(self):
221 | """Alignment flag as a string."""
222 | return ffi.string(libhts.bam_flag2str(self.flag))
223 |
224 | @property
225 | def flag(self):
226 | """Alignment flag."""
227 | return self._b.core.flag
228 |
229 | def __eq__(self, other):
230 | """test equality."""
231 | if self.qname != other.qname: return False
232 | if (self.pos, self.seq, self.mapq, self.qname) == \
233 | (other.pos, other.seq, other.mapq, other.qname):
234 | return True
235 | return False
236 |
237 | def __repr__(self):
238 | """repr of aln."""
239 | return "%s('%s')" % (self.__class__.__name__, self.qname)
240 |
241 | def __str__(self):
242 | """str of aln."""
243 | s = ffi.new("kstring_t *")
244 | l = libhts.sam_format1(self._h, self._b, s)
245 | return ffi.string(s.s, l)
246 |
247 | class Bam(object):
248 |
249 | r"""
250 | A BAM class with properties that call the C-API.
251 |
252 | Parameters
253 | ----------
254 |
255 | fname : string
256 | file name of bam
257 |
258 | mode : string
259 | mode for opening file r/w
260 |
261 | create_index: bool, string, optional
262 | if True, then force create index. If "auto", then only create index
263 | if it doesn't exist
264 |
265 | header: bam_hdr_t * or str
266 | ffi bam_hdr_t object for use when mode == "w"
267 | or a SAM header string.
268 |
269 | Examples
270 | --------
271 |
272 | >>> import os.path as op
273 | >>> bam = Bam("%s/test/small.bam" % op.dirname(__file__))
274 | >>> next(bam)
275 | Alignment('HWUSI-NAME:2:69:512:1017#0')
276 | >>> region_iter = bam('chr2L:9000-11000')
277 | >>> a = next(region_iter)
278 |
279 | # save copy for later test.
280 | >>> asav = a.copy()
281 |
282 | >>> list(bam.header.seqs)
283 | ['chr2L', 'chr2R', 'chr3L', 'chr3R', 'chr4', 'chrX']
284 |
285 |
286 | Query a specific Region
287 | >>> a
288 | Alignment('HWUSI-NAME:2:69:512:1017#0')
289 | >>> a.qname
290 | 'HWUSI-NAME:2:69:512:1017#0'
291 | >>> a.target
292 | 'chr2L'
293 |
294 | >>> a.cigar
295 | Cigar('36M')
296 | >>> a.qlen, a.rlen
297 | (36, 36)
298 |
299 | >>> a.strand
300 | '-'
301 |
302 | >>> a.seq
303 | 'TACAAATCTTACGTAAACACTCCAAGCATGAATTCG'
304 | >>> b = next(region_iter)
305 |
306 | >>> b.seq
307 | 'TGTAGAATGCAAAAATTACATTTGTGAGTATCATCA'
308 |
309 | # NOTE that a.seq has changed. this is because we updated the underlying
310 | # pointer and htslib assumes streaming stuff.
311 | >>> a.seq
312 | 'TGTAGAATGCAAAAATTACATTTGTGAGTATCATCA'
313 |
314 | # We can use the copy to avoid these problems:
315 | >>> asav.seq
316 | 'TACAAATCTTACGTAAACACTCCAAGCATGAATTCG'
317 | >>> a = asav
318 |
319 | # in the future, we may default to copy semantics or allow that to be specified
320 | # when creating a BAM.
321 |
322 | >>> a.flag, a.flag_str
323 | (16, 'REVERSE')
324 | >>> a.base_qualities[:10]
325 | [56, 63, 53, 62, 64, 62, 51, 44, 58, 59]
326 |
327 | >>> a.mapping_quality # or a.mapq
328 | 3
329 | >>> a.pos
330 | 9329
331 |
332 | >>> a.isize
333 | 0
334 |
335 | >>> str(a)
336 | 'HWUSI-NAME:2:69:512:1017#0\t16\tchr2L\t9330\t3\t36M\t*\t0\t0\tTACAAATCTTACGTAAACACTCCAAGCATGAATTCG\tY`V_a_TM[\\_V`abb`^^Q]QZaaaaa_aaaaaaa\tNM:i:0\tNH:i:2\tCC:Z:chrX\tCP:i:19096815'
337 |
338 | >>> a.tags
339 | [('NM', 'C', 0), ('NH', 'C', 2), ('CC', 'Z', 'chrX'), ('CP', 'I', 19096815)]
340 |
341 | >>> a.base_qualities[:10]
342 | [56, 63, 53, 62, 64, 62, 51, 44, 58, 59]
343 |
344 | # for paired end reads, we may want to avoid double-counting
345 | # the overlapping regions. We can use the samtools algorithm
346 | # to give a, the base-quality of a + b when the sequence is
347 | # the same or 0.8 * a when the seq is different. In either case,
348 | # the base-quality of b is set to 0.
349 | >>> b = a.copy()
350 |
351 | >>> a.adjust_overlap_quality(b)
352 | >>> a.base_qualities[:10]
353 | [112, 126, 106, 124, 128, 124, 102, 88, 116, 118]
354 |
355 | >>> b.base_qualities[:10]
356 | [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
357 |
358 | >>> all(bq == 0 for bq in b.base_qualities)
359 | True
360 |
361 | Writing.
362 |
363 | >>> out = Bam('out.bam', 'wb', header=a._h)
364 | >>> c = next(region_iter)
365 | >>> out.write(c, a, b); out.close()
366 |
367 | >>> cnew = next(Bam('out.bam'))
368 | >>> cnew.seq == c.seq
369 | True
370 |
371 | >>> (cnew == c, b.qname == a.qname)
372 | (True, True)
373 |
374 | we can also create a new writable bam with a fasta to create the bam header:
375 | >>> outf = Bam('outf.bam', mode='wb', fasta="hts/test/t2.fa")
376 |
377 | >>> outf.write(a); outf.close()
378 | >>> b = Bam('outf.bam')
379 | >>> b
380 | Bam('outf.bam', 'r')
381 |
382 | >>> next(b) == a
383 | True
384 |
385 |
386 | >>> a.pos
387 | 9329
388 | >>> a.pos += 1
389 | >>> a.pos
390 | 9330
391 |
392 | >>> assert a.mapq == 3
393 | >>> a.mapq += 55
394 | >>> assert a.mapping_quality == 58
395 |
396 | >>> a.rnext, a.pnext # no mate
397 | (None, -1)
398 |
399 | # string to object back to string.
400 | >>> s = str(a)
401 | >>> c = Alignment.from_sam_str(s, a._h)
402 | >>> str(c) == s
403 | True
404 |
405 | #>>> a.qname == "HELLO"
406 | #>>> assert "HELLO" in str(a)
407 | """
408 |
409 | def __init__(self, fname, mode="r", create_index="auto", header=None, fasta=None):
410 | self.fn, self.mode = fname, mode
411 |
412 | htf = self._htf = libhts.hts_open(fname, mode)
413 | _raise_if_null(htf, "Bam: bad file %s" % fname)
414 |
415 | if mode[0] == "r":
416 |
417 | idx = self._idx = libhts.sam_index_load(self._htf, fname)
418 | if (idx == ffi.NULL and create_index == "auto") or create_index is True:
419 | libhts.bam_index_build(fname, -1)
420 | idx = self._idx = libhts.sam_index_load(self._htf, fname)
421 | if idx == ffi.NULL:
422 | # no querying.
423 | print("NO querying", file=sys.stderr)
424 | pass
425 |
426 | self.header = BamHeader(libhts.sam_hdr_read(htf))
427 | b = self._b = libhts.bam_init1()
428 | atexit.register(libhts.bam_destroy1, b)
429 |
430 | else:
431 | assert mode[0] == "w" and (header or fasta)
432 | if hasattr(header, "_h"):
433 | header = header._h
434 | elif fasta:
435 | assert op.exists(fasta) # it's a fasta file.
436 | header_str = Bam.header_from_fasta(fasta)
437 | header = libhts.sam_hdr_parse(len(header_str), header_str)
438 | header.l_text = len(header_str)
439 | header.text = ffi.new("char[]", header_str)
440 |
441 | self.header = header
442 | libhts.sam_hdr_write(self._htf, self.header);
443 |
444 | def __repr__(self):
445 | return "Bam('%s', '%s')" % (self.fn, self.mode)
446 |
447 | def write(self, *alns):
448 | """
449 | Write alignments to the current file.
450 |
451 | Parameters
452 | ----------
453 | *alns: bam1_t *
454 |
455 | """
456 | for aln in alns:
457 | assert libhts.sam_write1(self._htf, self.header, aln._b) > 0, "error"
458 |
459 | @classmethod
460 | def header_from_fasta(self, fasta, sort_order='unknown'):
461 | """Create a sam header from a fasta file.
462 |
463 | >>> import os.path as op
464 | >>> fa = '%s/test/t.fa' % op.dirname(__file__)
465 | >>> print(Bam.header_from_fasta(fa)) #doctest: +NORMALIZE_WHITESPACE
466 | @HD VN:1.0 SO:unknown
467 | @SQ SN:chr1 LN:46
468 | """
469 | from .fai import Fai
470 | header = ["@HD\tVN:1.0\tSO:%s" % sort_order]
471 | for chrom, length in Fai(fasta):
472 | header.append("@SQ\tSN:%s\tLN:%i" % (chrom, length))
473 | return "\n".join(header) + "\n"
474 |
475 | def close(self):
476 | """Close the current file."""
477 | libhts.hts_close(self._htf)
478 |
479 | def flush(self):
480 | """Flush the current file."""
481 | libhts.bgzf_flush(self._htf.fp.bgzf)
482 |
483 | def __iter__(self):
484 | """Return self as an iterator of alignments."""
485 | return self
486 |
487 | def next(self):
488 | """Iterate over all alignments returning Alignment object."""
489 | if libhts.sam_read1(self._htf, self.header._h, self._b) >= 0:
490 | return Alignment(self._b, self.header._h)
491 | raise StopIteration()
492 |
493 | def __call__(self, region):
494 | """Perform a region query.
495 |
496 | Parameters
497 | ----------
498 | region : str
499 | region to query, e.g. chr1:1234-5678
500 | """
501 | qiter = libhts.sam_itr_querys(self._idx, self.header._h, region);
502 | try:
503 | slen = libhts.sam_itr_next(self._htf, qiter, self._b)
504 |
505 | while slen > 0:
506 | yield Alignment(self._b, self.header._h)
507 | slen = libhts.sam_itr_next(self._htf, qiter, self._b)
508 |
509 | finally:
510 | libhts.hts_itr_destroy(qiter)
511 |
--------------------------------------------------------------------------------
/hts/fai.py:
--------------------------------------------------------------------------------
1 | from .htsffi import libhts, ffi
2 | import os.path as op
3 | import atexit
4 |
5 | class Fai(object):
6 |
7 | """
8 | Random access to fasta files.
9 |
10 | uses 1-based starts for regions
11 |
12 | Arguments
13 | ---------
14 |
15 | fn: str
16 | fasta file path.
17 |
18 | Examples
19 | --------
20 |
21 | >>> f = Fai('%s/test/t.fa' % op.dirname(__file__))
22 | >>> f('chr1:1-10')
23 | 'AGAAAACCCC'
24 | >>> f.nseqs
25 | 1
26 | >>> 'chr1' in f
27 | True
28 | >>> 'chr2' in f
29 | False
30 |
31 | >>> for chrom, clen in f:
32 | ... print chrom, clen
33 | chr1 46
34 |
35 | >>> dict(f)
36 | {'chr1': 46}
37 | """
38 |
39 | def __init__(self, fn):
40 | """Create a new Fai object
41 |
42 | Examples
43 | --------
44 |
45 | >>> f = Fai('%s/test/t.fa' % op.dirname(__file__))
46 | """
47 | if fn.endswith(".fai"):
48 | fn = fn[:-4]
49 | assert op.exists(fn), (fn, "does not exist")
50 | if not op.exists("%s.fai" % fn):
51 | assert libhts.fai_build(fn) == 0
52 | self._fai = libhts.fai_load(fn)
53 | atexit.register(libhts.fai_destroy, self._fai)
54 | self.fn = fn
55 |
56 | def __call__(self, region):
57 | """Extract a region.
58 |
59 | Arguments
60 | ---------
61 |
62 | region: str
63 | """
64 | rlen = ffi.new("int *")
65 | seq = libhts.fai_fetch(self._fai, region, rlen)
66 | if rlen == -2:
67 | raise Exception("sequence not present")
68 | elif rlen == -1:
69 | raise Exception("error fetching sequence")
70 | return ffi.string(seq)
71 |
72 | @property
73 | def nseqs(self):
74 | """Count number of sequences in the fastq."""
75 | return libhts.faidx_nseq(self._fai)
76 |
77 | def __contains__(self, seq):
78 | """Test if a sequence name is in the fasta."""
79 | return bool(libhts.faidx_has_seq(self._fai, seq))
80 |
81 | def __iter__(self):
82 | """Generate names and lengths of the sequences."""
83 | with open(self.fn + ".fai") as fai:
84 | for toks in (l.rstrip("\r\n").split("\t") for l in fai):
85 | yield toks[0], int(toks[1])
86 |
--------------------------------------------------------------------------------
/hts/fisher.py:
--------------------------------------------------------------------------------
1 | from .htsffi import ffi, libhts
2 |
3 | def fisher_exact_test(n11, n12, n21, n22):
4 | """
5 | >>> ps = fisher_exact_test(20, 10, 10, 35)
6 | >>> ps['two_tail'], ps['right_tail'], ps['left_tail'] # doctest: +ELLIPSIS
7 | (0.00023..., 0.00014..., 0.9999...)
8 | """
9 | left, right = ffi.new("double *"), ffi.new("double *")
10 | two = ffi.new("double *")
11 | libhts.kt_fisher_exact(n11, n12, n21, n22, left, right, two)
12 | return dict(left_tail=left[0], right_tail=right[0], two_tail=two[0])
13 |
--------------------------------------------------------------------------------
/hts/hts_concat.h:
--------------------------------------------------------------------------------
1 | void *malloc(size_t size);
2 | void free(void *);
3 |
4 | char *strncpy(char *dst, char *src, size_t size);
5 | long int strtol (const char* str, char** endptr, int base);
6 |
7 |
8 | struct hFILE;
9 |
10 | //############################
11 | //# kstring
12 | //############################
13 |
14 | typedef struct __kstring_t {
15 | size_t l, m;
16 | char *s;
17 | } kstring_t;
18 |
19 | static inline char *ks_release(kstring_t *s);
20 | void kputsn(char *, int, kstring_t *);
21 |
22 |
23 | //##########################
24 | //# BGZF
25 | //##########################
26 | typedef struct __bgzidx_t bgzidx_t;
27 | typedef struct z_stream_s z_stream;
28 | struct BGZF;
29 | typedef struct BGZF BGZF;
30 | BGZF* bgzf_open(const char* path, const char *mode);
31 | int bgzf_close(BGZF *fp);
32 | BGZF* bgzf_hopen(struct hFILE *fp, const char *mode);
33 | int bgzf_flush(BGZF *fp);
34 |
35 |
36 | //###########################
37 | //# hts
38 | //###########################
39 | struct __hts_idx_t;
40 | typedef struct __hts_idx_t hts_idx_t;
41 |
42 | typedef struct {
43 | union {
44 | BGZF *bgzf;
45 | struct cram_fd *cram;
46 | struct hFILE *hfile;
47 | void *voidp;
48 | } fp;
49 | ...;
50 | } htsFile;
51 |
52 | htsFile *hts_open(const char *fn, const char *mode);
53 | int hts_close(htsFile *fp);
54 |
55 | int hts_getline(htsFile *fp, int delimiter, kstring_t *str);
56 | char **hts_readlines(const char *fn, int *_n);
57 | int hts_set_threads(htsFile *fp, int n);
58 | int hts_set_fai_filename(htsFile *fp, const char *fn_aux);
59 |
60 | typedef int hts_readrec_func(BGZF *fp, void *data, void *r, int *tid, int *beg, int *end);
61 | typedef const char *(*hts_id2name_f)(void*, int);
62 |
63 |
64 |
65 | struct _h;
66 | typedef struct _h hts_itr_t;
67 |
68 | hts_idx_t *hts_idx_init(int n, int fmt, uint64_t offset0, int min_shift, int n_lvls);
69 |
70 | void hts_idx_destroy(hts_idx_t *idx);
71 | int hts_idx_push(hts_idx_t *idx, int tid, int beg, int end, uint64_t offset, int is_mapped);
72 | void hts_idx_finish(hts_idx_t *idx, uint64_t final_offset);
73 |
74 | void hts_idx_save(const hts_idx_t *idx, const char *fn, int fmt);
75 | hts_idx_t *hts_idx_load(const char *fn, int fmt);
76 |
77 | uint8_t *hts_idx_get_meta(hts_idx_t *idx, int *l_meta);
78 | void hts_idx_set_meta(hts_idx_t *idx, int l_meta, uint8_t *meta, int is_copy);
79 |
80 | int hts_idx_get_stat(const hts_idx_t* idx, int tid, uint64_t* mapped, uint64_t* unmapped);
81 | uint64_t hts_idx_get_n_no_coor(const hts_idx_t* idx);
82 |
83 | const char *hts_parse_reg(const char *s, int *beg, int *end);
84 | hts_itr_t *hts_itr_query(const hts_idx_t *idx, int tid, int beg, int end, hts_readrec_func *readrec);
85 | void hts_itr_destroy(hts_itr_t *iter);
86 |
87 | int hts_itr_next(BGZF *fp, hts_itr_t *iter, void *r, void *data);
88 | const char **hts_idx_seqnames(const hts_idx_t *idx, int *n, hts_id2name_f getid, void *hdr);
89 |
90 |
91 | //###########################
92 | //# tbx
93 | //###########################
94 | typedef struct {
95 | int32_t preset;
96 | int32_t sc, bc, ec; // seq col., beg col. and end col.
97 | int32_t meta_char, line_skip;
98 | } tbx_conf_t;
99 |
100 | typedef struct {
101 | tbx_conf_t conf;
102 | hts_idx_t *idx;
103 | void *dict;
104 | } tbx_t;
105 |
106 |
107 | int tbx_index_build(const char *fn, int min_shift, const tbx_conf_t *conf);
108 | tbx_t *tbx_index_load(const char *fn);
109 | const char **tbx_seqnames(tbx_t *tbx, int *n); // free the array but not the values
110 | void tbx_destroy(tbx_t *tbx);
111 |
112 |
113 | hts_itr_t * tbx_itr_querys(tbx_t *tbx, char *);
114 |
115 | int tbx_itr_next(htsFile *fp, tbx_t *tbx, hts_itr_t *iter, void *data);
116 |
117 | //#####################################
118 | //# sam.h
119 | //#####################################
120 |
121 | typedef htsFile samFile;
122 |
123 | typedef struct {
124 | int32_t n_targets, ignore_sam_err;
125 | uint32_t l_text;
126 | uint32_t *target_len;
127 | int8_t *cigar_tab;
128 | char **target_name;
129 | char *text;
130 | void *sdict;
131 | } bam_hdr_t;
132 |
133 |
134 | typedef struct {
135 | int32_t tid;
136 | int32_t pos;
137 | uint16_t bin;
138 | uint8_t qual;
139 | uint8_t l_qname;
140 | uint16_t flag;
141 | uint8_t unused1;
142 | uint8_t l_extranul;
143 | uint32_t n_cigar;
144 | int32_t l_qseq;
145 | int32_t mtid;
146 | int32_t mpos;
147 | int32_t isize;
148 | } bam1_core_t;
149 |
150 | typedef struct {
151 | bam1_core_t core;
152 | int l_data, m_data;
153 | uint8_t *data;
154 | ...;
155 | } bam1_t;
156 |
157 |
158 |
159 | bam_hdr_t *sam_hdr_parse(int l_text, const char *text);
160 | bam_hdr_t *sam_hdr_read(samFile *fp);
161 | bam_hdr_t* bam_hdr_dup(const bam_hdr_t *h0);
162 | int bam_hdr_write(BGZF *fp, const bam_hdr_t *h);
163 | int sam_hdr_write(htsFile *fp, const bam_hdr_t *h);
164 | int sam_write1(htsFile *fp, const bam_hdr_t *h, const bam1_t *b);
165 |
166 |
167 |
168 | int sam_format1(const bam_hdr_t *h, const bam1_t *b, kstring_t *str);
169 | int sam_read1(samFile *fp, bam_hdr_t *h, bam1_t *b);
170 | int bam_read1(BGZF *fp, bam1_t *b);
171 |
172 | bam1_t *bam_init1();
173 | void bam_destroy1(bam1_t *b);
174 | int bam_is_rev(bam1_t *b);
175 | int bam_is_mrev(bam1_t *b);
176 | char *bam_get_qname(bam1_t *b);
177 | uint32_t *bam_get_cigar(bam1_t *b);
178 | uint8_t *bam_get_seq(bam1_t *b);
179 |
180 | uint8_t bam_seqi(uint8_t *c, int i);
181 |
182 | uint8_t *bam_get_qual(bam1_t *b);
183 |
184 | uint8_t *bam_get_aux(bam1_t *b);
185 | int bam_get_l_aux(bam1_t *b);
186 | uint8_t *bam_aux_get(const bam1_t *b, const char tag[2]);
187 | int32_t bam_aux2i(const uint8_t *s);
188 | float bam_aux2f(const uint8_t *s);
189 | char *bam_aux2Z(const uint8_t *s);
190 |
191 | bam1_t *bam_copy1(bam1_t *bdst, const bam1_t *bsrc);
192 | bam1_t *bam_dup1(const bam1_t *bsrc);
193 |
194 | int bam_cigar2qlen(int n_cigar, const uint32_t *cigar);
195 | int bam_cigar2rlen(int n_cigar, const uint32_t *cigar);
196 | int32_t bam_endpos(const bam1_t *b);
197 |
198 | int bam_str2flag(const char *str); /** returns negative value on error */
199 | char *bam_flag2str(int flag); /** The string must be freed by the user */
200 |
201 | int sam_parse1(kstring_t *s, bam_hdr_t *h, bam1_t *b);
202 |
203 |
204 |
205 | hts_idx_t * sam_index_load(samFile *in, char *); // load index
206 | int bam_index_build(const char *fn, int min_shift);
207 |
208 |
209 | hts_itr_t * sam_itr_querys(hts_idx_t*, bam_hdr_t *h, char * region);
210 |
211 | //int tbx_itr_next(htsFile *fp, tbx_t *tbx, hts_itr_t *iter, void *data);
212 | int sam_itr_next(htsFile *fp, hts_itr_t *iter, void *data);
213 |
214 | static const int BAM_CMATCH = 0;
215 | static const int BAM_CINS = 1;
216 | static const int BAM_CDEL = 2;
217 | static const int BAM_CREF_SKIP = 3;
218 | static const int BAM_CSOFT_CLIP = 4;
219 | static const int BAM_CHARD_CLIP = 5;
220 | static const int BAM_CPAD = 6;
221 | static const int BAM_CEQUAL = 7;
222 | static const int BAM_CDIFF = 8;
223 | static const int BAM_CBACK = 9;
224 |
225 | uint32_t bam_cigar_op(uint32_t cigar);
226 | char bam_cigar_opchr(uint32_t cigar);
227 | uint32_t bam_cigar_oplen(uint32_t cigar);
228 |
229 |
230 | typedef union {
231 | void *p;
232 | int64_t i;
233 | double f;
234 | } bam_pileup_cd;
235 |
236 |
237 | typedef struct {
238 | bam1_t *b;
239 | int32_t qpos;
240 | int indel, level;
241 | uint32_t is_del:1, is_head:1, is_tail:1, is_refskip:1, aux:28;
242 | bam_pileup_cd cd; // generic per-struct data, owned by caller.
243 | } bam_pileup1_t;
244 |
245 |
246 | typedef int (*bam_plp_auto_f)(void *data, bam1_t *b);
247 |
248 | struct __bam_plp_t;
249 | typedef struct __bam_plp_t *bam_plp_t;
250 |
251 | struct __bam_mplp_t;
252 | typedef struct __bam_mplp_t *bam_mplp_t;
253 |
254 | bam_plp_t bam_plp_init(bam_plp_auto_f func, void *data);
255 | void bam_plp_destroy(bam_plp_t iter);
256 | int bam_plp_push(bam_plp_t iter, const bam1_t *b);
257 | const bam_pileup1_t *bam_plp_next(bam_plp_t iter, int *_tid, int *_pos, int *_n_plp);
258 | const bam_pileup1_t *bam_plp_auto(bam_plp_t iter, int *_tid, int *_pos, int *_n_plp);
259 | void bam_plp_set_maxcnt(bam_plp_t iter, int maxcnt);
260 | void bam_plp_reset(bam_plp_t iter);
261 |
262 | bam_mplp_t bam_mplp_init(int n, bam_plp_auto_f func, void **data);
263 |
264 | void bam_mplp_init_overlaps(bam_mplp_t iter);
265 | void bam_mplp_destroy(bam_mplp_t iter);
266 | void bam_mplp_set_maxcnt(bam_mplp_t iter, int maxcnt);
267 | int bam_mplp_auto(bam_mplp_t iter, int *_tid, int *_pos, int *n_plp, const bam_pileup1_t **plp);
268 |
269 |
270 | //##############################################
271 | //# kfunc
272 | //##############################################
273 |
274 | double kt_fisher_exact(int n11, int n12, int n21, int n22, double *_left, double *_right, double *two);
275 |
276 | //##############################################
277 | //# faidx
278 | //##############################################
279 |
280 | struct __faidx_t;
281 | typedef struct __faidx_t faidx_t;
282 |
283 |
284 |
285 | void fai_destroy(faidx_t *fai);
286 | int fai_build(const char *fn);
287 |
288 | faidx_t *fai_load(const char *fn);
289 | // @param len Length of the region; -2 if seq not present, -1 general error
290 | char *fai_fetch(const faidx_t *fai, const char *reg, int *len);
291 | int faidx_nseq(const faidx_t *fai);
292 | char *faidx_fetch_seq(const faidx_t *fai, const char *c_name, int p_beg_i, int p_end_i, int *len);
293 | int faidx_has_seq(const faidx_t *fai, const char *seq);
294 |
295 | //##############################################
296 | //# vcf
297 | //##############################################
298 |
299 |
300 | /*
301 | typedef struct {
302 | int32_t rid; // CHROM
303 | int32_t pos; // POS
304 | int32_t rlen; // length of REF
305 | float qual; // QUAL
306 | uint32_t n_info:16, n_allele:16;
307 | uint32_t n_fmt:8, n_sample:24;
308 | kstring_t shared, indiv;
309 | bcf_dec_t d; // lazy evaluation: $d is not generated by bcf_read(), but by explicitly calling bcf_unpack()
310 | int max_unpack; // Set to BCF_UN_STR, BCF_UN_FLT, or BCF_UN_INFO to boost performance of vcf_parse when some of the fields won't be needed
311 | int unpacked; // remember what has been unpacked to allow calling bcf_unpack() repeatedly without redoing the work
312 | int unpack_size[3]; // the original block size of ID, REF+ALT and FILTER
313 | int errcode; // one of BCF_ERR_* codes
314 | } bcf1_t;
315 | */
316 |
317 |
318 | typedef struct {
319 | int type, n; // variant type and the number of bases affected, negative for deletions
320 | } variant_t;
321 |
322 | typedef struct {
323 | int id; // id: numeric tag id, the corresponding string is bcf_hdr_t::id[BCF_DT_ID][$id].key
324 | int n, size, type; // n: number of values per-sample; size: number of bytes per-sample; type: one of BCF_BT_* types
325 | uint8_t *p; // same as vptr and vptr_* in bcf_info_t below
326 | uint32_t p_len;
327 | uint32_t p_off:31, p_free:1;
328 | } bcf_fmt_t;
329 |
330 | typedef struct {
331 | int key; // key: numeric tag id, the corresponding string is bcf_hdr_t::id[BCF_DT_ID][$key].key
332 | int type, len; // type: one of BCF_BT_* types; len: vector length, 1 for scalars
333 | union {
334 | int32_t i; // integer value
335 | float f; // float value
336 | } v1; // only set if $len==1; for easier access
337 | uint8_t *vptr; // pointer to data array in bcf1_t->shared.s, excluding the size+type and tag id bytes
338 | uint32_t vptr_len; // length of the vptr block or, when set, of the vptr_mod block, excluding offset
339 | uint32_t vptr_off:31, // vptr offset, i.e., the size of the INFO key plus size+type bytes
340 | vptr_free:1; // indicates that vptr-vptr_off must be freed; set only when modified and the new
341 | // data block is bigger than the original
342 | } bcf_info_t;
343 |
344 |
345 | typedef struct {
346 | int32_t n[3];
347 | ...;
348 | } bcf_hdr_t;
349 |
350 |
351 | typedef struct {
352 | int m_fmt, m_info, m_id, m_als, m_allele, m_flt; // allocated size (high-water mark); do not change
353 | int n_flt; // Number of FILTER fields
354 | int *flt; // FILTER keys in the dictionary
355 | char *id, *als; // ID and REF+ALT block (\0-seperated)
356 | char **allele; // allele[0] is the REF (allele[] pointers to the als block); all null terminated
357 | bcf_info_t *info; // INFO
358 | bcf_fmt_t *fmt; // FORMAT and individual sample
359 | variant_t *var; // $var and $var_type set only when set_variant_types called
360 | int n_var, var_type;
361 | int shared_dirty; // if set, shared.s must be recreated on BCF output
362 | int indiv_dirty; // if set, indiv.s must be recreated on BCF output
363 | } bcf_dec_t;
364 |
365 | typedef struct {
366 | int32_t rid; // CHROM
367 | int32_t pos; // POS
368 | int32_t rlen; // length of REF
369 | float qual; // QUAL
370 | uint32_t n_info:16, n_allele:16;
371 | uint32_t n_fmt:8, n_sample:24;
372 | kstring_t shared, indiv;
373 | bcf_dec_t d; // lazy evaluation: $d is not generated by bcf_read(), but by explicitly calling bcf_unpack()
374 | int max_unpack; // Set to BCF_UN_STR, BCF_UN_FLT, or BCF_UN_INFO to boost performance of vcf_parse when some of the fields won't be needed
375 | int unpacked; // remember what has been unpacked to allow calling bcf_unpack() repeatedly without redoing the work
376 | int unpack_size[3]; // the original block size of ID, REF+ALT and FILTER
377 | int errcode; // one of BCF_ERR_* codes
378 | } bcf1_t;
379 |
380 |
381 | bcf1_t *bcf_init(void);
382 |
383 |
384 |
385 | bcf_hdr_t *bcf_hdr_read(htsFile *fp);
386 | int bcf_hdr_set_samples(bcf_hdr_t *hdr, const char *samples, int is_file);
387 |
388 | int bcf_read(htsFile *fp, const bcf_hdr_t *h, bcf1_t *v);
389 |
390 | static inline const char *bcf_hdr_id2name(const bcf_hdr_t *hdr, int rid);
391 |
392 | int bcf_unpack(bcf1_t *b, int which);
393 |
394 | static const int BCF_DT_SAMPLE = 2;
395 |
396 | int bcf_get_genotypes(const bcf_hdr_t *hdr, bcf1_t *line, int **dst, int *ndst);
397 | int bcf_get_format_values(const bcf_hdr_t *hdr, bcf1_t *line, const char *tag, void **dst, int *ndst, int type);
398 | //typedef htsFile vcfFile;
399 |
400 |
401 |
402 |
403 |
404 | //##############################################
405 | //# hts_extra
406 | //##############################################
407 | //int bam_get_read_seq(bam1_t *b, kstring_t *str);
408 |
--------------------------------------------------------------------------------
/hts/hts_extra.c:
--------------------------------------------------------------------------------
1 | #include "htslib/sam.h"
2 | #include "htslib/vcf.h"
3 | #include "htslib/kstring.h"
4 |
5 |
6 | // the htslib api only provides bam_seqi to get one base at a time.
7 | // to avoid having to call that, e.g. 100 times to get the sequence for
8 | // a 100 base read, we implement this.
9 | int bam_get_read_seq(bam1_t *b, kstring_t * str){
10 | int i = 0;
11 | str->l = 0;
12 | uint8_t *s = bam_get_seq(b);
13 | for (; i < b->core.l_qseq; ++i) kputc("=ACMGRSVTWYHKDBN"[bam_seqi(s, i)], str);
14 | return i;
15 | }
16 |
17 | int as_gts(int *gts, int num_samples) {
18 | int j = 0, i;
19 | for (i = 0; i < 2 * num_samples; i += 2){
20 | if (bcf_gt_is_missing(gts[i]) && bcf_gt_is_missing(gts[i+1])){
21 | gts[j++] = 2; // unknown
22 | continue;
23 | }
24 | int a = bcf_gt_allele(gts[i]);
25 | int b = bcf_gt_allele(gts[i+1]);
26 |
27 | if((a == 0) && (b == 0)) {
28 | gts[j] = 0; // HOM_REF
29 | }
30 | else if((a == 1) && (b == 1)) {
31 | gts[j] = 3; // HOM_ALT
32 | }
33 | else if((a != b)) {
34 | gts[j] = 1; // HET
35 | } else {
36 | gts[j] = 2; // unknown
37 | }
38 | j++;
39 | }
40 | // free the latter part of the array that we don't need.
41 | //free((void *)(&(gts[j])));
42 | return j;
43 | }
44 |
45 |
46 | static inline int cigar_iref2iseq_set(uint32_t **cigar, uint32_t *cigar_max, int *icig, int *iseq, int *iref)
47 | {
48 | int pos = *iref;
49 | if ( pos < 0 ) return -1;
50 | *icig = 0;
51 | *iseq = 0;
52 | *iref = 0;
53 | while ( *cigar> BAM_CIGAR_SHIFT;
57 |
58 | if ( cig==BAM_CSOFT_CLIP ) { (*cigar)++; *iseq += ncig; *icig = 0; continue; }
59 | if ( cig==BAM_CHARD_CLIP || cig==BAM_CPAD ) { (*cigar)++; *icig = 0; continue; }
60 | if ( cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF )
61 | {
62 | pos -= ncig;
63 | if ( pos < 0 ) { *icig = ncig + pos; *iseq += *icig; *iref += *icig; return BAM_CMATCH; }
64 | (*cigar)++; *iseq += ncig; *icig = 0; *iref += ncig;
65 | continue;
66 | }
67 | if ( cig==BAM_CINS ) { (*cigar)++; *iseq += ncig; *icig = 0; continue; }
68 | if ( cig==BAM_CDEL || cig==BAM_CREF_SKIP )
69 | {
70 | pos -= ncig;
71 | if ( pos<0 ) pos = 0;
72 | (*cigar)++; *icig = 0; *iref += ncig;
73 | continue;
74 | }
75 | }
76 | *iseq = -1;
77 | return -1;
78 | }
79 | static inline int cigar_iref2iseq_next(uint32_t **cigar, uint32_t *cigar_max, int *icig, int *iseq, int *iref)
80 | {
81 | while ( *cigar < cigar_max )
82 | {
83 | int cig = (**cigar) & BAM_CIGAR_MASK;
84 | int ncig = (**cigar) >> BAM_CIGAR_SHIFT;
85 |
86 | if ( cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF )
87 | {
88 | if ( *icig >= ncig - 1 ) { *icig = 0; (*cigar)++; continue; }
89 | (*iseq)++; (*icig)++; (*iref)++;
90 | return BAM_CMATCH;
91 | }
92 | if ( cig==BAM_CDEL || cig==BAM_CREF_SKIP ) { (*cigar)++; (*iref) += ncig; *icig = 0; continue; }
93 | if ( cig==BAM_CINS ) { (*cigar)++; *iseq += ncig; *icig = 0; continue; }
94 | if ( cig==BAM_CSOFT_CLIP ) { (*cigar)++; *iseq += ncig; *icig = 0; continue; }
95 | if ( cig==BAM_CHARD_CLIP || cig==BAM_CPAD ) { (*cigar)++; *icig = 0; continue; }
96 | fprintf(stderr,"todo: cigar %d\n", cig);
97 | }
98 | *iseq = -1;
99 | *iref = -1;
100 | return -1;
101 | }
102 |
103 | void tweak_overlap_quality(bam1_t *a, bam1_t *b) {
104 | uint32_t *a_cigar = bam_get_cigar(a), *a_cigar_max = a_cigar + a->core.n_cigar;
105 | uint32_t *b_cigar = bam_get_cigar(b), *b_cigar_max = b_cigar + b->core.n_cigar;
106 | int a_icig = 0, a_iseq = 0;
107 | int b_icig = 0, b_iseq = 0;
108 | uint8_t *a_qual = bam_get_qual(a), *b_qual = bam_get_qual(b);
109 | uint8_t *a_seq = bam_get_seq(a), *b_seq = bam_get_seq(b);
110 |
111 | int iref = b->core.pos;
112 | int a_iref = iref - a->core.pos;
113 | int b_iref = iref - b->core.pos;
114 | int a_ret = cigar_iref2iseq_set(&a_cigar, a_cigar_max, &a_icig, &a_iseq, &a_iref);
115 | if ( a_ret<0 ) return; // no overlap
116 | int b_ret = cigar_iref2iseq_set(&b_cigar, b_cigar_max, &b_icig, &b_iseq, &b_iref);
117 | if ( b_ret<0 ) return; // no overlap
118 |
119 |
120 | while ( 1 )
121 | {
122 | // Increment reference position
123 | while ( a_iref>=0 && a_iref < iref - a->core.pos )
124 | a_ret = cigar_iref2iseq_next(&a_cigar, a_cigar_max, &a_icig, &a_iseq, &a_iref);
125 | if ( a_ret<0 ) break; // done
126 | if ( iref < a_iref + a->core.pos ) iref = a_iref + a->core.pos;
127 |
128 | while ( b_iref>=0 && b_iref < iref - b->core.pos )
129 | b_ret = cigar_iref2iseq_next(&b_cigar, b_cigar_max, &b_icig, &b_iseq, &b_iref);
130 | if ( b_ret<0 ) break; // done
131 | if ( iref < b_iref + b->core.pos ) iref = b_iref + b->core.pos;
132 |
133 | iref++;
134 | if ( a_iref+a->core.pos != b_iref+b->core.pos ) continue; // only CMATCH positions, don't know what to do with indels
135 |
136 | if ( bam_seqi(a_seq,a_iseq) == bam_seqi(b_seq,b_iseq) )
137 | {
138 | // we are very confident about this base
139 | int qual = a_qual[a_iseq] + b_qual[b_iseq];
140 | a_qual[a_iseq] = qual>200 ? 200 : qual;
141 | b_qual[b_iseq] = 0;
142 | }
143 | else
144 | {
145 | if ( a_qual[a_iseq] >= b_qual[b_iseq] )
146 | {
147 | a_qual[a_iseq] = 0.8 * a_qual[a_iseq]; // not so confident about a_qual anymore given the mismatch
148 | b_qual[b_iseq] = 0;
149 | }
150 | else
151 | {
152 | b_qual[b_iseq] = 0.8 * b_qual[b_iseq];
153 | a_qual[a_iseq] = 0;
154 | }
155 | }
156 | }
157 | }
158 |
159 |
160 | int aux_type2size(uint8_t type)
161 | {
162 | switch (type) {
163 | case 'A': case 'c': case 'C':
164 | return 1;
165 | case 's': case 'S':
166 | return 2;
167 | case 'i': case 'I': case 'f':
168 | return 4;
169 | case 'd':
170 | return 8;
171 | case 'Z': case 'H': case 'B':
172 | return type;
173 | default:
174 | return 0;
175 | }
176 | }
177 |
178 |
179 | int skip_aux(uint8_t *s)
180 | {
181 | int size = aux_type2size(*s); ++s; // skip type
182 | uint32_t n;
183 | int k = 0;
184 | switch (size) {
185 | case 'Z':
186 | case 'H':
187 | while (*s) {++s;++k;}
188 | return k + 1;
189 | case 'B':
190 | size = aux_type2size(*s);
191 | ++s;
192 | memcpy(&n, s, 4); s += 4;
193 | return n * size + 4;
194 | case 0:
195 | abort();
196 | break;
197 | default:
198 | return size;
199 | }
200 | }
201 |
202 |
--------------------------------------------------------------------------------
/hts/hts_extra.h:
--------------------------------------------------------------------------------
1 | int bam_get_read_seq(bam1_t *b, kstring_t * str);
2 |
3 | void tweak_overlap_quality(bam1_t *, bam1_t *);
4 |
5 | int as_gts(int *gts, int num_samples);
6 |
7 |
8 | int aux_type2size(uint8_t type);
9 |
10 | int skip_aux(uint8_t *s);
11 |
12 |
--------------------------------------------------------------------------------
/hts/htsffi.py:
--------------------------------------------------------------------------------
1 | from __future__ import print_function, division
2 | from cffi import FFI
3 | import os
4 | import os.path as op
5 | import atexit
6 |
7 | def _raise_if_null(v, msg):
8 | if v == ffi.NULL:
9 | raise Exception(msg)
10 |
11 | ffi = FFI()
12 |
13 | HERE = op.relpath(op.dirname(__file__))
14 |
15 | with open(op.join(HERE, "hts_concat.h")) as headers:
16 | ffi.cdef(headers.read())
17 | with open(op.join(HERE, "hts_extra.h")) as headers:
18 | ffi.cdef(headers.read())
19 |
20 | libhts = ffi.verify('''
21 | #include "stdlib.h"
22 | #include
23 | #include "htslib/hts.h"
24 | #include "htslib/kstring.h"
25 | #include "htslib/tbx.h"
26 | #include "htslib/bgzf.h"
27 | #include "htslib/sam.h"
28 | #include "htslib/faidx.h"
29 | #include "htslib/vcf.h"
30 | #include "htslib/kfunc.h"
31 | #include "hts_extra.h"
32 | ''',
33 | libraries=['c', 'z', 'hts'],
34 | library_dirs=["/usr/lib", "/usr/local/lib"] + os.environ.get("LD_LIBRARY_PATH", "").split(":"),
35 | ext_package='hts',
36 | depends=["%s/hts_extra.h" % HERE],
37 | sources=["%s/hts_extra.c" % HERE],
38 | include_dirs=[HERE] + os.environ.get('C_INCLUDE_PATH', '').split(":") + ["/usr/include/", "/usr/local/include/"],
39 | )
40 |
--------------------------------------------------------------------------------
/hts/tbx.py:
--------------------------------------------------------------------------------
1 | import os.path as op
2 | from .htsffi import libhts, ffi, _raise_if_null
3 | import atexit
4 |
5 | class Tbx(object):
6 | """
7 | >>> tbx = Tbx('%s/test/example.gtf.gz' % op.dirname(__file__))
8 |
9 | >>> tbx.sequences
10 | [u'chr1', u'chr2']
11 |
12 | >>> for s in tbx('chr1:1-1800'):
13 | ... print(s[:5])
14 | ['chr1', 'ENSEMBL', 'UTR', 1737, 2090]
15 | ['chr1', 'ENSEMBL', 'exon', 1737, 2090]
16 | ['chr1', 'ENSEMBL', 'transcript', 1737, 4275]
17 | ['chr1', 'HAVANA', 'gene', 1737, 4275]
18 | """
19 | def __init__(self, fname):
20 | assert op.exists(fname), ("Tbx: no file", fname)
21 | if not op.exists("%s.tbi" % fname):
22 | if fname.endswith('.bed.gz'):
23 | Tbx.build(fname)
24 | elif fname.endswith(('.gff.gz', '.gtf.gz')):
25 | Tbx.build(fname, 1, 4, 5, '#', 0)
26 | elif fname.endswith(('.vcf.gz')):
27 | Tbx.build(fname, 1, 2, 0, '#', 0)
28 | else:
29 | raise Exception('%s.tbi not found and filetype not known' % fname)
30 |
31 | tbx = self._tbx = libhts.tbx_index_load(fname);
32 | _raise_if_null(tbx, "Tbx:unable to find %s.tbi" % fname)
33 |
34 | htf = self._htf = libhts.hts_open(fname, "r");
35 | _raise_if_null(tbx, "Tbx:unable to find %s" % fname)
36 |
37 | atexit.register(libhts.hts_close, htf)
38 | atexit.register(libhts.tbx_destroy, tbx)
39 |
40 | @classmethod
41 | def build(cls, fname, seq_col=1, start_col=2, end_col=3, comment="#",
42 | line_skip=0):
43 | """
44 | 1-based columns
45 | """
46 | conf = ffi.new('tbx_conf_t *')
47 | conf.sc, conf.bc, conf.ec = seq_col, start_col, end_col
48 | conf.meta_char = ffi.cast('char', comment)
49 | conf.preset = 0
50 | conf.line_skip = line_skip
51 | assert libhts.tbx_index_build(fname, -1, conf) != -1
52 | return Tbx(fname)
53 |
54 |
55 | @property
56 | def sequences(self):
57 | n = ffi.new("int *")
58 | cnames = libhts.tbx_seqnames(self._tbx, n)
59 | names = [ffi.string(cnames[i]).decode() for i in range(n[0])]
60 | try:
61 | return names
62 | finally:
63 | libhts.free(cnames)
64 |
65 | def __call__(self, region):
66 | itr = libhts.tbx_itr_querys(self._tbx, region)
67 | s = ffi.new("kstring_t *")
68 | conf = self._tbx.conf
69 |
70 | # get 0-based cols so we can convert to ints
71 | start_col, end_col = conf.bc - 1, conf.ec - 1
72 |
73 | try:
74 | slen = libhts.tbx_itr_next(self._htf, self._tbx, itr, s)
75 | while slen > 0:
76 | toks = ffi.string(s.s, slen).split("\t")
77 |
78 | # convert the start and end columns to int
79 | toks[start_col] = int(toks[start_col])
80 | if end_col != -1:
81 | toks[end_col] = int(toks[end_col])
82 | yield toks
83 |
84 | slen = libhts.tbx_itr_next(self._htf, self._tbx, itr, s)
85 | finally:
86 | libhts.free(s.s)
87 | libhts.hts_itr_destroy(itr)
88 |
89 | query = __call__
90 |
91 |
--------------------------------------------------------------------------------
/hts/test/__init__.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import doctest
3 | import hts.htsffi
4 |
5 |
--------------------------------------------------------------------------------
/hts/test/e.sam:
--------------------------------------------------------------------------------
1 | @HD VN:1.0 SO:coordinate
2 | @SQ SN:1 LN:23011544
3 | SRR1545849.11:CELL_A12:UMI_TCTCTT 0 ENSMUST00000188299 1 255 41M * 0 0 ATCAACCTGTACACTGTTATCTTCATTAATATTTTATTATC ggggiiighghhiiiihiihiiihhiiiiihiiiiiiiiii NH:i:1
4 |
--------------------------------------------------------------------------------
/hts/test/example.gtf.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brentp/hts-python/d27f873f7e8e770f6afd5630beb253edc2f7ca05/hts/test/example.gtf.gz
--------------------------------------------------------------------------------
/hts/test/example.gtf.gz.tbi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brentp/hts-python/d27f873f7e8e770f6afd5630beb253edc2f7ca05/hts/test/example.gtf.gz.tbi
--------------------------------------------------------------------------------
/hts/test/small.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brentp/hts-python/d27f873f7e8e770f6afd5630beb253edc2f7ca05/hts/test/small.bam
--------------------------------------------------------------------------------
/hts/test/small.bam.bai:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brentp/hts-python/d27f873f7e8e770f6afd5630beb253edc2f7ca05/hts/test/small.bam.bai
--------------------------------------------------------------------------------
/hts/test/t.fa:
--------------------------------------------------------------------------------
1 | >chr1
2 | AGAAAACCCCCCCACACACACAC
3 | TGATTTTTTTTTTTTTTTTTTTT
4 |
--------------------------------------------------------------------------------
/hts/test/t.fa.fai:
--------------------------------------------------------------------------------
1 | chr1 46 6 23 24
2 |
--------------------------------------------------------------------------------
/hts/test/t.sam:
--------------------------------------------------------------------------------
1 | @HD VN:1.5 SO:coordinate
2 | @SQ SN:chr1 LN:195471971 M5:c4ec915e7348d42648eefc1534b71c99 UR:file:/ref/mm10.fa
3 | HWI-ST552:217:C5WGPACXX:1:1209:10866:87788 163 chr1 3000004 40 14M1I86M = 3000132 229 TATTTCTATTTTATAAAATAATTTAAAAAAAATTAAAATTAAATCTTCTTTAAAAATCTAATAAAACTCTACATTAAACCCATCTAATCCTAAACTTTTTT CCCFFFFFHGHHHJJJJJJJJJJJJJJJJJJJJJJJJIIJIIIJJJJJJJIJJJJJJJIJJJJJJJIIHHHHHHFFFFEFDDEEDDDEDDDDDDDDDDDDD MC:Z:101M MD:Z:16T2C80 PG:Z:bwa-meth RG:Z:44_Mm08_WEAd_Db2_WGBS_E_1_L001__trimmed NM:i:28 MQ:i:60 UQ:i:1064 AS:i:87 XS:i:101
4 | HWI-ST552:217:C5WGPACXX:1:1316:10062:85179 163 chr1 3000011 25 7M1I93M = 3000086 177 ATTTTATAAAATAATTTAAAAAAAATTAAAATTAAATCTTCTTTAAAAATCTAATAAAACTCTACATTAAACCCATCTAATCCTAAACTTTTTTTTTTTTT CCCFFDFFGHHHHEHIJIGIIGJJJJJFHHEIIIIGIJJJJGIJJIIJGIGEHIGIJJGGIIJIGGJHHHHHHFFFFDCCDEDDD>;?CCDDDDDDDDDDD MC:Z:7M1D94M MD:Z:9T2C87 PG:Z:bwa-meth RG:Z:44_Mm08_WEAd_Db2_WGBS_E_1_L001__trimmed NM:i:27 MQ:i:25 UQ:i:981 AS:i:87 XS:i:101
5 |
--------------------------------------------------------------------------------
/hts/test/t2.fa:
--------------------------------------------------------------------------------
1 | >chr2L
2 | AGAAAACCCCCCCACACACACAC
3 | TGATTTTTTTTTTTTTTTTTTTT
4 | AGAAAACCCCCCCACACACACAC
5 | AGAAAACCCCCCCACACACACAC
6 | TGATTTTTTTTTTTTTTTTTTTT
7 | AGAAAACCCCCCCACACACACAC
8 | TGATTTTTTTTTTTTTTTTTTTT
9 | TGATTTTTTTTTTTTTTTTTTTT
10 | AGAAAACCCCCCCACACACACAC
11 | TGATTTTTTTTTTTTTTTTTTTT
12 | AGAAAACCCCCCCACACACACAC
13 | AGAAAACCCCCCCACACACACAC
14 | TGATTTTTTTTTTTTTTTTTTTT
15 | AGAAAACCCCCCCACACACACAC
16 | TGATTTTTTTTTTTTTTTTTTTT
17 | TGATTTTTTTTTTTTTTTTTTTT
18 | AGAAAACCCCCCCACACACACAC
19 | TGATTTTTTTTTTTTTTTTTTTT
20 | AGAAAACCCCCCCACACACACAC
21 | AGAAAACCCCCCCACACACACAC
22 | TGATTTTTTTTTTTTTTTTTTTT
23 | AGAAAACCCCCCCACACACACAC
24 | TGATTTTTTTTTTTTTTTTTTTT
25 | TGATTTTTTTTTTTTTTTTTTTT
26 | AGAAAACCCCCCCACACACACAC
27 | TGATTTTTTTTTTTTTTTTTTTT
28 | AGAAAACCCCCCCACACACACAC
29 | AGAAAACCCCCCCACACACACAC
30 | TGATTTTTTTTTTTTTTTTTTTT
31 | AGAAAACCCCCCCACACACACAC
32 | TGATTTTTTTTTTTTTTTTTTTT
33 | TGATTTTTTTTTTTTTTTTTTTT
34 | AGAAAACCCCCCCACACACACAC
35 | TGATTTTTTTTTTTTTTTTTTTT
36 | AGAAAACCCCCCCACACACACAC
37 | AGAAAACCCCCCCACACACACAC
38 | TGATTTTTTTTTTTTTTTTTTTT
39 | AGAAAACCCCCCCACACACACAC
40 | TGATTTTTTTTTTTTTTTTTTTT
41 | TGATTTTTTTTTTTTTTTTTTTT
42 | AGAAAACCCCCCCACACACACAC
43 | TGATTTTTTTTTTTTTTTTTTTT
44 | AGAAAACCCCCCCACACACACAC
45 | AGAAAACCCCCCCACACACACAC
46 | TGATTTTTTTTTTTTTTTTTTTT
47 | AGAAAACCCCCCCACACACACAC
48 | TGATTTTTTTTTTTTTTTTTTTT
49 | TGATTTTTTTTTTTTTTTTTTTT
50 | AGAAAACCCCCCCACACACACAC
51 | TGATTTTTTTTTTTTTTTTTTTT
52 | AGAAAACCCCCCCACACACACAC
53 | AGAAAACCCCCCCACACACACAC
54 | TGATTTTTTTTTTTTTTTTTTTT
55 | AGAAAACCCCCCCACACACACAC
56 | TGATTTTTTTTTTTTTTTTTTTT
57 | TGATTTTTTTTTTTTTTTTTTTT
58 | AGAAAACCCCCCCACACACACAC
59 | TGATTTTTTTTTTTTTTTTTTTT
60 | AGAAAACCCCCCCACACACACAC
61 | AGAAAACCCCCCCACACACACAC
62 | TGATTTTTTTTTTTTTTTTTTTT
63 | AGAAAACCCCCCCACACACACAC
64 | TGATTTTTTTTTTTTTTTTTTTT
65 | TGATTTTTTTTTTTTTTTTTTTT
66 | AGAAAACCCCCCCACACACACAC
67 | TGATTTTTTTTTTTTTTTTTTTT
68 | AGAAAACCCCCCCACACACACAC
69 | AGAAAACCCCCCCACACACACAC
70 | TGATTTTTTTTTTTTTTTTTTTT
71 | AGAAAACCCCCCCACACACACAC
72 | TGATTTTTTTTTTTTTTTTTTTT
73 | TGATTTTTTTTTTTTTTTTTTTT
74 | AGAAAACCCCCCCACACACACAC
75 | TGATTTTTTTTTTTTTTTTTTTT
76 | AGAAAACCCCCCCACACACACAC
77 | AGAAAACCCCCCCACACACACAC
78 | TGATTTTTTTTTTTTTTTTTTTT
79 | AGAAAACCCCCCCACACACACAC
80 | TGATTTTTTTTTTTTTTTTTTTT
81 | TGATTTTTTTTTTTTTTTTTTTT
82 | AGAAAACCCCCCCACACACACAC
83 | TGATTTTTTTTTTTTTTTTTTTT
84 | AGAAAACCCCCCCACACACACAC
85 | AGAAAACCCCCCCACACACACAC
86 | TGATTTTTTTTTTTTTTTTTTTT
87 | AGAAAACCCCCCCACACACACAC
88 | TGATTTTTTTTTTTTTTTTTTTT
89 | TGATTTTTTTTTTTTTTTTTTTT
90 | AGAAAACCCCCCCACACACACAC
91 | TGATTTTTTTTTTTTTTTTTTTT
92 | AGAAAACCCCCCCACACACACAC
93 | AGAAAACCCCCCCACACACACAC
94 | TGATTTTTTTTTTTTTTTTTTTT
95 | AGAAAACCCCCCCACACACACAC
96 | TGATTTTTTTTTTTTTTTTTTTT
97 | TGATTTTTTTTTTTTTTTTTTTT
98 | AGAAAACCCCCCCACACACACAC
99 | TGATTTTTTTTTTTTTTTTTTTT
100 | AGAAAACCCCCCCACACACACAC
101 | AGAAAACCCCCCCACACACACAC
102 | TGATTTTTTTTTTTTTTTTTTTT
103 | AGAAAACCCCCCCACACACACAC
104 | TGATTTTTTTTTTTTTTTTTTTT
105 | TGATTTTTTTTTTTTTTTTTTTT
106 | AGAAAACCCCCCCACACACACAC
107 | TGATTTTTTTTTTTTTTTTTTTT
108 | AGAAAACCCCCCCACACACACAC
109 | AGAAAACCCCCCCACACACACAC
110 | TGATTTTTTTTTTTTTTTTTTTT
111 | AGAAAACCCCCCCACACACACAC
112 | TGATTTTTTTTTTTTTTTTTTTT
113 | TGATTTTTTTTTTTTTTTTTTTT
114 | AGAAAACCCCCCCACACACACAC
115 | TGATTTTTTTTTTTTTTTTTTTT
116 | AGAAAACCCCCCCACACACACAC
117 | AGAAAACCCCCCCACACACACAC
118 | TGATTTTTTTTTTTTTTTTTTTT
119 | AGAAAACCCCCCCACACACACAC
120 | TGATTTTTTTTTTTTTTTTTTTT
121 | TGATTTTTTTTTTTTTTTTTTTT
122 | AGAAAACCCCCCCACACACACAC
123 | TGATTTTTTTTTTTTTTTTTTTT
124 | AGAAAACCCCCCCACACACACAC
125 | AGAAAACCCCCCCACACACACAC
126 | TGATTTTTTTTTTTTTTTTTTTT
127 | AGAAAACCCCCCCACACACACAC
128 | TGATTTTTTTTTTTTTTTTTTTT
129 | TGATTTTTTTTTTTTTTTTTTTT
130 | AGAAAACCCCCCCACACACACAC
131 | TGATTTTTTTTTTTTTTTTTTTT
132 | AGAAAACCCCCCCACACACACAC
133 | AGAAAACCCCCCCACACACACAC
134 | TGATTTTTTTTTTTTTTTTTTTT
135 | AGAAAACCCCCCCACACACACAC
136 | TGATTTTTTTTTTTTTTTTTTTT
137 | TGATTTTTTTTTTTTTTTTTTTT
138 | AGAAAACCCCCCCACACACACAC
139 | TGATTTTTTTTTTTTTTTTTTTT
140 | AGAAAACCCCCCCACACACACAC
141 | AGAAAACCCCCCCACACACACAC
142 | TGATTTTTTTTTTTTTTTTTTTT
143 | AGAAAACCCCCCCACACACACAC
144 | TGATTTTTTTTTTTTTTTTTTTT
145 | TGATTTTTTTTTTTTTTTTTTTT
146 | AGAAAACCCCCCCACACACACAC
147 | TGATTTTTTTTTTTTTTTTTTTT
148 | AGAAAACCCCCCCACACACACAC
149 | AGAAAACCCCCCCACACACACAC
150 | TGATTTTTTTTTTTTTTTTTTTT
151 | AGAAAACCCCCCCACACACACAC
152 | TGATTTTTTTTTTTTTTTTTTTT
153 | TGATTTTTTTTTTTTTTTTTTTT
154 | AGAAAACCCCCCCACACACACAC
155 | TGATTTTTTTTTTTTTTTTTTTT
156 | AGAAAACCCCCCCACACACACAC
157 | AGAAAACCCCCCCACACACACAC
158 | TGATTTTTTTTTTTTTTTTTTTT
159 | AGAAAACCCCCCCACACACACAC
160 | TGATTTTTTTTTTTTTTTTTTTT
161 | TGATTTTTTTTTTTTTTTTTTTT
162 | AGAAAACCCCCCCACACACACAC
163 | TGATTTTTTTTTTTTTTTTTTTT
164 | AGAAAACCCCCCCACACACACAC
165 | AGAAAACCCCCCCACACACACAC
166 | TGATTTTTTTTTTTTTTTTTTTT
167 | AGAAAACCCCCCCACACACACAC
168 | TGATTTTTTTTTTTTTTTTTTTT
169 | TGATTTTTTTTTTTTTTTTTTTT
170 | AGAAAACCCCCCCACACACACAC
171 | TGATTTTTTTTTTTTTTTTTTTT
172 | AGAAAACCCCCCCACACACACAC
173 | AGAAAACCCCCCCACACACACAC
174 | TGATTTTTTTTTTTTTTTTTTTT
175 | AGAAAACCCCCCCACACACACAC
176 | TGATTTTTTTTTTTTTTTTTTTT
177 | TGATTTTTTTTTTTTTTTTTTTT
178 | AGAAAACCCCCCCACACACACAC
179 | TGATTTTTTTTTTTTTTTTTTTT
180 | AGAAAACCCCCCCACACACACAC
181 | AGAAAACCCCCCCACACACACAC
182 | TGATTTTTTTTTTTTTTTTTTTT
183 | AGAAAACCCCCCCACACACACAC
184 | TGATTTTTTTTTTTTTTTTTTTT
185 | TGATTTTTTTTTTTTTTTTTTTT
186 | AGAAAACCCCCCCACACACACAC
187 | TGATTTTTTTTTTTTTTTTTTTT
188 | AGAAAACCCCCCCACACACACAC
189 | AGAAAACCCCCCCACACACACAC
190 | TGATTTTTTTTTTTTTTTTTTTT
191 | AGAAAACCCCCCCACACACACAC
192 | TGATTTTTTTTTTTTTTTTTTTT
193 | TGATTTTTTTTTTTTTTTTTTTT
194 | AGAAAACCCCCCCACACACACAC
195 | TGATTTTTTTTTTTTTTTTTTTT
196 | AGAAAACCCCCCCACACACACAC
197 | AGAAAACCCCCCCACACACACAC
198 | TGATTTTTTTTTTTTTTTTTTTT
199 | AGAAAACCCCCCCACACACACAC
200 | TGATTTTTTTTTTTTTTTTTTTT
201 | TGATTTTTTTTTTTTTTTTTTTT
202 | AGAAAACCCCCCCACACACACAC
203 | TGATTTTTTTTTTTTTTTTTTTT
204 | AGAAAACCCCCCCACACACACAC
205 | AGAAAACCCCCCCACACACACAC
206 | TGATTTTTTTTTTTTTTTTTTTT
207 | AGAAAACCCCCCCACACACACAC
208 | TGATTTTTTTTTTTTTTTTTTTT
209 | TGATTTTTTTTTTTTTTTTTTTT
210 | AGAAAACCCCCCCACACACACAC
211 | TGATTTTTTTTTTTTTTTTTTTT
212 | AGAAAACCCCCCCACACACACAC
213 | AGAAAACCCCCCCACACACACAC
214 | TGATTTTTTTTTTTTTTTTTTTT
215 | AGAAAACCCCCCCACACACACAC
216 | TGATTTTTTTTTTTTTTTTTTTT
217 | TGATTTTTTTTTTTTTTTTTTTT
218 | AGAAAACCCCCCCACACACACAC
219 | TGATTTTTTTTTTTTTTTTTTTT
220 | AGAAAACCCCCCCACACACACAC
221 | AGAAAACCCCCCCACACACACAC
222 | TGATTTTTTTTTTTTTTTTTTTT
223 | AGAAAACCCCCCCACACACACAC
224 | TGATTTTTTTTTTTTTTTTTTTT
225 | TGATTTTTTTTTTTTTTTTTTTT
226 | AGAAAACCCCCCCACACACACAC
227 | TGATTTTTTTTTTTTTTTTTTTT
228 | AGAAAACCCCCCCACACACACAC
229 | AGAAAACCCCCCCACACACACAC
230 | TGATTTTTTTTTTTTTTTTTTTT
231 | AGAAAACCCCCCCACACACACAC
232 | TGATTTTTTTTTTTTTTTTTTTT
233 | TGATTTTTTTTTTTTTTTTTTTT
234 | AGAAAACCCCCCCACACACACAC
235 | TGATTTTTTTTTTTTTTTTTTTT
236 | AGAAAACCCCCCCACACACACAC
237 | AGAAAACCCCCCCACACACACAC
238 | TGATTTTTTTTTTTTTTTTTTTT
239 | AGAAAACCCCCCCACACACACAC
240 | TGATTTTTTTTTTTTTTTTTTTT
241 | TGATTTTTTTTTTTTTTTTTTTT
242 | AGAAAACCCCCCCACACACACAC
243 | TGATTTTTTTTTTTTTTTTTTTT
244 | AGAAAACCCCCCCACACACACAC
245 | AGAAAACCCCCCCACACACACAC
246 | TGATTTTTTTTTTTTTTTTTTTT
247 | AGAAAACCCCCCCACACACACAC
248 | TGATTTTTTTTTTTTTTTTTTTT
249 | TGATTTTTTTTTTTTTTTTTTTT
250 | AGAAAACCCCCCCACACACACAC
251 | TGATTTTTTTTTTTTTTTTTTTT
252 | AGAAAACCCCCCCACACACACAC
253 | AGAAAACCCCCCCACACACACAC
254 | TGATTTTTTTTTTTTTTTTTTTT
255 | AGAAAACCCCCCCACACACACAC
256 | TGATTTTTTTTTTTTTTTTTTTT
257 | TGATTTTTTTTTTTTTTTTTTTT
258 | AGAAAACCCCCCCACACACACAC
259 | TGATTTTTTTTTTTTTTTTTTTT
260 | AGAAAACCCCCCCACACACACAC
261 | AGAAAACCCCCCCACACACACAC
262 | TGATTTTTTTTTTTTTTTTTTTT
263 | AGAAAACCCCCCCACACACACAC
264 | TGATTTTTTTTTTTTTTTTTTTT
265 | TGATTTTTTTTTTTTTTTTTTTT
266 | AGAAAACCCCCCCACACACACAC
267 | TGATTTTTTTTTTTTTTTTTTTT
268 | AGAAAACCCCCCCACACACACAC
269 | AGAAAACCCCCCCACACACACAC
270 | TGATTTTTTTTTTTTTTTTTTTT
271 | AGAAAACCCCCCCACACACACAC
272 | TGATTTTTTTTTTTTTTTTTTTT
273 | TGATTTTTTTTTTTTTTTTTTTT
274 | AGAAAACCCCCCCACACACACAC
275 | TGATTTTTTTTTTTTTTTTTTTT
276 | AGAAAACCCCCCCACACACACAC
277 | AGAAAACCCCCCCACACACACAC
278 | TGATTTTTTTTTTTTTTTTTTTT
279 | AGAAAACCCCCCCACACACACAC
280 | TGATTTTTTTTTTTTTTTTTTTT
281 | TGATTTTTTTTTTTTTTTTTTTT
282 | AGAAAACCCCCCCACACACACAC
283 | TGATTTTTTTTTTTTTTTTTTTT
284 | AGAAAACCCCCCCACACACACAC
285 | AGAAAACCCCCCCACACACACAC
286 | TGATTTTTTTTTTTTTTTTTTTT
287 | AGAAAACCCCCCCACACACACAC
288 | TGATTTTTTTTTTTTTTTTTTTT
289 | TGATTTTTTTTTTTTTTTTTTTT
290 | AGAAAACCCCCCCACACACACAC
291 | TGATTTTTTTTTTTTTTTTTTTT
292 | AGAAAACCCCCCCACACACACAC
293 | AGAAAACCCCCCCACACACACAC
294 | TGATTTTTTTTTTTTTTTTTTTT
295 | AGAAAACCCCCCCACACACACAC
296 | TGATTTTTTTTTTTTTTTTTTTT
297 | TGATTTTTTTTTTTTTTTTTTTT
298 | AGAAAACCCCCCCACACACACAC
299 | TGATTTTTTTTTTTTTTTTTTTT
300 | AGAAAACCCCCCCACACACACAC
301 | AGAAAACCCCCCCACACACACAC
302 | TGATTTTTTTTTTTTTTTTTTTT
303 | AGAAAACCCCCCCACACACACAC
304 | TGATTTTTTTTTTTTTTTTTTTT
305 | TGATTTTTTTTTTTTTTTTTTTT
306 | AGAAAACCCCCCCACACACACAC
307 | TGATTTTTTTTTTTTTTTTTTTT
308 | AGAAAACCCCCCCACACACACAC
309 | AGAAAACCCCCCCACACACACAC
310 | TGATTTTTTTTTTTTTTTTTTTT
311 | AGAAAACCCCCCCACACACACAC
312 | TGATTTTTTTTTTTTTTTTTTTT
313 | TGATTTTTTTTTTTTTTTTTTTT
314 | AGAAAACCCCCCCACACACACAC
315 | TGATTTTTTTTTTTTTTTTTTTT
316 | AGAAAACCCCCCCACACACACAC
317 | AGAAAACCCCCCCACACACACAC
318 | TGATTTTTTTTTTTTTTTTTTTT
319 | AGAAAACCCCCCCACACACACAC
320 | TGATTTTTTTTTTTTTTTTTTTT
321 | TGATTTTTTTTTTTTTTTTTTTT
322 | AGAAAACCCCCCCACACACACAC
323 | TGATTTTTTTTTTTTTTTTTTTT
324 | AGAAAACCCCCCCACACACACAC
325 | AGAAAACCCCCCCACACACACAC
326 | TGATTTTTTTTTTTTTTTTTTTT
327 | AGAAAACCCCCCCACACACACAC
328 | TGATTTTTTTTTTTTTTTTTTTT
329 | TGATTTTTTTTTTTTTTTTTTTT
330 | AGAAAACCCCCCCACACACACAC
331 | TGATTTTTTTTTTTTTTTTTTTT
332 | AGAAAACCCCCCCACACACACAC
333 | AGAAAACCCCCCCACACACACAC
334 | TGATTTTTTTTTTTTTTTTTTTT
335 | AGAAAACCCCCCCACACACACAC
336 | TGATTTTTTTTTTTTTTTTTTTT
337 | TGATTTTTTTTTTTTTTTTTTTT
338 | AGAAAACCCCCCCACACACACAC
339 | TGATTTTTTTTTTTTTTTTTTTT
340 | AGAAAACCCCCCCACACACACAC
341 | AGAAAACCCCCCCACACACACAC
342 | TGATTTTTTTTTTTTTTTTTTTT
343 | AGAAAACCCCCCCACACACACAC
344 | TGATTTTTTTTTTTTTTTTTTTT
345 | TGATTTTTTTTTTTTTTTTTTTT
346 | AGAAAACCCCCCCACACACACAC
347 | TGATTTTTTTTTTTTTTTTTTTT
348 | AGAAAACCCCCCCACACACACAC
349 | AGAAAACCCCCCCACACACACAC
350 | TGATTTTTTTTTTTTTTTTTTTT
351 | AGAAAACCCCCCCACACACACAC
352 | TGATTTTTTTTTTTTTTTTTTTT
353 | TGATTTTTTTTTTTTTTTTTTTT
354 | AGAAAACCCCCCCACACACACAC
355 | TGATTTTTTTTTTTTTTTTTTTT
356 | AGAAAACCCCCCCACACACACAC
357 | AGAAAACCCCCCCACACACACAC
358 | TGATTTTTTTTTTTTTTTTTTTT
359 | AGAAAACCCCCCCACACACACAC
360 | TGATTTTTTTTTTTTTTTTTTTT
361 | TGATTTTTTTTTTTTTTTTTTTT
362 | AGAAAACCCCCCCACACACACAC
363 | TGATTTTTTTTTTTTTTTTTTTT
364 | AGAAAACCCCCCCACACACACAC
365 | AGAAAACCCCCCCACACACACAC
366 | TGATTTTTTTTTTTTTTTTTTTT
367 | AGAAAACCCCCCCACACACACAC
368 | TGATTTTTTTTTTTTTTTTTTTT
369 | TGATTTTTTTTTTTTTTTTTTTT
370 | AGAAAACCCCCCCACACACACAC
371 | TGATTTTTTTTTTTTTTTTTTTT
372 | AGAAAACCCCCCCACACACACAC
373 | AGAAAACCCCCCCACACACACAC
374 | TGATTTTTTTTTTTTTTTTTTTT
375 | AGAAAACCCCCCCACACACACAC
376 | TGATTTTTTTTTTTTTTTTTTTT
377 | TGATTTTTTTTTTTTTTTTTTTT
378 | AGAAAACCCCCCCACACACACAC
379 | TGATTTTTTTTTTTTTTTTTTTT
380 | AGAAAACCCCCCCACACACACAC
381 | AGAAAACCCCCCCACACACACAC
382 | TGATTTTTTTTTTTTTTTTTTTT
383 | AGAAAACCCCCCCACACACACAC
384 | TGATTTTTTTTTTTTTTTTTTTT
385 | TGATTTTTTTTTTTTTTTTTTTT
386 | AGAAAACCCCCCCACACACACAC
387 | TGATTTTTTTTTTTTTTTTTTTT
388 | AGAAAACCCCCCCACACACACAC
389 | AGAAAACCCCCCCACACACACAC
390 | TGATTTTTTTTTTTTTTTTTTTT
391 | AGAAAACCCCCCCACACACACAC
392 | TGATTTTTTTTTTTTTTTTTTTT
393 | TGATTTTTTTTTTTTTTTTTTTT
394 | AGAAAACCCCCCCACACACACAC
395 | TGATTTTTTTTTTTTTTTTTTTT
396 | AGAAAACCCCCCCACACACACAC
397 | AGAAAACCCCCCCACACACACAC
398 | TGATTTTTTTTTTTTTTTTTTTT
399 | AGAAAACCCCCCCACACACACAC
400 | TGATTTTTTTTTTTTTTTTTTTT
401 | TGATTTTTTTTTTTTTTTTTTTT
402 | AGAAAACCCCCCCACACACACAC
403 | TGATTTTTTTTTTTTTTTTTTTT
404 | AGAAAACCCCCCCACACACACAC
405 | AGAAAACCCCCCCACACACACAC
406 | TGATTTTTTTTTTTTTTTTTTTT
407 | AGAAAACCCCCCCACACACACAC
408 | TGATTTTTTTTTTTTTTTTTTTT
409 | TGATTTTTTTTTTTTTTTTTTTT
410 | AGAAAACCCCCCCACACACACAC
411 | TGATTTTTTTTTTTTTTTTTTTT
412 | AGAAAACCCCCCCACACACACAC
413 | AGAAAACCCCCCCACACACACAC
414 | TGATTTTTTTTTTTTTTTTTTTT
415 | AGAAAACCCCCCCACACACACAC
416 | TGATTTTTTTTTTTTTTTTTTTT
417 | TGATTTTTTTTTTTTTTTTTTTT
418 | AGAAAACCCCCCCACACACACAC
419 | TGATTTTTTTTTTTTTTTTTTTT
420 | AGAAAACCCCCCCACACACACAC
421 | AGAAAACCCCCCCACACACACAC
422 | TGATTTTTTTTTTTTTTTTTTTT
423 | AGAAAACCCCCCCACACACACAC
424 | TGATTTTTTTTTTTTTTTTTTTT
425 | TGATTTTTTTTTTTTTTTTTTTT
426 | AGAAAACCCCCCCACACACACAC
427 | TGATTTTTTTTTTTTTTTTTTTT
428 | AGAAAACCCCCCCACACACACAC
429 | AGAAAACCCCCCCACACACACAC
430 | TGATTTTTTTTTTTTTTTTTTTT
431 | AGAAAACCCCCCCACACACACAC
432 | TGATTTTTTTTTTTTTTTTTTTT
433 | TGATTTTTTTTTTTTTTTTTTTT
434 | AGAAAACCCCCCCACACACACAC
435 | TGATTTTTTTTTTTTTTTTTTTT
436 | AGAAAACCCCCCCACACACACAC
437 | AGAAAACCCCCCCACACACACAC
438 | TGATTTTTTTTTTTTTTTTTTTT
439 | AGAAAACCCCCCCACACACACAC
440 | TGATTTTTTTTTTTTTTTTTTTT
441 | TGATTTTTTTTTTTTTTTTTTTT
442 | AGAAAACCCCCCCACACACACAC
443 | TGATTTTTTTTTTTTTTTTTTTT
444 | AGAAAACCCCCCCACACACACAC
445 | AGAAAACCCCCCCACACACACAC
446 | TGATTTTTTTTTTTTTTTTTTTT
447 | AGAAAACCCCCCCACACACACAC
448 | TGATTTTTTTTTTTTTTTTTTTT
449 | TGATTTTTTTTTTTTTTTTTTTT
450 | AGAAAACCCCCCCACACACACAC
451 | TGATTTTTTTTTTTTTTTTTTTT
452 | AGAAAACCCCCCCACACACACAC
453 | AGAAAACCCCCCCACACACACAC
454 | TGATTTTTTTTTTTTTTTTTTTT
455 | AGAAAACCCCCCCACACACACAC
456 | TGATTTTTTTTTTTTTTTTTTTT
457 | TGATTTTTTTTTTTTTTTTTTTT
458 | AGAAAACCCCCCCACACACACAC
459 | TGATTTTTTTTTTTTTTTTTTTT
460 | AGAAAACCCCCCCACACACACAC
461 | AGAAAACCCCCCCACACACACAC
462 | TGATTTTTTTTTTTTTTTTTTTT
463 | AGAAAACCCCCCCACACACACAC
464 | TGATTTTTTTTTTTTTTTTTTTT
465 | TGATTTTTTTTTTTTTTTTTTTT
466 | AGAAAACCCCCCCACACACACAC
467 | TGATTTTTTTTTTTTTTTTTTTT
468 | AGAAAACCCCCCCACACACACAC
469 | AGAAAACCCCCCCACACACACAC
470 | TGATTTTTTTTTTTTTTTTTTTT
471 | AGAAAACCCCCCCACACACACAC
472 | TGATTTTTTTTTTTTTTTTTTTT
473 | TGATTTTTTTTTTTTTTTTTTTT
474 | AGAAAACCCCCCCACACACACAC
475 | TGATTTTTTTTTTTTTTTTTTTT
476 | AGAAAACCCCCCCACACACACAC
477 | AGAAAACCCCCCCACACACACAC
478 | TGATTTTTTTTTTTTTTTTTTTT
479 | AGAAAACCCCCCCACACACACAC
480 | TGATTTTTTTTTTTTTTTTTTTT
481 | TGATTTTTTTTTTTTTTTTTTTT
482 | AGAAAACCCCCCCACACACACAC
483 | TGATTTTTTTTTTTTTTTTTTTT
484 | AGAAAACCCCCCCACACACACAC
485 | AGAAAACCCCCCCACACACACAC
486 | TGATTTTTTTTTTTTTTTTTTTT
487 | AGAAAACCCCCCCACACACACAC
488 | TGATTTTTTTTTTTTTTTTTTTT
489 | TGATTTTTTTTTTTTTTTTTTTT
490 | AGAAAACCCCCCCACACACACAC
491 | TGATTTTTTTTTTTTTTTTTTTT
492 | AGAAAACCCCCCCACACACACAC
493 | AGAAAACCCCCCCACACACACAC
494 | TGATTTTTTTTTTTTTTTTTTTT
495 | AGAAAACCCCCCCACACACACAC
496 | TGATTTTTTTTTTTTTTTTTTTT
497 | TGATTTTTTTTTTTTTTTTTTTT
498 | AGAAAACCCCCCCACACACACAC
499 | TGATTTTTTTTTTTTTTTTTTTT
500 | AGAAAACCCCCCCACACACACAC
501 | AGAAAACCCCCCCACACACACAC
502 | TGATTTTTTTTTTTTTTTTTTTT
503 | AGAAAACCCCCCCACACACACAC
504 | TGATTTTTTTTTTTTTTTTTTTT
505 | TGATTTTTTTTTTTTTTTTTTTT
506 | AGAAAACCCCCCCACACACACAC
507 | TGATTTTTTTTTTTTTTTTTTTT
508 | AGAAAACCCCCCCACACACACAC
509 | AGAAAACCCCCCCACACACACAC
510 | TGATTTTTTTTTTTTTTTTTTTT
511 | AGAAAACCCCCCCACACACACAC
512 | TGATTTTTTTTTTTTTTTTTTTT
513 | TGATTTTTTTTTTTTTTTTTTTT
514 | AGAAAACCCCCCCACACACACAC
515 | TGATTTTTTTTTTTTTTTTTTTT
516 | AGAAAACCCCCCCACACACACAC
517 | AGAAAACCCCCCCACACACACAC
518 | TGATTTTTTTTTTTTTTTTTTTT
519 | AGAAAACCCCCCCACACACACAC
520 | TGATTTTTTTTTTTTTTTTTTTT
521 | TGATTTTTTTTTTTTTTTTTTTT
522 | AGAAAACCCCCCCACACACACAC
523 | TGATTTTTTTTTTTTTTTTTTTT
524 | AGAAAACCCCCCCACACACACAC
525 | AGAAAACCCCCCCACACACACAC
526 | TGATTTTTTTTTTTTTTTTTTTT
527 | AGAAAACCCCCCCACACACACAC
528 | TGATTTTTTTTTTTTTTTTTTTT
529 | TGATTTTTTTTTTTTTTTTTTTT
530 | AGAAAACCCCCCCACACACACAC
531 | TGATTTTTTTTTTTTTTTTTTTT
532 | AGAAAACCCCCCCACACACACAC
533 | AGAAAACCCCCCCACACACACAC
534 | TGATTTTTTTTTTTTTTTTTTTT
535 | AGAAAACCCCCCCACACACACAC
536 | TGATTTTTTTTTTTTTTTTTTTT
537 | TGATTTTTTTTTTTTTTTTTTTT
538 | AGAAAACCCCCCCACACACACAC
539 | TGATTTTTTTTTTTTTTTTTTTT
540 | AGAAAACCCCCCCACACACACAC
541 | AGAAAACCCCCCCACACACACAC
542 | TGATTTTTTTTTTTTTTTTTTTT
543 | AGAAAACCCCCCCACACACACAC
544 | TGATTTTTTTTTTTTTTTTTTTT
545 | TGATTTTTTTTTTTTTTTTTTTT
546 | AGAAAACCCCCCCACACACACAC
547 | TGATTTTTTTTTTTTTTTTTTTT
548 | AGAAAACCCCCCCACACACACAC
549 | AGAAAACCCCCCCACACACACAC
550 | TGATTTTTTTTTTTTTTTTTTTT
551 | AGAAAACCCCCCCACACACACAC
552 | TGATTTTTTTTTTTTTTTTTTTT
553 | TGATTTTTTTTTTTTTTTTTTTT
554 | AGAAAACCCCCCCACACACACAC
555 | TGATTTTTTTTTTTTTTTTTTTT
556 | AGAAAACCCCCCCACACACACAC
557 | AGAAAACCCCCCCACACACACAC
558 | TGATTTTTTTTTTTTTTTTTTTT
559 | AGAAAACCCCCCCACACACACAC
560 | TGATTTTTTTTTTTTTTTTTTTT
561 | TGATTTTTTTTTTTTTTTTTTTT
562 | AGAAAACCCCCCCACACACACAC
563 | TGATTTTTTTTTTTTTTTTTTTT
564 | AGAAAACCCCCCCACACACACAC
565 | AGAAAACCCCCCCACACACACAC
566 | TGATTTTTTTTTTTTTTTTTTTT
567 | AGAAAACCCCCCCACACACACAC
568 | TGATTTTTTTTTTTTTTTTTTTT
569 | TGATTTTTTTTTTTTTTTTTTTT
570 | AGAAAACCCCCCCACACACACAC
571 | TGATTTTTTTTTTTTTTTTTTTT
572 | AGAAAACCCCCCCACACACACAC
573 | AGAAAACCCCCCCACACACACAC
574 | TGATTTTTTTTTTTTTTTTTTTT
575 | AGAAAACCCCCCCACACACACAC
576 | TGATTTTTTTTTTTTTTTTTTTT
577 | TGATTTTTTTTTTTTTTTTTTTT
578 | AGAAAACCCCCCCACACACACAC
579 | TGATTTTTTTTTTTTTTTTTTTT
580 | AGAAAACCCCCCCACACACACAC
581 | AGAAAACCCCCCCACACACACAC
582 | TGATTTTTTTTTTTTTTTTTTTT
583 | AGAAAACCCCCCCACACACACAC
584 | TGATTTTTTTTTTTTTTTTTTTT
585 | TGATTTTTTTTTTTTTTTTTTTT
586 | AGAAAACCCCCCCACACACACAC
587 | TGATTTTTTTTTTTTTTTTTTTT
588 | AGAAAACCCCCCCACACACACAC
589 | AGAAAACCCCCCCACACACACAC
590 | TGATTTTTTTTTTTTTTTTTTTT
591 | AGAAAACCCCCCCACACACACAC
592 | TGATTTTTTTTTTTTTTTTTTTT
593 | TGATTTTTTTTTTTTTTTTTTTT
594 | AGAAAACCCCCCCACACACACAC
595 | TGATTTTTTTTTTTTTTTTTTTT
596 | AGAAAACCCCCCCACACACACAC
597 | AGAAAACCCCCCCACACACACAC
598 | TGATTTTTTTTTTTTTTTTTTTT
599 | AGAAAACCCCCCCACACACACAC
600 | TGATTTTTTTTTTTTTTTTTTTT
601 | TGATTTTTTTTTTTTTTTTTTTT
602 | AGAAAACCCCCCCACACACACAC
603 | TGATTTTTTTTTTTTTTTTTTTT
604 | AGAAAACCCCCCCACACACACAC
605 | AGAAAACCCCCCCACACACACAC
606 | TGATTTTTTTTTTTTTTTTTTTT
607 | AGAAAACCCCCCCACACACACAC
608 | TGATTTTTTTTTTTTTTTTTTTT
609 | TGATTTTTTTTTTTTTTTTTTTT
610 | AGAAAACCCCCCCACACACACAC
611 | TGATTTTTTTTTTTTTTTTTTTT
612 | AGAAAACCCCCCCACACACACAC
613 | AGAAAACCCCCCCACACACACAC
614 | TGATTTTTTTTTTTTTTTTTTTT
615 | AGAAAACCCCCCCACACACACAC
616 | TGATTTTTTTTTTTTTTTTTTTT
617 | TGATTTTTTTTTTTTTTTTTTTT
618 | AGAAAACCCCCCCACACACACAC
619 | TGATTTTTTTTTTTTTTTTTTTT
620 | AGAAAACCCCCCCACACACACAC
621 | AGAAAACCCCCCCACACACACAC
622 | TGATTTTTTTTTTTTTTTTTTTT
623 | AGAAAACCCCCCCACACACACAC
624 | TGATTTTTTTTTTTTTTTTTTTT
625 | TGATTTTTTTTTTTTTTTTTTTT
626 | AGAAAACCCCCCCACACACACAC
627 | TGATTTTTTTTTTTTTTTTTTTT
628 | AGAAAACCCCCCCACACACACAC
629 | AGAAAACCCCCCCACACACACAC
630 | TGATTTTTTTTTTTTTTTTTTTT
631 | AGAAAACCCCCCCACACACACAC
632 | TGATTTTTTTTTTTTTTTTTTTT
633 | TGATTTTTTTTTTTTTTTTTTTT
634 | AGAAAACCCCCCCACACACACAC
635 | TGATTTTTTTTTTTTTTTTTTTT
636 | AGAAAACCCCCCCACACACACAC
637 | AGAAAACCCCCCCACACACACAC
638 | TGATTTTTTTTTTTTTTTTTTTT
639 | AGAAAACCCCCCCACACACACAC
640 | TGATTTTTTTTTTTTTTTTTTTT
641 | TGATTTTTTTTTTTTTTTTTTTT
642 | AGAAAACCCCCCCACACACACAC
643 | TGATTTTTTTTTTTTTTTTTTTT
644 | AGAAAACCCCCCCACACACACAC
645 | AGAAAACCCCCCCACACACACAC
646 | TGATTTTTTTTTTTTTTTTTTTT
647 | AGAAAACCCCCCCACACACACAC
648 | TGATTTTTTTTTTTTTTTTTTTT
649 | TGATTTTTTTTTTTTTTTTTTTT
650 | AGAAAACCCCCCCACACACACAC
651 | TGATTTTTTTTTTTTTTTTTTTT
652 | AGAAAACCCCCCCACACACACAC
653 | AGAAAACCCCCCCACACACACAC
654 | TGATTTTTTTTTTTTTTTTTTTT
655 | AGAAAACCCCCCCACACACACAC
656 | TGATTTTTTTTTTTTTTTTTTTT
657 | TGATTTTTTTTTTTTTTTTTTTT
658 | AGAAAACCCCCCCACACACACAC
659 | TGATTTTTTTTTTTTTTTTTTTT
660 | AGAAAACCCCCCCACACACACAC
661 | AGAAAACCCCCCCACACACACAC
662 | TGATTTTTTTTTTTTTTTTTTTT
663 | AGAAAACCCCCCCACACACACAC
664 | TGATTTTTTTTTTTTTTTTTTTT
665 | TGATTTTTTTTTTTTTTTTTTTT
666 | AGAAAACCCCCCCACACACACAC
667 | TGATTTTTTTTTTTTTTTTTTTT
668 | AGAAAACCCCCCCACACACACAC
669 | AGAAAACCCCCCCACACACACAC
670 | TGATTTTTTTTTTTTTTTTTTTT
671 | AGAAAACCCCCCCACACACACAC
672 | TGATTTTTTTTTTTTTTTTTTTT
673 | TGATTTTTTTTTTTTTTTTTTTT
674 |
--------------------------------------------------------------------------------
/hts/test/t2.fa.fai:
--------------------------------------------------------------------------------
1 | chr2L 15456 7 23 24
2 |
--------------------------------------------------------------------------------
/hts/test/test_hts.py:
--------------------------------------------------------------------------------
1 | import os
2 | from hts import Bam
3 |
4 | HERE = os.path.dirname(__file__)
5 |
6 | SAM = os.path.join(HERE, "e.sam")
7 | AUX_SAM = os.path.join(HERE, "t.sam")
8 |
9 | def test_aux():
10 |
11 | b = Bam(SAM)
12 | r = next(b)
13 | assert r.tags == [('NH', 'C', 1)], r.aux
14 |
15 | def test_tname():
16 | b = Bam(SAM)
17 | r = next(b)
18 | assert r.target is None
19 |
20 |
21 |
22 | def test_aux_bam():
23 |
24 | bam = Bam(AUX_SAM)
25 |
26 | aln = next(bam)
27 | assert aln.tags == [('MC', 'Z', '101M'), ('MD', 'Z', '16T2C80'), ('PG', 'Z', 'bwa-meth'), ('RG', 'Z', '44_Mm08_WEAd_Db2_WGBS_E_1_L001__trimmed'), ('NM', 'C', 28), ('MQ', 'C', 60), ('UQ', 'S', 1064), ('AS', 'C', 87), ('XS', 'C', 101)], aln.tags
28 | aln = next(bam)
29 | assert aln.tags == [('MC', 'Z', '7M1D94M'), ('MD', 'Z', '9T2C87'), ('PG', 'Z', 'bwa-meth'), ('RG', 'Z', '44_Mm08_WEAd_Db2_WGBS_E_1_L001__trimmed'), ('NM', 'C', 27), ('MQ', 'C', 25), ('UQ', 'S', 981), ('AS', 'C', 87), ('XS', 'C', 101)]
30 |
--------------------------------------------------------------------------------
/hts/test/test_tbx.py:
--------------------------------------------------------------------------------
1 | import os
2 | from hts import Tbx
3 | from nose.tools import assert_raises
4 |
5 | HERE = os.path.dirname(__file__)
6 | GTF = os.path.join(HERE, "example.gtf.gz")
7 | BAM = os.path.join(HERE, "e.sam")
8 |
9 | def test_build():
10 | if os.path.exists(GTF + ".tbi"):
11 | os.unlink(GTF + ".tbi")
12 | t = Tbx(GTF)
13 | assert t._tbx
14 | assert os.path.exists(GTF + ".tbi")
15 |
16 | def test_error_on_bad_file():
17 | assert_raises(Exception, Tbx, BAM)
18 |
19 |
--------------------------------------------------------------------------------
/hts/vcf.py:
--------------------------------------------------------------------------------
1 | from __future__ import print_function
2 | import os
3 | import sys
4 | from .htsffi import libhts, ffi, _raise_if_null
5 |
6 |
7 | class VCF(object):
8 | r"""
9 |
10 | >>> import os.path as op
11 | >>> vcf = VCF('%s/test/test.query.vcf' % op.dirname(__file__))
12 | >>> vcf #doctest: +ELLIPSIS
13 | VCF('...')
14 |
15 | >>> v = next(vcf)
16 | >>> v
17 | Variant('chr1:30547')
18 |
19 | >>> v.genotypes[:10]
20 | [2, 2, 2, 2, 2, 2, 0, 2, 2, 2]
21 |
22 | """
23 |
24 | def __init__(self, fname, mode="r"):
25 | if not os.path.exists(fname):
26 | raise Exception("%s not found" % fname)
27 | htf = self._htf = libhts.hts_open(fname, mode)
28 | hdr = self._hdr = libhts.bcf_hdr_read(htf)
29 | assert libhts.bcf_hdr_set_samples(hdr, "-", 0) == 0, ("error setting samples")
30 | self.fname = fname
31 |
32 | def __repr__(self):
33 | return "%s('%s')" % (self.__class__.__name__, self.fname)
34 |
35 | def __iter__(self):
36 | return self
37 |
38 | def __next__(self):
39 | bcf_t = libhts.bcf_init()
40 | if libhts.bcf_read(self._htf, self._hdr, bcf_t) >= 0:
41 | return Variant(bcf_t, self)
42 | raise StopIteration
43 |
44 | next = __next__
45 |
46 | def seq(self, tid):
47 | s = libhts.bcf_hdr_id2name(self._hdr, tid)
48 | return ffi.string(s)
49 |
50 | @property
51 | def n_samples(self):
52 | return self._hdr.n[libhts.BCF_DT_SAMPLE]
53 |
54 | class Variant(object):
55 | """Variants are created from VCF"""
56 |
57 | def __init__(self, bcf_t, vcf):
58 | self._bcf = bcf_t
59 | libhts.bcf_unpack(bcf_t, 15) # unpack everything.
60 |
61 | self.vcf = vcf
62 | self.chrom = vcf.seq(bcf_t.rid)
63 | self.pos = bcf_t.pos
64 |
65 | def __repr__(self):
66 | return "%s('%s:%d')" % (self.__class__.__name__, self.chrom, self.pos)
67 |
68 | @property
69 | def formats(self):
70 | return Format(self._bcf.d.fmt)
71 |
72 | @property
73 | def genotypes(self):
74 |
75 | dst = ffi.new("int **")
76 | ndst = ffi.new("int *")
77 | n_gts = libhts.bcf_get_genotypes(self.vcf._hdr, self._bcf, dst, ndst)
78 |
79 | if n_gts < 0:
80 | raise Exception("cant pull genotypes")
81 |
82 | n_samples = self.vcf.n_samples
83 | gts_per_sample = n_gts / n_samples
84 | if gts_per_sample != 2:
85 | return [None] * n_samples
86 |
87 | n = libhts.as_gts(dst[0], n_samples)
88 | assert n == n_samples, ("incorrect number of genotypes, got", n, "expected", n_samples)
89 | try:
90 | return [dst[0][i] for i in range(n_samples)]
91 | finally:
92 | libhts.free(dst[0])
93 |
94 | gt_types = genotypes
95 |
96 | class Format(object):
97 | def __init__(self, fmt_t):
98 | self._fmt_t = fmt_t
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/nose.cfg:
--------------------------------------------------------------------------------
1 | with-doctest=yes
2 | sdf
3 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | cffi
2 |
--------------------------------------------------------------------------------
/setup.cfg:
--------------------------------------------------------------------------------
1 | [nosetests]
2 | verbosity=1
3 | detailed-errors=0
4 | with-doctest=1
5 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | from setuptools import setup
2 | from glob import glob
3 |
4 | import hts.htsffi
5 | import cffi
6 |
7 | # from mpld3
8 | def get_version(fname):
9 | """Get the version info from the mpld3 package without importing it"""
10 | import ast
11 |
12 | with open(fname) as init_file:
13 | module = ast.parse(init_file.read())
14 |
15 | version = (ast.literal_eval(node.value) for node in ast.walk(module)
16 | if isinstance(node, ast.Assign)
17 | and node.targets[0].id == "__version__")
18 | try:
19 | return next(version)
20 | except StopIteration:
21 | raise ValueError("version could not be located")
22 |
23 |
24 | #cffi.verifier.cleanup_tmpdir()
25 | ext = hts.htsffi.ffi.verifier.get_extension()
26 |
27 | setup(name='hts',
28 | version=get_version("hts/__init__.py"),
29 | packages=['hts'],
30 | package_data={'hts': ["hts/hts_concat.h", "hts/hts_extra.h", "hts/hts_extra.c"]},
31 | ext_package='hts',
32 | include_package_data=True,
33 | ext_modules=[ext],
34 | zip_safe=False,
35 | install_requires=['cffi', 'setuptools>=0.6c11'],
36 | setup_requires=['nose>=1.0'],
37 |
38 | )
39 |
40 |
41 | from hts import htsffi
42 |
--------------------------------------------------------------------------------
\ 689 | Sort by:\ 690 | best rated\ 691 | newest\ 692 | oldest\ 693 |
\ 694 |\ 698 |
Add a comment\ 700 | (markup):
\ 701 |``code``
, \ 704 | code blocks:::
and an indented block after blank line