root/galaxy-central/tools/new_operations/gops_basecoverage.py @ 2

リビジョン 2, 1.4 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

行番号 
1#!/usr/bin/env python
2"""
3Count total base coverage.
4
5usage: %prog in_file out_file
6    -1, --cols1=N,N,N,N: Columns for start, end, strand in first file
7"""
8from galaxy import eggs
9import pkg_resources
10pkg_resources.require( "bx-python" )
11import sys, traceback, fileinput
12from warnings import warn
13from bx.intervals import *
14from bx.intervals.io import *
15from bx.intervals.operations.base_coverage import *
16from bx.cookbook import doc_optparse
17from galaxy.tools.util.galaxyops import *
18
19assert sys.version_info[:2] >= ( 2, 4 )
20
21def main():
22    upstream_pad = 0
23    downstream_pad = 0
24
25    options, args = doc_optparse.parse( __doc__ )
26    try:
27        chr_col_1, start_col_1, end_col_1, strand_col_1 = parse_cols_arg( options.cols1 )
28        in_fname, out_fname = args
29    except:
30        doc_optparse.exception()
31       
32    g1 = NiceReaderWrapper( fileinput.FileInput( in_fname ),
33                            chrom_col=chr_col_1,
34                            start_col=start_col_1,
35                            end_col=end_col_1,
36                            strand_col = strand_col_1,
37                            fix_strand=True )
38   
39    try:
40        bases = base_coverage(g1)
41    except ParseError, exc:
42        fail( "Invalid file format: %s" % str( exc ) )
43    out_file = open( out_fname, "w" )
44    out_file.write( "%s\n" % str( bases ) )
45    out_file.close()
46    if g1.skipped > 0:
47        print skipped( g1, filedesc="" )
48
49if __name__ == "__main__":
50    main()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。