bx.align.core module

Classes that represent alignments between multiple sequences.

class bx.align.core.Alignment(score: int | float | str = 0, attributes: dict[str, Any] | None = None, species_to_lengths: dict[str | None, str | dict[str, int] | int] | None = None)

Bases: object

add_component(component: Component) → None
column_iter() → Iterator[list[str]]
get_component_by_src(src: str) → Component | None
get_component_by_src_start(src: str) → Component | None
get_components_by_src(src: str) → Iterator[Component]
get_score() → int | float | str
limit_to_species(species: Container[str]) → Alignment
remove_all_gap_columns() → None

Remove any columns containing only gaps from alignment components, text of components is modified IN PLACE.

reverse_complement() → Alignment
property score: int | float | str
set_score(score: int | float | str) → None
slice(start: int, end: int) → Alignment
slice_by_component(component_index: int | str | Component, start: int, end: int) → Alignment

Return a slice of the alignment, corresponding to an coordinate interval in a specific component.

component_index is one of

an integer offset into the components list a string indicating the src of the desired component a component

start and end are relative to the + strand, regardless of the component’s strand.

src_size(src: str) → int
class bx.align.core.Component(src: str = '', start: int = 0, size: int = 0, strand: Literal['+', '-', '?'] | None = None, src_size: int | None = None, text: str | None = '')

Bases: object

coord_to_col(pos: int) → int

Return the alignment column index corresponding to coordinate pos.

pos is relative to the + strand, regardless of the component’s strand.

property end: int
property forward_strand_end: int
property forward_strand_start: int
get_end() → int
get_forward_strand_end() → int
get_forward_strand_start() → int
get_src_size() → int
reverse_complement() → Component
set_src_size(src_size: int | None) → None
slice(start: int, end: int) → Component
slice_by_coord(start: int, end: int) → Component

Return the slice of the component corresponding to a coordinate interval.

start and end are relative to the + strand, regardless of the component’s strand.

property src_size: int
bx.align.core.get_indexed(format: Literal['maf', 'axt', 'lav'], filename: str, index_filename: str | None = None, keep_open: bool = False, species_to_lengths: dict[str | None, str | dict[str, int] | int] | None = None) → bx.align.maf.MAFIndexedAccess | bx.align.axt.Indexed
bx.align.core.get_reader(format: Literal['maf', 'axt', 'lav'], infile: IO[str], species_to_lengths: dict[str | None, str | dict[str, int] | int] | None = None) → bx.align.maf.Reader | bx.align.axt.Reader | bx.align.lav.Reader
bx.align.core.get_writer(format: Literal['maf', 'axt', 'lav'], outfile: IO[str], attributes: dict[str, Any] | None = None) → bx.align.maf.Writer | bx.align.axt.Writer | bx.align.lav.Writer
bx.align.core.shuffle_columns(a: Alignment) → None

Randomize the columns of an alignment

bx.align.core.src_merge(species: str | None, chrom: str, contig: int | None = None) → str
bx.align.core.src_split(src: str) → tuple[str | None, str]