CommonBlocks

class geneblocks.CommonBlocks(common_blocks, records)[source]

Class to represent a set of common blocks from different sequences.

Create with CommonBlocks.from_sequences:

>>> common_blocks = CommonBlocks.from_sequences({'s1': 'ATGC...'})
Parameters
common_blocks

A dictionary of the sequences to compare, of the form {sequence_name: ATGC_sequence_string} or a list of records, all with different IDs.

records

A dictionary of the Biopython records of the sequences {record_id: record}.

common_blocks_records()[source]

Return all common blocks as a list of Biopython records.

common_blocks_to_csv(target_file=None)[source]

Write the common blocks into a CSV file.

If a target CSV file is provided the result is written to that file. Otherwise the result is returned as a string.

The columns of the CSV file are “block”, “size”, “locations”, and sequence.

compute_unique_blocks()[source]

Return a dictionary listing unique blocks by sequence.

The unique blocks are the blocks between the selected common blocks.

The result is of the form {seq: [(start, end), (start2, end2), …]}

plot_common_blocks(colors='auto', axes=None, figure_width=10, ax_height=2)[source]

Plot the common blocks found on vertically stacked axes.

The axes on which the plots are drawn are returned at the end.

Parameters
colors

Either a list of colors to use for blocks or “auto” for the default.

axes

A list of matplotlib axes on which to plot, or None for new axes.

figure_width

Width of the final figure in inches.

ax_eight

Height of each plot.

sequences_with_annotated_blocks(colors='auto')[source]

Return a list of Biopython records representing the sequences with annotations indicating the common blocks.

Parameter colors is either a list of colors or “auto” for the default.

unique_blocks_records(target_file=None)[source]

Return all unique blocks as a list of Biopython records.