Files
galaxy/tools/new_operations/gops_basecoverage.py
T
Nate Coraor 7560751dc8 Separate framework and tool environments.
Whether running locally or via PBS, $PATH should now be handled in your
user's environment.

This also fixes problems like PYTHONPATH on the new blast nodes being
wrong (because they are x86_64 and the frontends are i686).

Note that you can actually start Galaxy without having an eggs dir now.
2008-04-11 20:11:21 +00:00

60 lines
1.5 KiB
Python

#!/usr/bin/env python
"""
Count total base coverage.
usage: %prog in_file out_file
-1, --cols1=N,N,N,N: Columns for start, end, strand in first file
"""
from galaxy import eggs
import pkg_resources
pkg_resources.require( "bx-python" )
import sys
import traceback
import fileinput
from warnings import warn
from bx.intervals import *
from bx.intervals.io import *
from bx.intervals.operations.base_coverage import *
from bx.cookbook import doc_optparse
from galaxy.tools.util.galaxyops import *
assert sys.version_info[:2] >= ( 2, 4 )
def main():
upstream_pad = 0
downstream_pad = 0
options, args = doc_optparse.parse( __doc__ )
try:
chr_col_1, start_col_1, end_col_1, strand_col_1 = parse_cols_arg( options.cols1 )
in_fname, out_fname = args
except:
doc_optparse.exception()
g1 = NiceReaderWrapper( fileinput.FileInput( in_fname ),
chrom_col=chr_col_1,
start_col=start_col_1,
end_col=end_col_1,
fix_strand=True)
if strand_col_1 >= 0:
g1.strand_col=strand_col_1
out_file = open( out_fname, "w" )
try:
bases = base_coverage(g1)
except ParseError, exc:
print >> sys.stderr, "Invalid file format: ", str( exc )
print >> out_file, str(bases)
if g1.skipped > 0:
first_line, line_contents = g1.skipped_lines[0]
print skipped( g1 )
if __name__ == "__main__":
main()