root/galaxy-central/eggs/bx_python-0.5.0_dev_f74aec067563-py2.6-macosx-10.6-universal-ucs2.egg/bx/align/tools/chop.py @ 3

リビジョン 3, 1.0 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1"""
2Support for chopping a list of alignment blocks to only the portion that
3intersects a particular interval.
4"""
5
6def chop_list( blocks, src, start, end ):
7    """
8    For each alignment block in the sequence `blocks`, chop out the portion
9    of the block that overlaps the interval [`start`,`end`) in the
10    component/species named `src`.
11    """
12    new_blocks = []
13    for block in blocks:
14        ref = block.get_component_by_src( src )
15        # If the reference component is on the '-' strand we should complement the interval
16        if ref.strand == '-':
17            slice_start = max( ref.src_size - end, ref.start )
18            slice_end = max( ref.src_size - start, ref.end )
19        else:
20            slice_start = max( start, ref.start )
21            slice_end = min( end, ref.end )
22        sliced = block.slice_by_component( ref, slice_start, slice_end )
23        good = True
24        for c in sliced.components:
25            if c.size < 1:
26                good = False
27        if good:
28            new_blocks.append( sliced )
29    return new_blocks
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。