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

リビジョン 3, 0.9 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 and print the text as a fasta file.
5
6usage: %prog < maf > fasta
7"""
8
9from __future__ import division
10
11import textwrap
12import sys
13from bx.align import maf
14
15def __main__():
16
17    maf_reader = maf.Reader( sys.stdin )
18
19    # Confusing since maf_to_concat_fasta takes names.
20
21    # if len( sys.argv ) > 1:
22    #     comps = map( int, sys.argv[1:] )
23    # else:
24    #     comps = None   
25
26    comps = None
27
28    for i, m in enumerate( maf_reader ):
29        if comps: l = [ m.components[i] for i in comps ]
30        else: l = m.components
31        for c in l:
32            print ">%s:%d-%d" % ( c.src, c.start, c.end )
33            print c.text
34            #print_n( c.text, 50 )
35
36def print_n( s, n, f = sys.stdout ):
37    p = 0
38    while p < len( s ):
39        print >> f, s[p:min(p+n,len(s))]
40        p += n
41
42if __name__ == "__main__": __main__()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。