root/galaxy-central/eggs/bx_python-0.5.0_dev_f74aec067563-py2.6-macosx-10.6-universal-ucs2.egg/EGG-INFO/scripts/nib_intervals_to_fasta.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 set of ranges and a nib file, print portions of nib overlapping
5those ranges to stdout
6
7usage: %prog range_file nib_file
8"""
9
10from bx.cookbook import doc_optparse
11import bx.seq.nib
12import string
13import sys
14
15def __main__():
16
17    options, args = doc_optparse.parse( __doc__ )
18
19    try:
20        range_file = file( args[0] )
21        nib_file = file( args[1] )
22    except:
23        doc_optparse.exit()
24
25    nib = bx.seq.nib.NibFile( nib_file )
26
27    for line in range_file:
28        fields = line.split()
29        start, end = int( fields[0] ), int( fields[1] )
30        print ">", start, end
31        print_wrapped( nib.get( start, end - start ) )
32
33def print_wrapped( s ):
34    l = len( s )       
35    c = 0
36    while c < l:
37        b = min( c + 50, l )
38        print s[c:b]
39        c = b
40
41if __name__ == "__main__": __main__()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。