diff --git a/eggs.ini b/eggs.ini
index 486bbb38e65..7b3df2e0815 100644
--- a/eggs.ini
+++ b/eggs.ini
@@ -53,13 +53,13 @@ pbs_python = _2.1.8
MySQL_python = _5.0.51a_static
python_lzo = _static
flup = .dev_r2311
-bx_python = _dev_r418
+bx_python = _dev_r427
nose = .dev_r101
DRMAA_python = _6.1u4
; source location, necessary for scrambling
[source]
-bx_python = http://dist.g2.bx.psu.edu/bx-python_dist-r414.tar.bz2
+bx_python = http://dist.g2.bx.psu.edu/bx-python_dist-r427.tar.bz2
Cheetah = http://umn.dl.sourceforge.net/sourceforge/cheetahtemplate/Cheetah-1.0.tar.gz
DRMAA_python = http://gridengine.sunsource.net/files/documents/7/36/DRMAA-python-0.2.tar.gz
MySQL_python = http://superb-west.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.2.tar.gz http://mysql.mirrors.pair.com/Downloads/MySQL-5.0/mysql-5.0.51a.tar.gz
diff --git a/lib/galaxy/tools/util/galaxyops/__init__.py b/lib/galaxy/tools/util/galaxyops/__init__.py
index 83884210bac..e18be6ef418 100644
--- a/lib/galaxy/tools/util/galaxyops/__init__.py
+++ b/lib/galaxy/tools/util/galaxyops/__init__.py
@@ -1,52 +1,8 @@
-"""
-Utility functions for galaxyops
-"""
+"""Utility functions for galaxyops"""
import sys
-
from bx.bitset import *
from bx.intervals.io import *
-class BitsetSafeNiceReaderWrapper:
- """Handles exceptions thrown in bx."""
- def __init__( self, iterat ):
- self.iterat = iterat
- self.MAXINT = 2147483647 # max signed int value for 32-bit
- def __iter__( self ):
- while True:
- region = self.iterat.next()
- # NiceReaderWrapper can return a header, comment or GenomicInterval
- if type( region ) == GenomicInterval:
- if ( region.start > self.MAXINT ) or ( region.end > self.MAXINT ) or ( region.start > region.end ):
- self.iterat.skipped += 1
- if self.iterat.skipped < 10:
- self.iterat.skipped_lines.append( ( self.iterat.linenum, self.iterat.current_line ) )
- else:
- yield region
- def __getattr__( self, name ):
- return getattr( self.iterat, name )
- def binned_bitsets( self , upstream_pad=0, downstream_pad=0, lens={} ):
- # This is duplicated in bx.intervals.io, but we need it here so that self refers to
- # our BitsetSafeNiceReaderWrapper rather than bx.intervals.io's GenomicIntervalReader
- last_chrom = None
- last_bitset = None
- bitsets = dict()
- for interval in self:
- if type( interval ) == GenomicInterval:
- chrom = interval[self.chrom_col]
- if chrom != last_chrom:
- if chrom not in bitsets:
- if chrom in lens:
- size = lens[chrom]
- else:
- size = MAX
- bitsets[chrom] = BinnedBitSet( size )
- last_chrom = chrom
- last_bitset = bitsets[chrom]
- start = max(int( interval[self.start_col]), 0 )
- end = min(int( interval[self.end_col]), size)
- last_bitset.set_range( start, end-start )
- return bitsets
-
def warn( msg ):
# TODO: since everything printed to stderr results in job.state = error, we
# don't need both a warn and a fail...
@@ -72,6 +28,5 @@ def default_printer( stream, exc, obj ):
print >> stream, "\tError: %s" % ( str(exc) )
def skipped( reader, filedesc="" ):
- first_line, line_contents = reader.skipped_lines[0]
- return 'Skipped %d invalid lines%s starting at line #%d: "%s"' \
- % ( reader.skipped, filedesc, first_line, line_contents )
+ first_line, line_contents, problem = reader.skipped_lines[0]
+ return 'Skipped %d invalid lines%s, 1st line #%d: "%s", problem: %s' % ( reader.skipped, filedesc, first_line, line_contents, problem )
diff --git a/tools/new_operations/basecoverage.xml b/tools/new_operations/basecoverage.xml
index 8e67580d97f..09bfb5221ee 100644
--- a/tools/new_operations/basecoverage.xml
+++ b/tools/new_operations/basecoverage.xml
@@ -13,7 +13,11 @@
-
+
+
+
+
+
diff --git a/tools/new_operations/cluster.xml b/tools/new_operations/cluster.xml
index fcc10c5fea2..36d8ad53af1 100644
--- a/tools/new_operations/cluster.xml
+++ b/tools/new_operations/cluster.xml
@@ -32,7 +32,14 @@
-
+
+
+
+
+
+
+
+
diff --git a/tools/new_operations/complement.xml b/tools/new_operations/complement.xml
index 4c5790b945a..6a8b7d70715 100644
--- a/tools/new_operations/complement.xml
+++ b/tools/new_operations/complement.xml
@@ -16,7 +16,12 @@
-
+
+
+
+
+
+
diff --git a/tools/new_operations/coverage.xml b/tools/new_operations/coverage.xml
index 19b453f8577..26a6d4bac35 100644
--- a/tools/new_operations/coverage.xml
+++ b/tools/new_operations/coverage.xml
@@ -17,7 +17,12 @@
-
+
+
+
+
+
+
diff --git a/tools/new_operations/flanking_features.py b/tools/new_operations/flanking_features.py
index b9b3d0b44f4..0c9204cb951 100644
--- a/tools/new_operations/flanking_features.py
+++ b/tools/new_operations/flanking_features.py
@@ -10,18 +10,15 @@ usage: %prog primary_file features_file out_file direction
from galaxy import eggs
import pkg_resources
pkg_resources.require( "bx-python" )
-
-import sys
-import traceback
-import fileinput
+import sys, traceback, fileinput
from warnings import warn
-
from bx.cookbook import doc_optparse
from galaxy.tools.util.galaxyops import *
-
from bx.intervals.io import *
from bx.intervals.operations import quicksect
+assert sys.version_info[:2] >= ( 2, 4 )
+
def get_closest_feature (node, direction, threshold_up, threshold_down, report_func_up, report_func_down):
#direction=1 for +ve strand upstream and -ve strand downstream cases; and it is 0 for +ve strand downstream and -ve strand upstream cases
#threhold_Up is equal to the interval start for +ve strand, and interval end for -ve strand
@@ -121,7 +118,6 @@ def proximal_region_finder(readers, region, comments=True):
yield outfields
def main():
-
options, args = doc_optparse.parse( __doc__ )
try:
chr_col_1, start_col_1, end_col_1, strand_col_1 = parse_cols_arg( options.cols1 )
@@ -130,22 +126,19 @@ def main():
except:
doc_optparse.exception()
- g1 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_fname ),
- chrom_col=chr_col_1,
- start_col=start_col_1,
- end_col=end_col_1,
- strand_col=strand_col_1,
- fix_strand=True )
- )
- g2 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in2_fname ),
- chrom_col=chr_col_2,
- start_col=start_col_2,
- end_col=end_col_2,
- strand_col=strand_col_2,
- fix_strand=True )
- )
+ g1 = NiceReaderWrapper( fileinput.FileInput( in_fname ),
+ chrom_col=chr_col_1,
+ start_col=start_col_1,
+ end_col=end_col_1,
+ strand_col=strand_col_1,
+ fix_strand=True )
+ g2 = NiceReaderWrapper( fileinput.FileInput( in2_fname ),
+ chrom_col=chr_col_2,
+ start_col=start_col_2,
+ end_col=end_col_2,
+ strand_col=strand_col_2,
+ fix_strand=True )
out_file = open( out_fname, "w" )
-
try:
for line in proximal_region_finder([g1,g2], direction):
if type( line ) is list:
@@ -153,16 +146,13 @@ def main():
else:
out_file.write( "%s\n" % line )
except ParseError, exc:
- fail( "Invalid file format: ", str( exc ) )
+ fail( "Invalid file format: %s" % str( exc ) )
print "Direction: %s" %(direction)
-
if g1.skipped > 0:
print skipped( g1, filedesc=" of 1st dataset" )
-
if g2.skipped > 0:
print skipped( g2, filedesc=" of 2nd dataset" )
-
if __name__ == "__main__":
main()
diff --git a/tools/new_operations/gops_basecoverage.py b/tools/new_operations/gops_basecoverage.py
index caa0a39bc0e..741b073a583 100644
--- a/tools/new_operations/gops_basecoverage.py
+++ b/tools/new_operations/gops_basecoverage.py
@@ -1,32 +1,25 @@
#!/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
+import sys, traceback, 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
@@ -37,24 +30,21 @@ def main():
except:
doc_optparse.exception()
- g1 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_fname ),
- chrom_col=chr_col_1,
- start_col=start_col_1,
- end_col=end_col_1,
- fix_strand=True )
- )
+ 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
-
try:
bases = base_coverage(g1)
except ParseError, exc:
- fail( "Invalid file format: ", str( exc ) )
-
+ fail( "Invalid file format: %s" % str( exc ) )
out_file = open( out_fname, "w" )
out_file.write( "%s\n" % str( bases ) )
-
+ out_file.close()
if g1.skipped > 0:
print skipped( g1, filedesc="" )
diff --git a/tools/new_operations/gops_cluster.py b/tools/new_operations/gops_cluster.py
index d72f11758b2..ac2f4f75d0a 100644
--- a/tools/new_operations/gops_cluster.py
+++ b/tools/new_operations/gops_cluster.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-
"""
Cluster regions of intervals.
@@ -10,23 +9,19 @@ usage: %prog in_file out_file
-m, --minregions=N: Minimum regions per cluster
-o, --output=N: 1)merged 2)filtered 3)clustered 4) minimum 5) maximum
"""
-
from galaxy import eggs
import pkg_resources
pkg_resources.require( "bx-python" )
-
-import sys
-import traceback
-import fileinput
+import sys, traceback, fileinput
from warnings import warn
-
from bx.intervals import *
from bx.intervals.io import *
from bx.intervals.operations.find_clusters import *
from bx.cookbook import doc_optparse
-
from galaxy.tools.util.galaxyops import *
+assert sys.version_info[:2] >= ( 2, 4 )
+
def main():
distance = 0
minregions = 2
@@ -45,22 +40,21 @@ def main():
except:
doc_optparse.exception()
- g1 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_fname ),
- chrom_col=chr_col_1,
- start_col=start_col_1,
- end_col=end_col_1,
- strand_col=strand_col_1,
- fix_strand=True )
- )
- out_file = open( out_fname, "w" )
+ g1 = NiceReaderWrapper( fileinput.FileInput( in_fname ),
+ chrom_col=chr_col_1,
+ start_col=start_col_1,
+ end_col=end_col_1,
+ strand_col=strand_col_1,
+ fix_strand=True )
# Get the cluster tree
try:
clusters, extra = find_clusters( g1, mincols=distance, minregions=minregions)
except ParseError, exc:
- fail( "Invalid file format: ", str( exc ) )
+ fail( "Invalid file format: %s" % str( exc ) )
f1 = open( in_fname, "r" )
+ out_file = open( out_fname, "w" )
# If "merge"
if output == 1:
@@ -129,6 +123,7 @@ def main():
out_file.write( "%s\n" % outinterval )
f1.close()
+ out_file.close()
if g1.skipped > 0:
print skipped( g1, filedesc="" )
diff --git a/tools/new_operations/gops_complement.py b/tools/new_operations/gops_complement.py
index 0a82d52f4a1..09a78e25e51 100644
--- a/tools/new_operations/gops_complement.py
+++ b/tools/new_operations/gops_complement.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-
"""
Complement regions.
@@ -8,24 +7,20 @@ usage: %prog in_file out_file
-d, --db=N: Database name (for determining chromosome lengths)
-a, --all: Complement all chromosomes (Genome-wide complement)
"""
-
from galaxy import eggs
import pkg_resources
pkg_resources.require( "bx-python" )
-
-import sys
-import traceback
-import fileinput
+import sys, traceback, fileinput
from warnings import warn
-
from bx.intervals import *
from bx.intervals.io import *
from bx.intervals.operations.complement import complement
from bx.intervals.operations.subtract import subtract
from bx.cookbook import doc_optparse
-
from galaxy.tools.util.galaxyops import *
+assert sys.version_info[:2] >= ( 2, 4 )
+
def main():
allchroms = False
upstream_pad = 0
@@ -40,17 +35,17 @@ def main():
except:
doc_optparse.exception()
- g1 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_fname ),
- chrom_col=chr_col_1,
- start_col=start_col_1,
- end_col=end_col_1,
- strand_col=strand_col_1,
- fix_strand=True )
- )
-
- out_file = open( out_fname, "w" )
+ g1 = NiceReaderWrapper( fileinput.FileInput( in_fname ),
+ chrom_col=chr_col_1,
+ start_col=start_col_1,
+ end_col=end_col_1,
+ strand_col=strand_col_1,
+ fix_strand=True )
+
lens = dict()
chroms = list()
+ # dbfile is used to determine the length of each chromosome. The lengths
+ # are added to the lens dict and passed copmlement operation code in bx.
dbfile = fileinput.FileInput( "static/ucsc/chrom/"+db+".len" )
if dbfile:
@@ -82,6 +77,8 @@ def main():
else:
generator = complement(g1, lens)
+ out_file = open( out_fname, "w" )
+
try:
for interval in generator:
if type( interval ) is GenomicInterval:
@@ -89,7 +86,10 @@ def main():
else:
out_file.write( "%s\n" % interval )
except ParseError, exc:
- fail( "Invalid file format: ", str( exc ) )
+ out_file.close()
+ fail( "Invalid file format: %s" % str( exc ) )
+
+ out_file.close()
if g1.skipped > 0:
print skipped( g1, filedesc="" )
diff --git a/tools/new_operations/gops_concat.py b/tools/new_operations/gops_concat.py
index 68dbee29343..4b5ea08a35c 100644
--- a/tools/new_operations/gops_concat.py
+++ b/tools/new_operations/gops_concat.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-
"""
Concatenate two bed files. The concatenated files are returned in the
same format as the first. If --sameformat is specified, then all
@@ -13,25 +12,20 @@ usage: %prog in_file_1 in_file_2 out_file
-2, --cols2=N,N,N,N: Columns for chrom, start, end, strand in second file
-s, --sameformat: All files are precisely the same format.
"""
-
from galaxy import eggs
import pkg_resources
pkg_resources.require( "bx-python" )
-
-import sys
-import traceback
-import fileinput
+import sys, traceback, fileinput
from warnings import warn
-
from bx.intervals import *
from bx.intervals.io import *
from bx.intervals.operations.concat import *
from bx.cookbook import doc_optparse
-
from galaxy.tools.util.galaxyops import *
-def main():
+assert sys.version_info[:2] >= ( 2, 4 )
+def main():
sameformat=False
upstream_pad = 0
downstream_pad = 0
@@ -45,23 +39,22 @@ def main():
except:
doc_optparse.exception()
- g1 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_file_1 ),
- chrom_col=chr_col_1,
- start_col=start_col_1,
- end_col=end_col_1,
- fix_strand=True )
- )
+ g1 = NiceReaderWrapper( fileinput.FileInput( in_file_1 ),
+ chrom_col=chr_col_1,
+ start_col=start_col_1,
+ end_col=end_col_1,
+ fix_strand=True )
+
+ g2 = NiceReaderWrapper( fileinput.FileInput( in_file_2 ),
+ chrom_col=chr_col_2,
+ start_col=start_col_2,
+ end_col=end_col_2,
+ strand_col=strand_col_2,
+ fix_strand=True )
+
if strand_col_1 >= 0:
- g1.strand_col=strand_col_1
-
- g2 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_file_2 ),
- chrom_col=chr_col_2,
- start_col=start_col_2,
- end_col=end_col_2,
- strand_col=strand_col_2,
- fix_strand=True )
- )
-
+ g1.strand_col = strand_col_1
+
out_file = open( out_fname, "w" )
try:
@@ -71,8 +64,11 @@ def main():
else:
out_file.write( "%s\n" % line )
except ParseError, exc:
- fail( "Invalid file format: ", str( exc ) )
-
+ out_file.close()
+ fail( "Invalid file format: %s" % str( exc ) )
+
+ out_file.close()
+
if g1.skipped > 0:
print skipped( g1, filedesc=" of 1st dataset" )
if g2.skipped > 0:
diff --git a/tools/new_operations/gops_coverage.py b/tools/new_operations/gops_coverage.py
index 2fb5935b82f..91b3ad19803 100644
--- a/tools/new_operations/gops_coverage.py
+++ b/tools/new_operations/gops_coverage.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-
"""
Calculate coverage of one query on another, and append the coverage to
the last two columns as bases covered and percent coverage.
@@ -8,25 +7,20 @@ usage: %prog bed_file_1 bed_file_2 out_file
-1, --cols1=N,N,N,N: Columns for start, end, strand in first file
-2, --cols2=N,N,N,N: Columns for start, end, strand in second file
"""
-
from galaxy import eggs
import pkg_resources
pkg_resources.require( "bx-python" )
-
-import sys
-import traceback
-import fileinput
+import sys, traceback, fileinput
from warnings import warn
-
from bx.intervals import *
from bx.intervals.io import *
from bx.intervals.operations.coverage import *
from bx.cookbook import doc_optparse
-
from galaxy.tools.util.galaxyops import *
-def main():
+assert sys.version_info[:2] >= ( 2, 4 )
+def main():
upstream_pad = 0
downstream_pad = 0
@@ -38,20 +32,19 @@ def main():
except:
doc_optparse.exception()
- g1 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_fname ),
- chrom_col=chr_col_1,
- start_col=start_col_1,
- end_col=end_col_1,
- strand_col=strand_col_1,
- fix_strand=True )
- )
- g2 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in2_fname ),
- chrom_col=chr_col_2,
- start_col=start_col_2,
- end_col=end_col_2,
- strand_col=strand_col_2,
- fix_strand=True )
- )
+ g1 = NiceReaderWrapper( fileinput.FileInput( in_fname ),
+ chrom_col=chr_col_1,
+ start_col=start_col_1,
+ end_col=end_col_1,
+ strand_col=strand_col_1,
+ fix_strand=True )
+ g2 = NiceReaderWrapper( fileinput.FileInput( in2_fname ),
+ chrom_col=chr_col_2,
+ start_col=start_col_2,
+ end_col=end_col_2,
+ strand_col=strand_col_2,
+ fix_strand=True )
+
out_file = open( out_fname, "w" )
try:
@@ -61,7 +54,10 @@ def main():
else:
out_file.write( "%s\n" % line )
except ParseError, exc:
- fail( "Invalid file format: ", str( exc ) )
+ out_file.close()
+ fail( "Invalid file format: %s" % str( exc ) )
+
+ out_file.close()
if g1.skipped > 0:
print skipped( g1, filedesc=" of 1st dataset" )
diff --git a/tools/new_operations/gops_intersect.py b/tools/new_operations/gops_intersect.py
index 975bff25b1f..8e152c44496 100755
--- a/tools/new_operations/gops_intersect.py
+++ b/tools/new_operations/gops_intersect.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-
"""
Find regions of first bed file that overlap regions in a second bed file
@@ -9,25 +8,20 @@ usage: %prog bed_file_1 bed_file_2 out_file
-m, --mincols=N: Require this much overlap (default 1bp)
-p, --pieces: just print pieces of second set (after padding)
"""
-
from galaxy import eggs
import pkg_resources
pkg_resources.require( "bx-python" )
-
-import sys
-import traceback
-import fileinput
+import sys, traceback, fileinput
from warnings import warn
-
from bx.intervals import *
from bx.intervals.io import *
from bx.intervals.operations.intersect import *
from bx.cookbook import doc_optparse
-
from galaxy.tools.util.galaxyops import *
-def main():
+assert sys.version_info[:2] >= ( 2, 4 )
+def main():
mincols = 1
upstream_pad = 0
downstream_pad = 0
@@ -42,20 +36,18 @@ def main():
except:
doc_optparse.exception()
- g1 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_fname ),
- chrom_col=chr_col_1,
- start_col=start_col_1,
- end_col=end_col_1,
- strand_col=strand_col_1,
- fix_strand=True )
- )
- g2 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in2_fname ),
- chrom_col=chr_col_2,
- start_col=start_col_2,
- end_col=end_col_2,
- strand_col=strand_col_2,
- fix_strand=True )
- )
+ g1 = NiceReaderWrapper( fileinput.FileInput( in_fname ),
+ chrom_col=chr_col_1,
+ start_col=start_col_1,
+ end_col=end_col_1,
+ strand_col=strand_col_1,
+ fix_strand=True )
+ g2 = NiceReaderWrapper( fileinput.FileInput( in2_fname ),
+ chrom_col=chr_col_2,
+ start_col=start_col_2,
+ end_col=end_col_2,
+ strand_col=strand_col_2,
+ fix_strand=True )
out_file = open( out_fname, "w" )
@@ -66,12 +58,15 @@ def main():
else:
out_file.write( "%s\n" % line )
except ParseError, e:
+ out_file.close()
fail( "Invalid file format: %s" % str( e ) )
+ out_file.close()
+
if g1.skipped > 0:
- print skipped( g1, filedesc=" of 1st dataset." )
+ print skipped( g1, filedesc=" of 1st dataset" )
if g2.skipped > 0:
- print skipped( g2, filedesc=" of 2nd dataset." )
+ print skipped( g2, filedesc=" of 2nd dataset" )
if __name__ == "__main__":
main()
diff --git a/tools/new_operations/gops_join.py b/tools/new_operations/gops_join.py
index 797b7c31a4a..daab6cb18e0 100644
--- a/tools/new_operations/gops_join.py
+++ b/tools/new_operations/gops_join.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-
"""
Join two sets of intervals using their overlap as the key.
@@ -9,24 +8,20 @@ usage: %prog bed_file_1 bed_file_2 out_file
-m, --mincols=N: Require this much overlap (default 1bp)
-f, --fill=N: none, right, left, both
"""
-
from galaxy import eggs
import pkg_resources
pkg_resources.require( "bx-python" )
-
-import traceback
-import fileinput
+import sys, traceback, fileinput
from warnings import warn
-
from bx.intervals import *
from bx.intervals.io import *
from bx.intervals.operations.join import *
from bx.cookbook import doc_optparse
-
from galaxy.tools.util.galaxyops import *
-def main():
+assert sys.version_info[:2] >= ( 2, 4 )
+def main():
mincols = 1
upstream_pad = 0
downstream_pad = 0
@@ -48,20 +43,18 @@ def main():
except:
doc_optparse.exception()
- g1 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_fname ),
- chrom_col=chr_col_1,
- start_col=start_col_1,
- end_col=end_col_1,
- strand_col=strand_col_1,
- fix_strand=True )
- )
- g2 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in2_fname ),
- chrom_col=chr_col_2,
- start_col=start_col_2,
- end_col=end_col_2,
- strand_col=strand_col_2,
- fix_strand=True )
- )
+ g1 = NiceReaderWrapper( fileinput.FileInput( in_fname ),
+ chrom_col=chr_col_1,
+ start_col=start_col_1,
+ end_col=end_col_1,
+ strand_col=strand_col_1,
+ fix_strand=True )
+ g2 = NiceReaderWrapper( fileinput.FileInput( in2_fname ),
+ chrom_col=chr_col_2,
+ start_col=start_col_2,
+ end_col=end_col_2,
+ strand_col=strand_col_2,
+ fix_strand=True )
out_file = open( out_fname, "w" )
@@ -72,10 +65,14 @@ def main():
else:
out_file.write( "%s\n" % outfields )
except ParseError, exc:
- fail( "Invalid file format: ", str( exc ) )
+ out_file.close()
+ fail( "Invalid file format: %s" % str( exc ) )
except MemoryError:
+ out_file.close()
fail( "Input datasets were too large to complete the join operation." )
+ out_file.close()
+
if g1.skipped > 0:
print skipped( g1, filedesc=" of 1st dataset" )
if g2.skipped > 0:
diff --git a/tools/new_operations/gops_merge.py b/tools/new_operations/gops_merge.py
index 86da86a3080..85d215f83f4 100644
--- a/tools/new_operations/gops_merge.py
+++ b/tools/new_operations/gops_merge.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-
"""
Merge overlaping regions.
@@ -8,25 +7,20 @@ usage: %prog in_file out_file
-m, --mincols=N: Require this much overlap (default 1bp)
-3, --threecol: Output 3 column bed
"""
-
from galaxy import eggs
import pkg_resources
pkg_resources.require( "bx-python" )
-
-import sys
-import traceback
-import fileinput
+import sys, traceback, fileinput
from warnings import warn
-
from bx.intervals import *
from bx.intervals.io import *
from bx.intervals.operations.merge import *
from bx.cookbook import doc_optparse
-
from galaxy.tools.util.galaxyops import *
-def main():
+assert sys.version_info[:2] >= ( 2, 4 )
+def main():
mincols = 1
upstream_pad = 0
downstream_pad = 0
@@ -39,13 +33,12 @@ def main():
except:
doc_optparse.exception()
- g1 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_fname ),
- chrom_col=chr_col_1,
- start_col=start_col_1,
- end_col=end_col_1,
- strand_col = strand_col_1,
- fix_strand=True )
- )
+ g1 = NiceReaderWrapper( fileinput.FileInput( in_fname ),
+ chrom_col=chr_col_1,
+ start_col=start_col_1,
+ end_col=end_col_1,
+ strand_col = strand_col_1,
+ fix_strand=True )
out_file = open( out_fname, "w" )
@@ -66,7 +59,10 @@ def main():
else:
out_file.write( "%s\n" % line )
except ParseError, exc:
- fail( "Invalid file format: ", str( exc ) )
+ out_file.close()
+ fail( "Invalid file format: %s" % str( exc ) )
+
+ out_file.close()
if g1.skipped > 0:
print skipped( g1, filedesc=" of 1st dataset" )
diff --git a/tools/new_operations/gops_subtract.py b/tools/new_operations/gops_subtract.py
index d15060e83c9..376b97f1089 100644
--- a/tools/new_operations/gops_subtract.py
+++ b/tools/new_operations/gops_subtract.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-
"""
Find regions of first bed file that do not overlap regions in a second
bed file
@@ -10,25 +9,20 @@ usage: %prog bed_file_1 bed_file_2 out_file
-m, --mincols=N: Require this much overlap (default 1bp)
-p, --pieces: just print pieces of second set (after padding)
"""
-
from galaxy import eggs
import pkg_resources
pkg_resources.require( "bx-python" )
-
-import sys
-import traceback
-import fileinput
+import sys, traceback, fileinput
from warnings import warn
-
from bx.intervals import *
from bx.intervals.io import *
from bx.intervals.operations.subtract import *
from bx.cookbook import doc_optparse
-
from galaxy.tools.util.galaxyops import *
-def main():
+assert sys.version_info[:2] >= ( 2, 4 )
+def main():
mincols = 1
upstream_pad = 0
downstream_pad = 0
@@ -43,20 +37,19 @@ def main():
except:
doc_optparse.exception()
- g1 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_fname ),
- chrom_col=chr_col_1,
- start_col=start_col_1,
- end_col=end_col_1,
- strand_col=strand_col_1,
- fix_strand=True )
- )
- g2 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in2_fname ),
- chrom_col=chr_col_2,
- start_col=start_col_2,
- end_col=end_col_2,
- strand_col=strand_col_2,
- fix_strand=True )
- )
+ g1 = NiceReaderWrapper( fileinput.FileInput( in_fname ),
+ chrom_col=chr_col_1,
+ start_col=start_col_1,
+ end_col=end_col_1,
+ strand_col=strand_col_1,
+ fix_strand=True )
+ g2 = NiceReaderWrapper( fileinput.FileInput( in2_fname ),
+ chrom_col=chr_col_2,
+ start_col=start_col_2,
+ end_col=end_col_2,
+ strand_col=strand_col_2,
+ fix_strand=True )
+
out_file = open( out_fname, "w" )
try:
@@ -66,7 +59,10 @@ def main():
else:
out_file.write( "%s\n" % line )
except ParseError, exc:
- fail( "Invalid file format: ", str( exc ) )
+ out_file.close()
+ fail( "Invalid file format: %s" % str( exc ) )
+
+ out_file.close()
if g1.skipped > 0:
print skipped( g1, filedesc=" of 2nd dataset" )
diff --git a/tools/new_operations/merge.xml b/tools/new_operations/merge.xml
index 8111716d6dd..1f6be7eff43 100644
--- a/tools/new_operations/merge.xml
+++ b/tools/new_operations/merge.xml
@@ -21,6 +21,11 @@
+
+
+
+
+
diff --git a/tools/new_operations/subtract.xml b/tools/new_operations/subtract.xml
index bc83a26ce23..60f3c155e9f 100644
--- a/tools/new_operations/subtract.xml
+++ b/tools/new_operations/subtract.xml
@@ -32,6 +32,13 @@
+
+
+
+
+
+
+
diff --git a/tools/regVariation/featureCounter.py b/tools/regVariation/featureCounter.py
index a5f7a0e15cc..0baa78d63bc 100644
--- a/tools/regVariation/featureCounter.py
+++ b/tools/regVariation/featureCounter.py
@@ -8,22 +8,18 @@ usage: %prog bed_file_1 bed_file_2 out_file
-1, --cols1=N,N,N,N: Columns for chr, start, end, strand in first file
-2, --cols2=N,N,N,N: Columns for chr, start, end, strand in second file
"""
-
from galaxy import eggs
import pkg_resources
pkg_resources.require( "bx-python" )
-
-import sys
-import traceback
-import fileinput
+import sys, traceback, fileinput
from warnings import warn
-
from bx.intervals.io import *
from bx.cookbook import doc_optparse
from bx.intervals.operations import quicksect
-
from galaxy.tools.util.galaxyops import *
+assert sys.version_info[:2] >= ( 2, 4 )
+
def stop_err(msg):
sys.stderr.write(msg)
sys.exit()
@@ -99,7 +95,6 @@ def count_coverage(readers):
yield interval
def main():
-
options, args = doc_optparse.parse( __doc__ )
try:
@@ -108,32 +103,29 @@ def main():
in1_fname, in2_fname, out_fname = args
except:
stop_err( "Data issue: click the pencil icon in the history item to correct the metadata attributes." )
-
- try:
- out_file = open( out_fname, "w" )
- except:
- stop_err( "Unable to open output file." )
g1 = NiceReaderWrapper( fileinput.FileInput( in1_fname ),
- chrom_col=chr_col_1,
- start_col=start_col_1,
- end_col=end_col_1,
- strand_col=strand_col_1,
- fix_strand=True)
+ chrom_col=chr_col_1,
+ start_col=start_col_1,
+ end_col=end_col_1,
+ strand_col=strand_col_1,
+ fix_strand=True )
g2 = NiceReaderWrapper( fileinput.FileInput( in2_fname ),
- chrom_col=chr_col_2,
- start_col=start_col_2,
- end_col=end_col_2,
- strand_col=strand_col_2,
- fix_strand=True)
- g2_copy = BitsetSafeNiceReaderWrapper ( NiceReaderWrapper( fileinput.FileInput( in2_fname ),
- chrom_col=chr_col_2,
- start_col=start_col_2,
- end_col=end_col_2,
- strand_col=strand_col_2,
- fix_strand=True) )
-
+ chrom_col=chr_col_2,
+ start_col=start_col_2,
+ end_col=end_col_2,
+ strand_col=strand_col_2,
+ fix_strand=True )
+ g2_copy = NiceReaderWrapper( fileinput.FileInput( in2_fname ),
+ chrom_col=chr_col_2,
+ start_col=start_col_2,
+ end_col=end_col_2,
+ strand_col=strand_col_2,
+ fix_strand=True )
+
+ out_file = open( out_fname, "w" )
+
try:
for line in count_coverage([g1,g2,g2_copy]):
if type( line ) is GenomicInterval:
@@ -141,11 +133,13 @@ def main():
else:
print >> out_file, line
except ParseError, exc:
- print >> sys.stderr, "Invalid file format: ", str( exc )
-
+ out_file.close()
+ fail( str( exc ) )
+
+ out_file.close()
+
if g1.skipped > 0:
print skipped( g1, filedesc=" of 1st dataset" )
-
if g2.skipped > 0:
print skipped( g2, filedesc=" of 2nd dataset" )
elif g2_copy.skipped > 0: