API Reference

A python module for using rust to access data from fiberseq BAM files.

class pyft.Fiberbam(bam_file, threads=8)

Bases: object

Open a fiberseq bam file. Must have an index.

center(chrom, start, end, strand='+')

Returns an iterator over Fiberdata objects; however, the data is centered around the region that has been fetched (should work the same as ft center).

fetch(chrom, start=None, end=None)

Returns an iterator over Fiberdata objects for the selected region. Arguments for the region to fetch can be provided in multiple ways, e.g.:

fiberdata.fetch(“chr1”, 100, 200)

fiberdata.fetch(“chr1”, start=100, end=200)

fiberdata.fetch(“chr1:100-200”)

fiberdata.fetch(“chr1”)

class pyft.Fiberdata

Bases: object

Class for fiberseq data. This class corresponds to a single record in the bam file.

aligned_block_pairs

Aligned block pairs from the bam record

chrom

Chromosome

cpg

cpg Basemods object

ec

Number of c_s

end

Chromosome end

get_seq_length()

return the length of the sequence

hp

Haplotype tag

lift_query_positions(positions)

liftover query (fiber) positions to the reference

lift_reference_positions(positions)

liftover reference positions to the query (fiber)

m6a

m6a Basemods object

msp

Ranges object for msp features

nuc

Ranges object for nuc features

offset

offset for centering the fiber

qname

Name of the read

rg

Read group

rq

Read quality

sam_flag

SAM flag

seq

Read sequence

start

Chromosome start

strand

Strand

class pyft.Basemods(starts, reference_starts, ml)

Bases: object

Class for describing base modifications within fiberseq data. For example, m6a and 5mC (cpg) features.

get_ends()

return ends, start + 1

get_reference_ends()

return reference ends, start + 1

ml

Basemod ML

reference_starts

Basemod reference starts

starts

Basemod starts

class pyft.Ranges(starts, lengths, qual, reference_starts, reference_lengths)

Bases: object

Class for describing ranges within fiberseq data. For example, nucleosomes and msp features.

ends

Range ends

lengths

Range lengths

qual

quals

reference_ends

Reference ends

reference_lengths

Reference lengths

reference_starts

Reference starts

starts

Range starts

class pyft.Fiberwriter(output_bam_path, template_bam_path)

Bases: object

write(fiberdata)

Write a Fiberdata object to a bam file.

utils.empty_data_dict()[source]
utils.footprint_code_to_vec(footprint_code, n_modules)[source]

Convert a footprint code to a boolean vector of length n_modules

utils.read_footprint_table(f, long=False)[source]

Read a ft-footprint bed into a pandas dataframe

utils.read_and_center_footprint_table(f)[source]

Read a ft-footprint bed into a pandas dataframe and reformat the data to reflect ft-center output

utils.read_center_table(f)[source]

Read a ft-center bed into a pandas dataframe

utils.region_to_centered_df(fiberbam, region, strand='+', max_flank=None, min_basemod_qual=125)[source]

Takes a fiberbam and a region and returns a pandas dataframe with reference centered positions

utils.region_to_df(fiberbam, region, min_basemod_qual=125)[source]

Takes a fiberbam and a region and returns a pandas dataframe with fibers that overlap the region