root/galaxy-central/eggs/bx_python-0.5.0_dev_f74aec067563-py2.6-macosx-10.6-universal-ucs2.egg/EGG-INFO/scripts/maf_print_scores.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"""
4Read a MAF from standard input and print the score of each block. It can
5optionally recalculate each score using the hox70 matrix, and normalize the
6score by the number of columns in the alignment.
7
8TODO: Should be able to read an arbitrary scoring matrix.
9
10usage: %prog [options]
11   -r, --recalculate: don't use the score from the maf, recalculate (using hox70 matrix)
12   -l, --lnorm: divide (normalize) score by alignment text length
13"""
14
15from __future__ import division
16
17import sys
18from bx.cookbook import doc_optparse
19from bx.align import maf
20from bx.align import score
21from optparse import OptionParser
22
23def main():
24
25    # Parse command line arguments
26    options, args = doc_optparse.parse( __doc__ )
27
28    try:
29        lnorm = bool( options.lnorm )
30        recalculate = bool( options.recalculate )
31    except:
32        doc_optparse.exit()
33
34    hox70 = score.build_scoring_scheme( """  A    C    G    T
35                                      91 -114  -31 -123
36                                    -114  100 -125  -31
37                                     -31 -125  100 -114
38                                    -123  -31 -114   91 """, 400, 30, default=0 )
39
40    maf_reader = maf.Reader( sys.stdin )
41
42    for m in maf_reader:
43        if m.text_size == 0:
44            print "NA"
45            continue
46        s = m.score
47        # Recalculate?
48        if recalculate:
49            s = hox70.score_alignment( m )
50        # Normalize?
51        if lnorm:
52            s = s / m.text_size
53        # Print
54        print s
55
56if __name__ == "__main__":
57    main()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。