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

リビジョン 3, 0.6 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1#!/usr/bin/python2.6
2
3"""
4Translate lists of space separated integers (magnitude less than 62) and print
5as strings of alphanumeric characters. This is useful mainly for some machine
6learning algorithms that only take string input.
7
8usage: %prog < int_seqs > strings
9"""
10
11from itertools import *
12
13import sys
14
15table = "012345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
16
17def main():
18    for line in sys.stdin:
19        ints = [ int( f ) for f in line.split() ]
20        if max( ints ) > len( table ):
21            raise "Alphabet size too large!"
22        print str.join( '', [ table[i] for i in ints ] )   
23
24if __name__ == "__main__": main()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。