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

リビジョン 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 data in UCSC wiggle format and write it to an "array tree" file.
5
6usage: %prog array_length output.array_tree < input.wig
7"""
8
9from __future__ import division
10
11import sys
12
13from bx.arrays.array_tree import *
14from bx.arrays.wiggle import WiggleReader
15
16def main():
17   
18    sizes_fname = sys.argv[1]
19    out_fname = sys.argv[2]
20   
21    sizes = {}
22    for line in open( sizes_fname ):
23        fields = line.split()
24        sizes[ fields[0] ] = int( fields[1] )
25   
26    # Fill array from wiggle
27    d = array_tree_dict_from_reader( WiggleReader( sys.stdin ), sizes )
28   
29    for value in d.itervalues():
30        value.root.build_summary()
31   
32    f = open( out_fname, "w" )
33    FileArrayTreeDict.dict_to_file( d, f )
34    f.close()
35
36if __name__ == "__main__":
37    main()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。