Skip to content

I/O Module

class BedSet(region_sets: Union[List[RegionSet], List[str], List[List[Region]], None] = None, file_path: str = None, identifier: str = None)

BedSet object

Initialize a BedSet object.

Args: region_sets: list of BED file paths, RegionSet, or 2-dimension list of Region. Defaults to None (empty BedSet). file_path (str): path to the .txt file with identifier of all BED files in it identifier (str): the identifier of the BED set

  • region_sets

@property
def identifier -> str

def add(bedfile: RegionSet) -> NoReturn

Add a BED file to the BED set.

Warning: if new bedfile will be added, bedSet identifier will be changed!

Args: bedfile (RegionSet): RegionSet instance, that should be added to the bedSet

def compute_bedset_identifier() -> str

Return the identifier. If it is not set, compute one.

Returns: str: the identifier of BED set

class RegionSet(regions: Union[str, List[Region]], backed: bool = False)

Instantiate a RegionSet object. This can be backed or not backed. It represents a set of genomic regions.

If you specify backed as True, then the bed file will not be loaded into memory. This is useful for large bed files. You can still iterate over the regions, but you cannot index into them.

Args: regions: path, or url to bed file or list of Region objects backed (bool): whether to load the bed file into memory or not. Defaults to False.

  • backed
  • regions (List[Region])
  • path
  • is_gzipped
  • length

@property
def identifier -> str

def to_pandas() -> Union[pd.DataFrame, None]

def to_granges()

Return GenomicRanges contained in this BED file.

Returns: genomicranges.GenomicRanges: GenomicRanges object

def compute_bed_identifier() -> str

Return bed file identifier. If it is not set, compute one.

Returns: str: the identifier of BED file

class Region(chr: str, start: int, stop: int)

Instantiate a Region object.

Args: chr (str): chromosome start (int): start position stop (int): stop position

  • chr
  • start
  • end