root/galaxy-central/eggs/bx_python-0.5.0_dev_f74aec067563-py2.6-macosx-10.6-universal-ucs2.egg/EGG-INFO/scripts/maf_drop_overlapping.py @ 3

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

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

行番号 
1#!/usr/bin/python2.6
2
3"""
4Remove any blocks from a maf that overlap any of a set of intervals.
5
6usage: %prog interval files... < maf
7"""
8
9import psyco_full
10
11from bx.cookbook import doc_optparse
12
13import bx.align.maf
14from bx import intervals
15import sys
16
17
18def __main__():
19
20    # Parse Command Line
21
22    options, args = doc_optparse.parse( __doc__ )
23
24    try:
25        assert len( args ) > 0
26    except:
27        doc_optparse.exit()
28
29    # Load Intervals
30
31    intersector = intervals.Intersecter()
32
33    for f in args:
34        for line in file( f ):
35            if line.startswith( "#" ) or line.isspace(): continue
36            fields = line.split()
37            intersector.add_interval( intervals.Interval( int( fields[0] ), int( fields[1] ) ) )
38
39    # Start MAF on stdout
40
41    out = bx.align.maf.Writer( sys.stdout )
42
43    # Iterate over input MAF
44
45    for maf in bx.align.maf.Reader( sys.stdin ):
46        # Find overlap with reference component
47        intersections = intersector.find( maf.components[0].start, maf.components[0].end )
48        # Write only if no overlap
49        if len( intersections ) == 0:
50            out.write( maf )
51         
52    # Close output MAF
53
54    out.close()
55
56if __name__ == "__main__": __main__()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。