API

ribocore (common functions)

Common functions.

exception riboplot.ribocore.ArgumentError[source]

Raised when invalid arguments are sent in the command line.

exception riboplot.ribocore.BamFileError[source]

Errors related to BAM file

exception riboplot.ribocore.RNACountsError[source]

For errors related to RNA Coverage generation using bedtools.

exception riboplot.ribocore.RiboCountError[source]

General errors relating to ribocount.

exception riboplot.ribocore.RiboPlotError[source]

General errors relating to riboplot.

riboplot.ribocore.bam_has_index(bam_file)[source]

Check if bam file has an index. Returns True/False.

riboplot.ribocore.check_read_lengths(ribo_file, read_lengths)[source]

Check if read lengths are valid (positive).

riboplot.ribocore.check_read_lengths_offsets(read_lengths, read_offsets)[source]

Check if read length has corresponding read offset for all read lengths.

riboplot.ribocore.check_read_offsets(read_offsets)[source]

Check if read offsets are valid (positive).

riboplot.ribocore.check_required_arguments(ribo_file, transcriptome_fasta, transcript_name=None)[source]

Check required arguments of both riboplot and ribocount.

riboplot.ribocore.check_rna_file(rna_file)[source]

Check if bedtools is available and if the given RNA-Seq bam file is valid.

riboplot.ribocore.create_bam_index(bam_file)[source]

Create an index for the given BAM file.

riboplot.ribocore.filter_ribo_counts(counts, orf_start=None, orf_stop=None)[source]

Filter read counts and return only upstream of orf_start or downstream of orf_stop.

Keyword arguments: counts – Ribo-Seq read counts obtained from get_ribo_counts. orf_start – Start position of the longest ORF. orf_stop – Stop position of the longest ORF.

riboplot.ribocore.get_fasta_record(fasta_file, transcript_name)[source]

Return a single transcript from a valid fasta file as a record.

record[transcript_name] = sequence

Keyword arguments: fasta_file – FASTA format file of the transcriptome transcript_name – Name of the transcript as in the FASTA header

riboplot.ribocore.get_fasta_records(fasta, transcripts)[source]

Return list of transcript records from the given fasta file. Each record will be of the form {‘sequence_id’: {‘sequence’: ‘AAA’, ‘length’: 3}}

trascripts should be provided as a list of sequence id’s.

riboplot.ribocore.get_first_transcript_name(fasta_file)[source]

Return the first FASTA sequence from the given FASTA file.

Keyword arguments: fasta_file – FASTA format file of the transcriptome

riboplot.ribocore.get_longest_orf(orfs)[source]

Find longest ORF from the given list of ORFs.

riboplot.ribocore.get_ribo_counts(ribo_fileobj, transcript_name, read_lengths, read_offsets)[source]

For each mapped read of the given transcript in the BAM file (pysam AlignmentFile object), return the position (+1) and the corresponding frame (1, 2 or 3) to which it aligns.

Keyword arguments: ribo_fileobj – file object - BAM file opened using pysam AlignmentFile transcript_name – Name of transcript to get counts for read_length (optional) – If provided, get counts only for reads of this length.

riboplot.ribocore.get_three_frame_orfs(sequence, starts=None, stops=None)[source]

Find ORF’s in frames 1, 2 and 3 for the given sequence.

Positions returned are 1-based (not 0)

Return format [{‘start’: start_position, ‘stop’: stop_position, ‘sequence’: sequence}, ]

Keyword arguments: sequence – sequence for the transcript starts – List of codons to be considered as start (Default: [‘ATG’]) stops – List of codons to be considered as stop (Default: [‘TAG’, ‘TGA’, ‘TAA’])

riboplot.ribocore.is_bam_valid(bam_file)[source]

Check if bam file is valid. Raises a ValueError if pysam cannot read the file.

#TODO: pysam does not differentiate between BAM and SAM

riboplot.ribocore.is_fasta_valid(fasta_file)[source]

Check if fasta file is valid. Raises a ValueError if pysam cannot read the file.

#TODO: pysam does not differentiate between BAM and SAM

riboplot.ribocore.lengths_offsets(value)[source]

Split the given comma separated value to multiple integer values.

riboplot.ribocore.open_pysam_file(*args, **kwds)[source]

Open a BAM or FASTA file with pysam (for use with “with” statement)

riboplot

class riboplot.riboplot.ErrorLogFormatter(fmt=None, datefmt=None)[source]

Custom error log format for the HTML file

riboplot.riboplot.create_parser()[source]

Argument parser.

riboplot.riboplot.get_color_palette(scheme)[source]

Return colors for a given scheme. Default colors are returned for an item if undefined in scheme.

riboplot.riboplot.get_rna_counts(rna_file, transcript_name)[source]

Get coverage for a given RNA BAM file, return read counts.

riboplot.riboplot.get_start_stops(transcript_sequence, start_codons=None, stop_codons=None)[source]

Return start and stop positions for all frames in the given transcript.

riboplot.riboplot.main(args)[source]

Main program

riboplot.riboplot.plot_profile(ribo_counts, transcript_name, transcript_length, start_stops, read_lengths=None, read_offsets=None, rna_counts=None, color_scheme='default', html_file='index.html', output_path='output')[source]

Plot read counts (in all 3 frames) and RNA coverage if provided for a single transcript.

riboplot.riboplot.run()[source]

Run program

riboplot.riboplot.set_axis_color(axis, color, alpha=None)[source]

Sets the spine color of all sides of an axis (top, right, bottom, left).

ribocount

ribocount

class riboplot.ribocount.ErrorLogFormatter(fmt=None, datefmt=None)[source]

Custom error log format for the HTML file

riboplot.ribocount.create_parser()[source]

Argument parser.

riboplot.ribocount.main(args)[source]

Main program

riboplot.ribocount.run()[source]

Run program

config

class riboplot.config.ProductionConfig[source]

Production configuration

class riboplot.config.TestingConfig[source]

Testing configuration