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

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

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

行番号 
1#!/usr/bin/python2.6
2
3"""
4Read a MAF from standard input and determine the mean length of ungapped pieces
5in each block.
6
7usage: %prog < maf > out
8"""
9
10from __future__ import division
11
12import sys
13import bx.align.maf
14
15def main():
16   
17    for m in bx.align.maf.Reader( sys.stdin ): 
18   
19        ungapped_columns = 0
20        ungapped_runs = 0
21        in_ungapped = False
22       
23        for col in m.column_iter():
24            is_gap = ( '-' in col )
25            if not is_gap: ungapped_columns += 1
26            if in_ungapped and is_gap:
27                ungapped_runs += 1
28            in_ungapped = not is_gap
29        if in_ungapped: ungapped_runs += 1
30
31        print ungapped_columns / ungapped_runs
32
33
34if __name__ == "__main__": main()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。