Skip to content

Commit 2a69e47

Browse files
committed
Update documentation a bit
1 parent 8237ddb commit 2a69e47

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Table of Contents
1515
* [Print file information](#print-file-information)
1616
* [Fetch a sequence](#fetch-a-sequence)
1717
* [Fetch per-base statistics](#fetch-per-base-statistics)
18+
* [Fetch masked blocks](#fetch-masked-blocks)
1819
* [A note on coordinates](#a-note-on-coordinates)
1920

2021
# Installation
@@ -108,6 +109,31 @@ If integer counts are preferred, then they can instead be returned.
108109
>>> tb.bases("chr1", 24, 74, False)
109110
{'A': 6, 'C': 6, 'T': 6, 'G': 6}
110111

112+
## Fetch masked blocks
113+
114+
There are two kinds of masking blocks that can be present in 2bit files: hard-masked and soft-masked. Hard-masked blocks are stretches of NNNN, as are commonly found near telomeres and centromeres. Soft-masked blocks are runs of lowercase A/C/T/G, typically indicating repeat elements or low-complexity stretches. In can sometimes be useful to query this information from 2bit files:
115+
116+
>>> tb.hardMaskedBlocks("chr1")
117+
[(0, 50), (100, 150)]
118+
119+
In this (small) example, there are two stretches of hard-masked sequence, from 0 to 50 and again from 100 to 150 (see the note below about coordinates). If you would instead like to query all blocks overlapping with a specific region, you can specify the region bounds:
120+
121+
>>> tb.hardMaskedBlocks("chr1", 75, 101)
122+
[(100, 150)]
123+
124+
If there are no overlapping regions, then an empty list is returned:
125+
126+
>>> tb.hardMaskedBlocks("chr1", 75, 100)
127+
[]
128+
129+
Instead of `hardMaskedBlocks()`, one can use `softMaskedBlocks()` in an identical manner:
130+
131+
>>> tb = py2bit.open("foo.2bit", storeMasked=True)
132+
>>> tb.softMaskedBlocks("chr1")
133+
[(62, 70)]
134+
135+
As shown, you **must** specify `storeMasked=True` or you will receive a run time error.
136+
111137
## Close a file
112138

113139
A `TwoBit` object can be closed with the `close()` method.

0 commit comments

Comments
 (0)