root/galaxy-central/lib/galaxy/tools/util/galaxyops/__init__.py @ 2

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

import galaxy-central

行番号 
1"""Utility functions for galaxyops"""
2import sys
3from bx.bitset import *
4from bx.intervals.io import *
5
6def warn( msg ):
7    # TODO: since everything printed to stderr results in job.state = error, we
8    # don't need both a warn and a fail...
9    print >> sys.stderr, msg
10    sys.exit( 1 )
11   
12def fail( msg ):
13    print >> sys.stderr, msg
14    sys.exit( 1 )
15
16# Default chrom, start, end, strand cols for a bed file
17BED_DEFAULT_COLS = 0, 1, 2, 5
18
19def parse_cols_arg( cols ):
20    """Parse a columns command line argument into a four-tuple"""
21    if cols:
22        # Handle case where no strand column included - in this case, cols
23        # looks something like 1,2,3,
24        if cols.endswith( ',' ):
25            cols += '0'
26        col_list = map( lambda x: int( x ) - 1, cols.split(",") )
27        return col_list
28    else:
29        return BED_DEFAULT_COLS
30
31def default_printer( stream, exc, obj ):
32    print >> stream, "%d: %s" % ( obj.linenum, obj.current_line )
33    print >> stream, "\tError: %s" % ( str(exc) )
34
35def skipped( reader, filedesc="" ):
36    first_line, line_contents, problem = reader.skipped_lines[0]
37    return 'Skipped %d invalid lines%s, 1st line #%d: "%s", problem: %s' % ( reader.skipped, filedesc, first_line, line_contents, problem )
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。