Changeset 1323:c6ce30677868
- Timestamp:
- 05/23/08 16:43:20 (8 months ago)
- Files:
-
- eggs.ini (modified) (2 diffs)
- lib/galaxy/tools/util/galaxyops/__init__.py (modified) (2 diffs)
- test-data/gops_basecoverage_out.txt (moved) (moved from test-data/gops-basecoverage.dat)
- test-data/gops_basecoverage_out2.txt (added)
- test-data/gops_cluster_bigint.bed (added)
- test-data/gops_complement_out.bed (moved) (moved from test-data/gops-complement.dat)
- test-data/gops_complement_out2.bed (added)
- test-data/gops_coverage_out.interval (moved) (moved from test-data/gops-coverage.dat)
- test-data/gops_coverage_out2.interval (added)
- test-data/gops_merge_out2.bed (added)
- test-data/gops_subtract_bigint.bed (added)
- tools/new_operations/basecoverage.xml (modified) (1 diff)
- tools/new_operations/cluster.xml (modified) (1 diff)
- tools/new_operations/complement.xml (modified) (1 diff)
- tools/new_operations/coverage.xml (modified) (1 diff)
- tools/new_operations/flanking_features.py (modified) (4 diffs)
- tools/new_operations/gops_basecoverage.py (modified) (4 diffs)
- tools/new_operations/gops_cluster.py (modified) (5 diffs)
- tools/new_operations/gops_complement.py (modified) (6 diffs)
- tools/new_operations/gops_concat.py (modified) (4 diffs)
- tools/new_operations/gops_coverage.py (modified) (4 diffs)
- tools/new_operations/gops_intersect.py (modified) (4 diffs)
- tools/new_operations/gops_join.py (modified) (4 diffs)
- tools/new_operations/gops_merge.py (modified) (4 diffs)
- tools/new_operations/gops_subtract.py (modified) (4 diffs)
- tools/new_operations/merge.xml (modified) (1 diff)
- tools/new_operations/subtract.xml (modified) (1 diff)
- tools/regVariation/featureCounter.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
eggs.ini
r1254 r1323 54 54 python_lzo = _static 55 55 flup = .dev_r2311 56 bx_python = _dev_r4 1856 bx_python = _dev_r427 57 57 nose = .dev_r101 58 58 DRMAA_python = _6.1u4 … … 60 60 ; source location, necessary for scrambling 61 61 [source] 62 bx_python = http://dist.g2.bx.psu.edu/bx-python_dist-r4 14.tar.bz262 bx_python = http://dist.g2.bx.psu.edu/bx-python_dist-r427.tar.bz2 63 63 Cheetah = http://umn.dl.sourceforge.net/sourceforge/cheetahtemplate/Cheetah-1.0.tar.gz 64 64 DRMAA_python = http://gridengine.sunsource.net/files/documents/7/36/DRMAA-python-0.2.tar.gz lib/galaxy/tools/util/galaxyops/__init__.py
r1281 r1323 1 """ 2 Utility functions for galaxyops 3 """ 1 """Utility functions for galaxyops""" 4 2 import sys 5 6 3 from bx.bitset import * 7 4 from bx.intervals.io import * 8 9 class BitsetSafeNiceReaderWrapper:10 """Handles exceptions thrown in bx."""11 def __init__( self, iterat ):12 self.iterat = iterat13 self.MAXINT = 2147483647 # max signed int value for 32-bit14 def __iter__( self ):15 while True:16 region = self.iterat.next()17 # NiceReaderWrapper can return a header, comment or GenomicInterval18 if type( region ) == GenomicInterval:19 if ( region.start > self.MAXINT ) or ( region.end > self.MAXINT ) or ( region.start > region.end ):20 self.iterat.skipped += 121 if self.iterat.skipped < 10:22 self.iterat.skipped_lines.append( ( self.iterat.linenum, self.iterat.current_line ) )23 else:24 yield region25 def __getattr__( self, name ):26 return getattr( self.iterat, name )27 def binned_bitsets( self , upstream_pad=0, downstream_pad=0, lens={} ):28 # This is duplicated in bx.intervals.io, but we need it here so that self refers to29 # our BitsetSafeNiceReaderWrapper rather than bx.intervals.io's GenomicIntervalReader30 last_chrom = None31 last_bitset = None32 bitsets = dict()33 for interval in self:34 if type( interval ) == GenomicInterval:35 chrom = interval[self.chrom_col]36 if chrom != last_chrom:37 if chrom not in bitsets:38 if chrom in lens:39 size = lens[chrom]40 else:41 size = MAX42 bitsets[chrom] = BinnedBitSet( size )43 last_chrom = chrom44 last_bitset = bitsets[chrom]45 start = max(int( interval[self.start_col]), 0 )46 end = min(int( interval[self.end_col]), size)47 last_bitset.set_range( start, end-start )48 return bitsets49 5 50 6 def warn( msg ): … … 73 29 74 30 def skipped( reader, filedesc="" ): 75 first_line, line_contents = reader.skipped_lines[0] 76 return 'Skipped %d invalid lines%s starting at line #%d: "%s"' \ 77 % ( reader.skipped, filedesc, first_line, line_contents ) 31 first_line, line_contents, problem = reader.skipped_lines[0] 32 return 'Skipped %d invalid lines%s, 1st line #%d: "%s", problem: %s' % ( reader.skipped, filedesc, first_line, line_contents, problem ) tools/new_operations/basecoverage.xml
r1129 r1323 14 14 <test> 15 15 <param name="input1" value="1.bed" /> 16 <output name="output" file="gops-basecoverage.dat" /> 16 <output name="output" file="gops_basecoverage_out.txt" /> 17 </test> 18 <test> 19 <param name="input1" value="gops_bigint.interval" /> 20 <output name="output" file="gops_basecoverage_out2.txt" /> 17 21 </test> 18 22 </tests> tools/new_operations/cluster.xml
r1129 r1323 33 33 <param name="returntype" value="1" /> 34 34 <output name="output" file="gops-cluster-1.bed" /> 35 </test> 35 </test> 36 <test> 37 <param name="input1" value="gops_cluster_bigint.bed" /> 38 <param name="distance" value="1" /> 39 <param name="minregions" value="2" /> 40 <param name="returntype" value="1" /> 41 <output name="output" file="gops-cluster-1.bed" /> 42 </test> 36 43 <test> 37 44 <param name="input1" value="5.bed" /> tools/new_operations/complement.xml
r1129 r1323 17 17 <param name="input1" value="1.bed" /> 18 18 <param name="allchroms" value="true" /> 19 <output name="output" file="gops-complement.dat" /> 19 <output name="output" file="gops_complement_out.bed" /> 20 </test> 21 <test> 22 <param name="input1" value="gops_bigint.interval" /> 23 <param name="allchroms" value="true" /> 24 <output name="output" file="gops_complement_out2.bed" /> 20 25 </test> 21 26 </tests> tools/new_operations/coverage.xml
r1129 r1323 18 18 <param name="input1" value="1.bed" /> 19 19 <param name="input2" value="2.bed" /> 20 <output name="output" file="gops-coverage.dat" /> 20 <output name="output" file="gops_coverage_out.interval" /> 21 </test> 22 <test> 23 <param name="input1" value="gops_bigint.interval" /> 24 <param name="input2" value="gops_bigint2.interval" /> 25 <output name="output" file="gops_coverage_out2.interval" /> 21 26 </test> 22 27 </tests> tools/new_operations/flanking_features.py
r1281 r1323 11 11 import pkg_resources 12 12 pkg_resources.require( "bx-python" ) 13 14 import sys 15 import traceback 16 import fileinput 13 import sys, traceback, fileinput 17 14 from warnings import warn 18 19 15 from bx.cookbook import doc_optparse 20 16 from galaxy.tools.util.galaxyops import * 21 22 17 from bx.intervals.io import * 23 18 from bx.intervals.operations import quicksect 19 20 assert sys.version_info[:2] >= ( 2, 4 ) 24 21 25 22 def get_closest_feature (node, direction, threshold_up, threshold_down, report_func_up, report_func_down): … … 122 119 123 120 def main(): 124 125 121 options, args = doc_optparse.parse( __doc__ ) 126 122 try: … … 131 127 doc_optparse.exception() 132 128 133 g1 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_fname ), 134 chrom_col=chr_col_1, 135 start_col=start_col_1, 136 end_col=end_col_1, 137 strand_col=strand_col_1, 138 fix_strand=True ) 139 ) 140 g2 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in2_fname ), 141 chrom_col=chr_col_2, 142 start_col=start_col_2, 143 end_col=end_col_2, 144 strand_col=strand_col_2, 145 fix_strand=True ) 146 ) 129 g1 = NiceReaderWrapper( fileinput.FileInput( in_fname ), 130 chrom_col=chr_col_1, 131 start_col=start_col_1, 132 end_col=end_col_1, 133 strand_col=strand_col_1, 134 fix_strand=True ) 135 g2 = NiceReaderWrapper( fileinput.FileInput( in2_fname ), 136 chrom_col=chr_col_2, 137 start_col=start_col_2, 138 end_col=end_col_2, 139 strand_col=strand_col_2, 140 fix_strand=True ) 147 141 out_file = open( out_fname, "w" ) 148 149 142 try: 150 143 for line in proximal_region_finder([g1,g2], direction): … … 154 147 out_file.write( "%s\n" % line ) 155 148 except ParseError, exc: 156 fail( "Invalid file format: ",str( exc ) )149 fail( "Invalid file format: %s" % str( exc ) ) 157 150 158 151 print "Direction: %s" %(direction) 159 160 152 if g1.skipped > 0: 161 153 print skipped( g1, filedesc=" of 1st dataset" ) 162 163 154 if g2.skipped > 0: 164 155 print skipped( g2, filedesc=" of 2nd dataset" ) 165 156 166 167 157 if __name__ == "__main__": 168 158 main() tools/new_operations/gops_basecoverage.py
r1281 r1323 1 1 #!/usr/bin/env python 2 3 2 """ 4 3 Count total base coverage. … … 7 6 -1, --cols1=N,N,N,N: Columns for start, end, strand in first file 8 7 """ 9 10 8 from galaxy import eggs 11 9 import pkg_resources 12 10 pkg_resources.require( "bx-python" ) 13 11 14 import sys 15 import traceback 16 import fileinput 12 import sys, traceback, fileinput 17 13 from warnings import warn 18 19 14 from bx.intervals import * 20 15 from bx.intervals.io import * 21 16 from bx.intervals.operations.base_coverage import * 22 17 from bx.cookbook import doc_optparse 23 24 18 from galaxy.tools.util.galaxyops import * 25 19 … … 27 21 28 22 def main(): 29 30 23 upstream_pad = 0 31 24 downstream_pad = 0 … … 38 31 doc_optparse.exception() 39 32 40 g1 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_fname ), 41 chrom_col=chr_col_1, 42 start_col=start_col_1, 43 end_col=end_col_1, 44 fix_strand=True ) 45 ) 33 g1 = NiceReaderWrapper( fileinput.FileInput( in_fname ), 34 chrom_col=chr_col_1, 35 start_col=start_col_1, 36 end_col=end_col_1, 37 fix_strand=True ) 46 38 47 39 if strand_col_1 >= 0: 48 40 g1.strand_col=strand_col_1 49 50 41 try: 51 42 bases = base_coverage(g1) 52 43 except ParseError, exc: 53 fail( "Invalid file format: ", str( exc ) ) 54 44 fail( "Invalid file format: %s" % str( exc ) ) 55 45 out_file = open( out_fname, "w" ) 56 46 out_file.write( "%s\n" % str( bases ) ) 57 47 out_file.close() 58 48 if g1.skipped > 0: 59 49 print skipped( g1, filedesc="" ) tools/new_operations/gops_cluster.py
r1281 r1323 1 1 #!/usr/bin/env python 2 3 2 """ 4 3 Cluster regions of intervals. … … 11 10 -o, --output=N: 1)merged 2)filtered 3)clustered 4) minimum 5) maximum 12 11 """ 13 14 12 from galaxy import eggs 15 13 import pkg_resources 16 14 pkg_resources.require( "bx-python" ) 17 18 import sys 19 import traceback 20 import fileinput 15 import sys, traceback, fileinput 21 16 from warnings import warn 22 23 17 from bx.intervals import * 24 18 from bx.intervals.io import * 25 19 from bx.intervals.operations.find_clusters import * 26 20 from bx.cookbook import doc_optparse 21 from galaxy.tools.util.galaxyops import * 27 22 28 from galaxy.tools.util.galaxyops import * 23 assert sys.version_info[:2] >= ( 2, 4 ) 29 24 30 25 def main(): … … 46 41 doc_optparse.exception() 47 42 48 g1 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_fname ), 49 chrom_col=chr_col_1, 50 start_col=start_col_1, 51 end_col=end_col_1, 52 strand_col=strand_col_1, 53 fix_strand=True ) 54 ) 55 out_file = open( out_fname, "w" ) 43 g1 = NiceReaderWrapper( fileinput.FileInput( in_fname ), 44 chrom_col=chr_col_1, 45 start_col=start_col_1, 46 end_col=end_col_1, 47 strand_col=strand_col_1, 48 fix_strand=True ) 56 49 57 50 # Get the cluster tree … … 59 52 clusters, extra = find_clusters( g1, mincols=distance, minregions=minregions) 60 53 except ParseError, exc: 61 fail( "Invalid file format: ",str( exc ) )54 fail( "Invalid file format: %s" % str( exc ) ) 62 55 63 56 f1 = open( in_fname, "r" ) 57 out_file = open( out_fname, "w" ) 64 58 65 59 # If "merge" … … 130 124 131 125 f1.close() 126 out_file.close() 132 127 133 128 if g1.skipped > 0: tools/new_operations/gops_complement.py
r1281 r1323 1 1 #!/usr/bin/env python 2 3 2 """ 4 3 Complement regions. … … 9 8 -a, --all: Complement all chromosomes (Genome-wide complement) 10 9 """ 11 12 10 from galaxy import eggs 13 11 import pkg_resources 14 12 pkg_resources.require( "bx-python" ) 15 16 import sys 17 import traceback 18 import fileinput 13 import sys, traceback, fileinput 19 14 from warnings import warn 20 21 15 from bx.intervals import * 22 16 from bx.intervals.io import * … … 24 18 from bx.intervals.operations.subtract import subtract 25 19 from bx.cookbook import doc_optparse 20 from galaxy.tools.util.galaxyops import * 26 21 27 from galaxy.tools.util.galaxyops import * 22 assert sys.version_info[:2] >= ( 2, 4 ) 28 23 29 24 def main(): … … 41 36 doc_optparse.exception() 42 37 43 g1 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_fname ), 44 chrom_col=chr_col_1, 45 start_col=start_col_1, 46 end_col=end_col_1, 47 strand_col=strand_col_1, 48 fix_strand=True ) 49 ) 50 51 out_file = open( out_fname, "w" ) 38 g1 = NiceReaderWrapper( fileinput.FileInput( in_fname ), 39 chrom_col=chr_col_1, 40 start_col=start_col_1, 41 end_col=end_col_1, 42 strand_col=strand_col_1, 43 fix_strand=True ) 44 52 45 lens = dict() 53 46 chroms = list() 47 # dbfile is used to determine the length of each chromosome. The lengths 48 # are added to the lens dict and passed copmlement operation code in bx. 54 49 dbfile = fileinput.FileInput( "static/ucsc/chrom/"+db+".len" ) 55 50 … … 83 78 generator = complement(g1, lens) 84 79 80 out_file = open( out_fname, "w" ) 81 85 82 try: 86 83 for interval in generator: … … 90 87 out_file.write( "%s\n" % interval ) 91 88 except ParseError, exc: 92 fail( "Invalid file format: ", str( exc ) ) 89 out_file.close() 90 fail( "Invalid file format: %s" % str( exc ) ) 91 92 out_file.close() 93 93 94 94 if g1.skipped > 0: tools/new_operations/gops_concat.py
r1281 r1323 1 1 #!/usr/bin/env python 2 3 2 """ 4 3 Concatenate two bed files. The concatenated files are returned in the … … 14 13 -s, --sameformat: All files are precisely the same format. 15 14 """ 16 17 15 from galaxy import eggs 18 16 import pkg_resources 19 17 pkg_resources.require( "bx-python" ) 20 21 import sys 22 import traceback 23 import fileinput 18 import sys, traceback, fileinput 24 19 from warnings import warn 25 26 20 from bx.intervals import * 27 21 from bx.intervals.io import * 28 22 from bx.intervals.operations.concat import * 29 23 from bx.cookbook import doc_optparse 30 31 24 from galaxy.tools.util.galaxyops import * 32 25 26 assert sys.version_info[:2] >= ( 2, 4 ) 27 33 28 def main(): 34 35 29 sameformat=False 36 30 upstream_pad = 0 … … 46 40 doc_optparse.exception() 47 41 48 g1 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_file_1 ), 49 chrom_col=chr_col_1, 50 start_col=start_col_1, 51 end_col=end_col_1, 52 fix_strand=True ) 53 ) 42 g1 = NiceReaderWrapper( fileinput.FileInput( in_file_1 ), 43 chrom_col=chr_col_1, 44 start_col=start_col_1, 45 end_col=end_col_1, 46 fix_strand=True ) 47 48 g2 = NiceReaderWrapper( fileinput.FileInput( in_file_2 ), 49 chrom_col=chr_col_2, 50 start_col=start_col_2, 51 end_col=end_col_2, 52 strand_col=strand_col_2, 53 fix_strand=True ) 54 54 55 if strand_col_1 >= 0: 55 g1.strand_col=strand_col_1 56 57 g2 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_file_2 ), 58 chrom_col=chr_col_2, 59 start_col=start_col_2, 60 end_col=end_col_2, 61 strand_col=strand_col_2, 62 fix_strand=True ) 63 ) 64 56 g1.strand_col = strand_col_1 57 65 58 out_file = open( out_fname, "w" ) 66 59 … … 72 65 out_file.write( "%s\n" % line ) 73 66 except ParseError, exc: 74 fail( "Invalid file format: ", str( exc ) ) 75 67 out_file.close() 68 fail( "Invalid file format: %s" % str( exc ) ) 69 70 out_file.close() 71 76 72 if g1.skipped > 0: 77 73 print skipped( g1, filedesc=" of 1st dataset" ) tools/new_operations/gops_coverage.py
r1281 r1323 1 1 #!/usr/bin/env python 2 3 2 """ 4 3 Calculate coverage of one query on another, and append the coverage to … … 9 8 -2, --cols2=N,N,N,N: Columns for start, end, strand in second file 10 9 """ 11 12 10 from galaxy import eggs 13 11 import pkg_resources 14 12 pkg_resources.require( "bx-python" ) 15 16 import sys 17 import traceback 18 import fileinput 13 import sys, traceback, fileinput 19 14 from warnings import warn 20 21 15 from bx.intervals import * 22 16 from bx.intervals.io import * 23 17 from bx.intervals.operations.coverage import * 24 18 from bx.cookbook import doc_optparse 25 26 19 from galaxy.tools.util.galaxyops import * 27 20 21 assert sys.version_info[:2] >= ( 2, 4 ) 22 28 23 def main(): 29 30 24 upstream_pad = 0 31 25 downstream_pad = 0 … … 39 33 doc_optparse.exception() 40 34 41 g1 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_fname ), 42 chrom_col=chr_col_1, 43 start_col=start_col_1, 44 end_col=end_col_1, 45 strand_col=strand_col_1, 46 fix_strand=True ) 47 ) 48 g2 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in2_fname ), 49 chrom_col=chr_col_2, 50 start_col=start_col_2, 51 end_col=end_col_2, 52 strand_col=strand_col_2, 53 fix_strand=True ) 54 ) 35 g1 = NiceReaderWrapper( fileinput.FileInput( in_fname ), 36 chrom_col=chr_col_1, 37 start_col=start_col_1, 38 end_col=end_col_1, 39 strand_col=strand_col_1, 40 fix_strand=True ) 41 g2 = NiceReaderWrapper( fileinput.FileInput( in2_fname ), 42 chrom_col=chr_col_2, 43 start_col=start_col_2, 44 end_col=end_col_2, 45 strand_col=strand_col_2, 46 fix_strand=True ) 47 55 48 out_file = open( out_fname, "w" ) 56 49 … … 62 55 out_file.write( "%s\n" % line ) 63 56 except ParseError, exc: 64 fail( "Invalid file format: ", str( exc ) ) 57 out_file.close() 58 fail( "Invalid file format: %s" % str( exc ) ) 59 60 out_file.close() 65 61 66 62 if g1.skipped > 0: tools/new_operations/gops_intersect.py
r1281 r1323 1 1 #!/usr/bin/env python 2 3 2 """ 4 3 Find regions of first bed file that overlap regions in a second bed file … … 10 9 -p, --pieces: just print pieces of second set (after padding) 11 10 """ 12 13 11 from galaxy import eggs 14 12 import pkg_resources 15 13 pkg_resources.require( "bx-python" ) 16 17 import sys 18 import traceback 19 import fileinput 14 import sys, traceback, fileinput 20 15 from warnings import warn 21 22 16 from bx.intervals import * 23 17 from bx.intervals.io import * 24 18 from bx.intervals.operations.intersect import * 25 19 from bx.cookbook import doc_optparse 26 27 20 from galaxy.tools.util.galaxyops import * 28 21 22 assert sys.version_info[:2] >= ( 2, 4 ) 23 29 24 def main(): 30 31 25 mincols = 1 32 26 upstream_pad = 0 … … 43 37 doc_optparse.exception() 44 38 45 g1 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_fname ), 46 chrom_col=chr_col_1, 47 start_col=start_col_1, 48 end_col=end_col_1, 49 strand_col=strand_col_1, 50 fix_strand=True ) 51 ) 52 g2 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in2_fname ), 53 chrom_col=chr_col_2, 54 start_col=start_col_2, 55 end_col=end_col_2, 56 strand_col=strand_col_2, 57 fix_strand=True ) 58 ) 39 g1 = NiceReaderWrapper( fileinput.FileInput( in_fname ), 40 chrom_col=chr_col_1, 41 start_col=start_col_1, 42 end_col=end_col_1, 43 strand_col=strand_col_1, 44 fix_strand=True ) 45 g2 = NiceReaderWrapper( fileinput.FileInput( in2_fname ), 46 chrom_col=chr_col_2, 47 start_col=start_col_2, 48 end_col=end_col_2, 49 strand_col=strand_col_2, 50 fix_strand=True ) 59 51 60 52 out_file = open( out_fname, "w" ) … … 67 59 out_file.write( "%s\n" % line ) 68 60 except ParseError, e: 61 out_file.close() 69 62 fail( "Invalid file format: %s" % str( e ) ) 70 63 64 out_file.close() 65 71 66 if g1.skipped > 0: 72 print skipped( g1, filedesc=" of 1st dataset ." )67 print skipped( g1, filedesc=" of 1st dataset" ) 73 68 if g2.skipped > 0: 74 print skipped( g2, filedesc=" of 2nd dataset ." )69 print skipped( g2, filedesc=" of 2nd dataset" ) 75 70 76 71 if __name__ == "__main__": tools/new_operations/gops_join.py
r1281 r1323 1 1 #!/usr/bin/env python 2 3 2 """ 4 3 Join two sets of intervals using their overlap as the key. … … 10 9 -f, --fill=N: none, right, left, both 11 10 """ 12 13 11 from galaxy import eggs 14 12 import pkg_resources 15 13 pkg_resources.require( "bx-python" ) 16 17 import traceback 18 import fileinput 14 import sys, traceback, fileinput 19 15 from warnings import warn 20 21 16 from bx.intervals import * 22 17 from bx.intervals.io import * 23 18 from bx.intervals.operations.join import * 24 19 from bx.cookbook import doc_optparse 25 26 20 from galaxy.tools.util.galaxyops import * 27 21 22 assert sys.version_info[:2] >= ( 2, 4 ) 23 28 24 def main(): 29 30 25 mincols = 1 31 26 upstream_pad = 0 … … 49 44 doc_optparse.exception() 50 45 51 g1 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_fname ), 52 chrom_col=chr_col_1, 53 start_col=start_col_1, 54 end_col=end_col_1, 55 strand_col=strand_col_1, 56 fix_strand=True ) 57 ) 58 g2 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in2_fname ), 59 chrom_col=chr_col_2, 60 start_col=start_col_2, 61 end_col=end_col_2, 62 strand_col=strand_col_2, 63 fix_strand=True ) 64 ) 46 g1 = NiceReaderWrapper( fileinput.FileInput( in_fname ), 47 chrom_col=chr_col_1, 48 start_col=start_col_1, 49 end_col=end_col_1, 50 strand_col=strand_col_1, 51 fix_strand=True ) 52 g2 = NiceReaderWrapper( fileinput.FileInput( in2_fname ), 53 chrom_col=chr_col_2, 54 start_col=start_col_2, 55 end_col=end_col_2, 56 strand_col=strand_col_2, 57 fix_strand=True ) 65 58 66 59 out_file = open( out_fname, "w" ) … … 73 66 out_file.write( "%s\n" % outfields ) 74 67 except ParseError, exc: 75 fail( "Invalid file format: ", str( exc ) ) 68 out_file.close() 69 fail( "Invalid file format: %s" % str( exc ) ) 76 70 except MemoryError: 71 out_file.close() 77 72 fail( "Input datasets were too large to complete the join operation." ) 73 74 out_file.close() 78 75 79 76 if g1.skipped > 0: tools/new_operations/gops_merge.py
r1281 r1323 1 1 #!/usr/bin/env python 2 3 2 """ 4 3 Merge overlaping regions. … … 9 8 -3, --threecol: Output 3 column bed 10 9 """ 11 12 10 from galaxy import eggs 13 11 import pkg_resources 14 12 pkg_resources.require( "bx-python" ) 15 16 import sys 17 import traceback 18 import fileinput 13 import sys, traceback, fileinput 19 14 from warnings import warn 20 21 15 from bx.intervals import * 22 16 from bx.intervals.io import * 23 17 from bx.intervals.operations.merge import * 24 18 from bx.cookbook import doc_optparse 25 26 19 from galaxy.tools.util.galaxyops import * 27 20 21 assert sys.version_info[:2] >= ( 2, 4 ) 22 28 23 def main(): 29 30 24 mincols = 1 31 25 upstream_pad = 0 … … 40 34 doc_optparse.exception() 41 35 42 g1 = BitsetSafeNiceReaderWrapper( NiceReaderWrapper( fileinput.FileInput( in_fname ), 43 chrom_col=chr_col_1, 44 start_col=start_col_1, 45 end_col=end_col_1, 46 strand_col = strand_col_1, 47 fix_strand=True ) 48 ) 36 g1 = NiceReaderWrapper( fileinput.FileInput( in_fname ), 37 chrom_col=chr_col_1, 38 start_col=start_col_1, 39 end_col=end_col_1, 40 strand_col = strand_col_1, 41 fix_strand=True ) 49 42 50 43 out_file = open( out_fname, "w" ) … … 67 60 out_file.write( "%s\n" % line ) 68 61 except ParseError, exc: 69 fail( "Invalid file format: ", str( exc ) ) 62 out_file.close() 63 fail( "Invalid file format: %s" % str( exc ) ) 64 65 out_file.close() <