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

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