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

リビジョン 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"""
4Writes compressed data from a wiggle file by chromosome.
5
6usage: %prog score_file < wiggle_data
7"""
8
9from __future__ import division
10
11import sys
12import psyco_full
13import bx.wiggle
14from bx.binned_array import BinnedArray
15from fpconst import isNaN
16from bx.cookbook import doc_optparse
17from bx import misc
18
19
20def main():
21   
22    # Parse command line
23    options, args = doc_optparse.parse( __doc__ )
24    try:
25        score_fname = args[0]
26    except:
27        doc_optparse.exit()
28
29    scores = {}
30    for i, ( chrom, pos, val ) in enumerate( bx.wiggle.Reader( open(sys.argv[1]) ) ):
31        if not chrom in scores: scores[ chrom ] = BinnedArray()
32        scores[chrom][pos] = val
33
34        # Status
35        if i % 10000 == 0: print i, "scores processed"
36
37    for chr in scores.keys():
38        out = open( chr, "w" )
39        scores[chr].to_file( out )
40        out.close()
41
42if __name__ == "__main__": main()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。