Exemplo n.º 1
0
 def read_as_intervaltree(self):
     '''
     Reads the data from a 'bed' file into an ``intervaltree.bio.GenomeIntervalTree`` data structure.
     Similarly to ``open`` and ``open_text`` it won't download file to cache, if it is not there.
     Reads the whole file to memory during its work.
     
     The file must be a `bed` or `bed.gz` file.
     The ``data`` field of each interval will contain the result of ``ln.split('\t')[3:]`` applied to the corresponding line of the ``bed`` file.
     
     Returns:
         a GenomeIntervalTree instance.
     '''
     assert self['type'] in ['bed', 'narrowPeak', 'broadPeak']
     
     with self.open_text() as f:
         gtree = GenomeIntervalTree.from_bed(fileobj=f)
     return gtree