root/galaxy-central/eggs/bx_python-0.5.0_dev_f74aec067563-py2.6-macosx-10.6-universal-ucs2.egg/EGG-INFO/scripts/maf_randomize.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"""
4Randomize the order of blocks in a MAF file. If `sample_size` is specified,
5that many random blocks will be kept from the original maf
6
7usage: %prog [sample_size] < maf > maf
8"""
9
10import sys
11
12import sys, random
13from bx.align import maf
14from math import *
15from optparse import OptionParser
16
17def __main__():
18
19    #if len( sys.argv ) > 1: fraction = float( sys.argv[1] )
20    if len( sys.argv ) > 1: sample_size = int( sys.argv[1] )
21
22    maf_reader = maf.Reader( sys.stdin )
23    maf_writer = maf.Writer( sys.stdout )
24
25    mafs = list( maf_reader )
26
27    # for m in maf_reader: mafs.append( m )
28
29    random.shuffle( mafs )
30
31    if not sample_size: sample_size = len( mafs )
32
33    for i in range( 0, sample_size ): maf_writer.write( mafs[ i ] )
34   
35if __name__ == "__main__": __main__()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。