Entering edit mode
21 months ago
Manuel
▴
40
I need to import the data of one bed file into GenomeIntervalTree.from_bed().
Looking the code, there are some examples
test_url = 'http://hgdownload.cse.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeAwgTfbsUniform/wgEncodeAwgTfbsBroadDnd41Ezh239875UniPk.narrowPeak.gz'
data = zlib.decompress(urlopen(test_url).read(), 16+zlib.MAX_WBITS)
gtree = GenomeIntervalTree.from_bed(BytesIO(data))
But in this example, data is taken from a url then decompressed, read and them imported. I have been working around to do the same but having the bed file in my computer. How can I do this?
Thanks!
EDIT
And then, following their example, the search method seems no work to me
Example::
gtree[b'chr10'].search(22610878)
Traceback (most recent call last):
File "C:\Users\User\Desktop\myeloid-coverage-script\myeloid_transfer.py", line 49, in <module>
roi_data = roi2(file_path, bedregions)
File "C:\Users\User\Desktop\myeloid-coverage-script\bin\Coverage2.py", line 71, in roi2
gtree[b'chr10'].search(22610878)
AttributeError: 'IntervalTree' object has no attribute 'search'
code taken from https://github.com/konstantint/intervaltree-bio/blob/master/intervaltree_bio/__init__.py