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

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

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

行番号 
1#!/usr/bin/python2.6
2
3"""
4Filter each block in a maf file. Can filter blocks for a minimum number of
5components (rows), a minimum length in columns, or an arbitrary python
6expression (which will be evaluated for each block with the variable 'm'
7containing that block).
8
9usage: %prog [options] < maf > maf
10    --component_count=N: Minimum number of components (rows)
11    --min_cols=N: Minimum number of columns
12    -e, --expr=EXPR: Python expression that must evaulate to true
13"""
14
15import psyco_full
16
17import sys
18
19import sys
20from bx.align import maf
21from optparse import OptionParser
22
23def __main__():
24
25    # Parse command line arguments
26
27    parser = OptionParser()
28    parser.add_option( "--component_count", action="store", default=None, type="int", help="" )
29    parser.add_option( "--min_cols", action="store", default=None, type="int", help="" )
30    parser.add_option( "-e", "--expr", action="store", default=None )
31
32    ( options, args ) = parser.parse_args()
33
34    component_count = options.component_count
35    min_cols = options.min_cols
36    expr = options.expr
37
38    # Compile expression for SPEED
39    if expr: expr = compile( expr, '<expr arg>', 'eval' )
40
41    maf_reader = maf.Reader( sys.stdin )
42    maf_writer = maf.Writer( sys.stdout )
43
44    for m in maf_reader:
45
46        if component_count and len( m.components ) != component_count: continue
47        if min_cols and m.text_size < min_cols: continue
48        if expr and not bool( eval( expr, { "m": m, "maf": m } ) ): continue
49
50        maf_writer.write( m )
51
52if __name__ == "__main__": __main__()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。