moca.bedoperations package

Submodules

moca.bedoperations.model module

class moca.bedoperations.model.Bedfile(filepath, genome_table, output_dir=None)[source]

Bases: future.types.newobject.newobject

Class to crate a bed file object

Parameters:
  • filepath (string) – Absolute path to bedfile
  • genome_table (string) – Absolute path to geonme chromosome size file
  • output_dir (string) – Output directory
extract_fasta(bed_in, fasta_in, fasta_out=None)[source]

Extract fasta of bed regions

Parameters:
  • bed_in (string) – Path to input bed
  • fasta_in (string) – Absolute path to location of reference fasta file
  • fasta_out (string) – Path to write extracted fasta sequence
Returns:

fasta – Fasta sequence combined

Return type:

string

get_total_peaks
guess_bedformat()[source]

Method to guess bed format

Returns:
  • bed_format (string) – BED format
  • Example – >>> bed_df = Bedfile(‘file.bed’) >>> print(bed_df.guess_bed_format())
slop_bed(bed_in, flank_length=50)[source]

Add flanking sequences to bed file

Parameters:
  • bed_in (string) – Path to input bed file
  • flank_length (int) – the bed region is expanded in both direction by flank_length number of bases
Returns:

slopped_bed – Slopped bed data object

Return type:

dataframe

sort_by(columns=None, ascending=False)[source]

Method to sort columns of bedfiles

Parameters:
  • columns (list) – list of column names to sort by
  • ascending (bool) – Sort order(Default: true)
Returns:

sorted_bed_df – dataframe with sorted columns

Return type:

dataframe

split_train_test_bed(train_peaks_count=500, test_peaks_count=500, train_suffix='train', test_suffix='test')[source]

Split bedfile into ranked training and testing sets

Training set consists of top train_peaks_count peaks while testing set will consist of next test_peaks_count ranked peaks

Parameters:
  • train_peaks_count (int) – Count of training peaks
  • test_peaks_count (int) – Count of testing peaks
write_to_scorefile(bed_df, out_suffix='sorted')[source]

Write bed file as score file

Module contents