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

リビジョン 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 PAIRWISE maf from stdin and print the fraction of columns whose bases
5match for each alignment.
6
7TODO: generalize for more than two speceis.
8
9usage: %prog < maf > out
10"""
11
12from __future__ import division
13
14import sys
15
16import psyco_full
17
18from bx.align import maf
19
20
21def __main__():
22   
23    maf_reader = maf.Reader( sys.stdin )
24
25    for m in maf_reader:
26        match = 0
27        total = 0
28        for i in range( 0, m.text_size ):
29            a = m.components[0].text[i].lower()
30            b = m.components[1].text[i].lower()           
31            if a == b:
32                match += 1
33            total += 1
34
35        print match / total
36
37
38if __name__ == "__main__": __main__()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。