bx.align.tools package

Submodules

Module contents

Various utilities for working with bx.align.Alignment objects.

class bx.align.tools.FusingAlignmentWriter(maf_writer)

Bases: object

Wrapper for an alignment Writer which attempts to fuse adjacent blocks

close()
write(m)
bx.align.tools.chop_list(blocks, src, start, end)

For each alignment block in the sequence blocks, chop out the portion of the block that overlaps the interval [start,`end`) in the component/species named src.

bx.align.tools.fuse(m1, m2)

Attempt to fuse two blocks. If they can be fused returns a new block, otherwise returns None.

Example:

>>> import bx.align.maf
>>> block1 = bx.align.maf.from_string( '''
... a score=0.0
... s hg18.chr10 52686 44 + 135374737 GTGCTAACTTACTGCTCCACAGAAAACATCAATTCTGCTCATGC
... i hg18.chr10 N 0 C 0
... s panTro1.chrUn_random 208115356 44 - 240967748 GTGCTAACTGACTGCTCCAGAGAAAACATCAATTCTGTTCATGT
... ''' )
>>> block2 = bx.align.maf.from_string( '''
... a score=0.0
... s hg18.chr10 52730 69 + 135374737 GCAGGTACAATTCATCAAGAAAGGAATTACAACTTCAGAAATGTGTTCAAAATATATCCATACTTTGAC
... i hg18.chr10 C 0 I 12
... s panTro1.chrUn_random 208115400 69 - 240967748 GCAGCTACTATTCATCAAGAAAGGGATTACAACTTCAGAAATGTGTTCAAAGTGTATCCATACTTTGAT
... ''' )
>>> fused = fuse( block1, block2 )
>>> print(fused)
a score=0.0
s hg18.chr10 52686 113 + 135374737 GTGCTAACTTACTGCTCCACAGAAAACATCAATTCTGCTCATGCGCAGGTACAATTCATCAAGAAAGGAATTACAACTTCAGAAATGTGTTCAAAATATATCCATACTTTGAC
i hg18.chr10 N 0 I 12
s panTro1.chrUn_random 208115356 113 - 240967748 GTGCTAACTGACTGCTCCAGAGAAAACATCAATTCTGTTCATGTGCAGCTACTATTCATCAAGAAAGGGATTACAACTTCAGAAATGTGTTCAAAGTGTATCCATACTTTGAT
bx.align.tools.fuse_list(mafs)

Try to fuse a list of blocks by progressively fusing each adjacent pair.

bx.align.tools.get_components_for_species(alignment, species)

Return the component for each species in the list species or None

bx.align.tools.intervals_from_mask(mask)
bx.align.tools.tile_interval(sources, index, ref_src, start, end, seq_db=None)

Tile maf blocks onto an interval. The resulting block will span the interval exactly and contain the column from the highest scoring alignment at each position.

sources: list of sequence source names to include in final block index: an instnace that can return maf blocks overlapping intervals ref_src: source name of the interval (ie, hg17.chr7) start: start of interval end: end of interval seq_db: a mapping for source names in the reference species to nib files