diff --git a/lib/galaxy/app.py b/lib/galaxy/app.py index 904750b5436..378cffe3e92 100644 --- a/lib/galaxy/app.py +++ b/lib/galaxy/app.py @@ -186,6 +186,6 @@ class UniverseApplication( object ): def configure_fluent_log( self ): if self.config.fluent_log: from galaxy.util.log.fluent_log import FluentTraceLogger - self.trace_logger = FluentTraceLogger( 'galaxy', self.config.fluent_host, self.config.fluent_port ) + self.trace_logger = FluentTraceLogger( 'galaxy', self.config.fluent_host, self.config.fluent_port ) else: self.trace_logger = None diff --git a/lib/galaxy/config.py b/lib/galaxy/config.py index 0f3c7d92516..d2701555a8f 100644 --- a/lib/galaxy/config.py +++ b/lib/galaxy/config.py @@ -282,7 +282,7 @@ class Configuration( object ): self.biostar_url = kwargs.get( 'biostar_url', None ) self.biostar_key_name = kwargs.get( 'biostar_key_name', None ) self.biostar_key = kwargs.get( 'biostar_key', None ) - # Experimental: This will not be enabled by default and will hide + # Experimental: This will not be enabled by default and will hide # nonproduction code. # The api_folders refers to whether the API exposes the /folders section. self.api_folders = string_as_bool( kwargs.get( 'api_folders', False ) ) @@ -302,7 +302,7 @@ class Configuration( object ): @property def sentry_dsn_public( self ): """ - Sentry URL with private key removed for use in client side scripts, + Sentry URL with private key removed for use in client side scripts, sentry server will need to be configured to accept events """ if self.sentry_dsn: @@ -436,8 +436,8 @@ def configure_logging( config ): """ # Get root logger root = logging.getLogger() - # PasteScript will have already configured the logger if the - # 'loggers' section was found in the config file, otherwise we do + # PasteScript will have already configured the logger if the + # 'loggers' section was found in the config file, otherwise we do # some simple setup using the 'log_*' values from the config. if not config.global_conf_parser.has_section( "loggers" ): format = config.get( "log_format", "%(name)s %(levelname)s %(asctime)s %(message)s" ) diff --git a/lib/galaxy/datatypes/assembly.py b/lib/galaxy/datatypes/assembly.py index 3a0207a8ca5..3583e524a3d 100644 --- a/lib/galaxy/datatypes/assembly.py +++ b/lib/galaxy/datatypes/assembly.py @@ -168,7 +168,7 @@ class Velvet( Html ): def regenerate_primary_file(self,dataset): """ - cannot do this until we are setting metadata + cannot do this until we are setting metadata """ log.debug( "Velvet log info %s" % 'JJ regenerate_primary_file') gen_msg = '' diff --git a/lib/galaxy/datatypes/binary.py b/lib/galaxy/datatypes/binary.py index 22fff082be8..fbca965b290 100644 --- a/lib/galaxy/datatypes/binary.py +++ b/lib/galaxy/datatypes/binary.py @@ -203,7 +203,7 @@ class Bam( Binary ): stderr = open( stderr_name ).read().strip() if stderr: if exit_code != 0: - shutil.rmtree( tmp_dir) #clean up + shutil.rmtree( tmp_dir) #clean up raise Exception, "Error Grooming BAM file contents: %s" % stderr else: print stderr @@ -231,7 +231,7 @@ class Bam( Binary ): stderr = open( stderr_name ).read().strip() if stderr: if exit_code != 0: - os.unlink( stderr_name ) #clean up + os.unlink( stderr_name ) #clean up raise Exception, "Error Setting BAM Metadata: %s" % stderr else: print stderr @@ -240,7 +240,7 @@ class Bam( Binary ): os.unlink( stderr_name ) def sniff( self, filename ): # BAM is compressed in the BGZF format, and must not be uncompressed in Galaxy. - # The first 4 bytes of any bam file is 'BAM\1', and the file is binary. + # The first 4 bytes of any bam file is 'BAM\1', and the file is binary. try: header = gzip.open( filename ).read(4) if binascii.b2a_hex( header ) == binascii.hexlify( 'BAM\1' ): @@ -250,7 +250,7 @@ class Bam( Binary ): return False def set_peek( self, dataset, is_multi_byte=False ): if not dataset.dataset.purged: - dataset.peek = "Binary bam alignments file" + dataset.peek = "Binary bam alignments file" dataset.blurb = data.nice_size( dataset.get_size() ) else: dataset.peek = 'file does not exist' @@ -278,7 +278,7 @@ class Bam( Binary ): samtools_source = dataproviders.dataset.SamtoolsDataProvider( dataset ) settings[ 'comment_char' ] = '@' return dataproviders.line.RegexLineDataProvider( samtools_source, **settings ) - + @dataproviders.decorators.dataprovider_factory( 'column', dataproviders.column.ColumnarDataProvider.settings ) def column_dataprovider( self, dataset, **settings ): samtools_source = dataproviders.dataset.SamtoolsDataProvider( dataset ) @@ -352,7 +352,7 @@ class H5( Binary ): def set_peek( self, dataset, is_multi_byte=False ): if not dataset.dataset.purged: - dataset.peek = "Binary h5 file" + dataset.peek = "Binary h5 file" dataset.blurb = data.nice_size( dataset.get_size() ) else: dataset.peek = 'file does not exist' @@ -372,7 +372,7 @@ class Scf( Binary ): def set_peek( self, dataset, is_multi_byte=False ): if not dataset.dataset.purged: - dataset.peek = "Binary scf sequence file" + dataset.peek = "Binary scf sequence file" dataset.blurb = data.nice_size( dataset.get_size() ) else: dataset.peek = 'file does not exist' @@ -404,7 +404,7 @@ class Sff( Binary ): return False def set_peek( self, dataset, is_multi_byte=False ): if not dataset.dataset.purged: - dataset.peek = "Binary sff file" + dataset.peek = "Binary sff file" dataset.blurb = data.nice_size( dataset.get_size() ) else: dataset.peek = 'file does not exist' @@ -451,7 +451,7 @@ class BigWig(Binary): return dataset.peek except: return "Binary UCSC %s file (%s)" % ( self._name, data.nice_size( dataset.get_size() ) ) - + Binary.register_sniffable_binary_format("bigwig", "bigwig", BigWig) @@ -470,9 +470,9 @@ Binary.register_sniffable_binary_format("bigbed", "bigbed", BigBed) class TwoBit (Binary): """Class describing a TwoBit format nucleotide file""" - + file_ext = "twobit" - + def sniff(self, filename): try: # All twobit files start with a 16-byte header. If the file is smaller than 16 bytes, it's obviously not a valid twobit file. diff --git a/lib/galaxy/datatypes/converters/bedgraph_to_array_tree_converter.py b/lib/galaxy/datatypes/converters/bedgraph_to_array_tree_converter.py index 76403f4b181..b20a1d889a5 100644 --- a/lib/galaxy/datatypes/converters/bedgraph_to_array_tree_converter.py +++ b/lib/galaxy/datatypes/converters/bedgraph_to_array_tree_converter.py @@ -23,13 +23,13 @@ class BedGraphReader: if not line: raise StopIteration() if line.isspace(): - continue + continue if line[0] == "#": continue if line[0].isalpha(): if line.startswith( "track" ) or line.startswith( "browser" ): continue - + feature = line.strip().split() chrom = feature[0] chrom_start = int(feature[1]) @@ -37,19 +37,19 @@ class BedGraphReader: score = float(feature[3]) return chrom, chrom_start, chrom_end, None, score def main(): - + input_fname = sys.argv[1] out_fname = sys.argv[2] - + reader = BedGraphReader( open( input_fname ) ) - + # Fill array from reader d = array_tree_dict_from_reader( reader, {}, block_size = BLOCK_SIZE ) - + for array_tree in d.itervalues(): array_tree.root.build_summary() - + FileArrayTreeDict.dict_to_file( d, open( out_fname, "w" ) ) -if __name__ == "__main__": +if __name__ == "__main__": main() \ No newline at end of file diff --git a/lib/galaxy/datatypes/converters/bgzip.py b/lib/galaxy/datatypes/converters/bgzip.py index 7a577129048..a419257a2b8 100644 --- a/lib/galaxy/datatypes/converters/bgzip.py +++ b/lib/galaxy/datatypes/converters/bgzip.py @@ -19,13 +19,13 @@ def main(): parser.add_option( '-P', '--preset', dest='preset' ) (options, args) = parser.parse_args() input_fname, output_fname = args - + tmpfile = tempfile.NamedTemporaryFile() sort_params = None - + if options.chrom_col and options.start_col and options.end_col: - sort_params = ["sort", - "-k%(i)s,%(i)s" % { 'i': options.chrom_col }, + sort_params = ["sort", + "-k%(i)s,%(i)s" % { 'i': options.chrom_col }, "-k%(i)i,%(i)in" % { 'i': options.start_col }, "-k%(i)i,%(i)in" % { 'i': options.end_col } ] @@ -40,9 +40,8 @@ def main(): after_sort = subprocess.Popen(sort_params, stdin=grepped.stdout, stderr=subprocess.PIPE, stdout=tmpfile ) grepped.stdout.close() output, err = after_sort.communicate() - + ctabix.tabix_compress(tmpfile.name, output_fname, force=True) - -if __name__ == "__main__": + +if __name__ == "__main__": main() - \ No newline at end of file diff --git a/lib/galaxy/datatypes/converters/fasta_to_len.py b/lib/galaxy/datatypes/converters/fasta_to_len.py index d604d8dd101..278a3449e5d 100644 --- a/lib/galaxy/datatypes/converters/fasta_to_len.py +++ b/lib/galaxy/datatypes/converters/fasta_to_len.py @@ -10,7 +10,7 @@ import sys, os assert sys.version_info[:2] >= ( 2, 4 ) def compute_fasta_length( fasta_file, out_file, keep_first_char, keep_first_word=False ): - + infile = fasta_file out = open( out_file, 'w') keep_first_char = int( keep_first_char ) diff --git a/lib/galaxy/datatypes/converters/fastq_to_fqtoc.py b/lib/galaxy/datatypes/converters/fastq_to_fqtoc.py index 06654a17227..d9856ee9fc0 100644 --- a/lib/galaxy/datatypes/converters/fastq_to_fqtoc.py +++ b/lib/galaxy/datatypes/converters/fastq_to_fqtoc.py @@ -38,11 +38,11 @@ def main(): chunk_end = in_file.tell() out_file.write('{"start":"%s","end":"%s","sequences":"%s"},' % (chunk_begin, chunk_end, sequences)) chunk_begin = chunk_end - + chunk_end = in_file.tell() out_file.write('{"start":"%s","end":"%s","sequences":"%s"}' % (chunk_begin, chunk_end, (current_line % lines_per_chunk) / 4)) out_file.write(']}\n') - -if __name__ == "__main__": + +if __name__ == "__main__": main() diff --git a/lib/galaxy/datatypes/converters/fastqsolexa_to_fasta_converter.py b/lib/galaxy/datatypes/converters/fastqsolexa_to_fasta_converter.py index 1b68b3f6a2a..b5d82ba81fb 100644 --- a/lib/galaxy/datatypes/converters/fastqsolexa_to_fasta_converter.py +++ b/lib/galaxy/datatypes/converters/fastqsolexa_to_fasta_converter.py @@ -7,7 +7,7 @@ the order should be: 1st line: @title_of_seq 2nd line: nucleotides 3rd line: +title_of_qualityscore (might be skipped) -4th line: quality scores +4th line: quality scores (in three forms: a. digits, b. ASCII codes, the first char as the coding base, c. ASCII codes without the first char.) Usage: @@ -52,4 +52,4 @@ def __main__(): outfile.close() -if __name__ == "__main__": __main__() \ No newline at end of file +if __name__ == "__main__": __main__() \ No newline at end of file diff --git a/lib/galaxy/datatypes/converters/fastqsolexa_to_qual_converter.py b/lib/galaxy/datatypes/converters/fastqsolexa_to_qual_converter.py index 870a69fbfb4..c87228f842e 100644 --- a/lib/galaxy/datatypes/converters/fastqsolexa_to_qual_converter.py +++ b/lib/galaxy/datatypes/converters/fastqsolexa_to_qual_converter.py @@ -7,7 +7,7 @@ the order should be: 1st line: @title_of_seq 2nd line: nucleotides 3rd line: +title_of_qualityscore (might be skipped) -4th line: quality scores +4th line: quality scores (in three forms: a. digits, b. ASCII codes, the first char as the coding base, c. ASCII codes without the first char.) Usage: @@ -30,7 +30,7 @@ def __main__(): seq_title_startswith = '' default_coding_value = 64 fastq_block_lines = 0 - + for i, line in enumerate( file( infile_name ) ): line = line.rstrip() if not line or line.startswith( '#' ): @@ -52,7 +52,7 @@ def __main__(): if not qual_title_startswith: qual_title_startswith = line_startswith if line_startswith != qual_title_startswith: - stop_err( 'Invalid fastqsolexa format at line %d: %s.' % ( i + 1, line ) ) + stop_err( 'Invalid fastqsolexa format at line %d: %s.' % ( i + 1, line ) ) quality_title = line[1:] if quality_title and read_title != quality_title: stop_err( 'Invalid fastqsolexa format at line %d: sequence title "%s" differes from score title "%s".' % ( i + 1, read_title, quality_title ) ) @@ -67,15 +67,15 @@ def __main__(): # peek: ascii or digits? val = line.split()[0] - try: + try: check = int( val ) fastq_integer = True except: fastq_integer = False - + if fastq_integer: # digits qual = line - else: + else: # ascii quality_score_length = len( line ) if quality_score_length == read_length + 1: @@ -89,8 +89,7 @@ def __main__(): score = ord( char ) - quality_score_startswith # 64 qual = "%s%s " % ( qual, str( score ) ) outfile_score.write( '%s\n' % qual ) - + outfile_score.close() -if __name__ == "__main__": __main__() - \ No newline at end of file +if __name__ == "__main__": __main__() diff --git a/lib/galaxy/datatypes/converters/gff_to_interval_index_converter.py b/lib/galaxy/datatypes/converters/gff_to_interval_index_converter.py index 2f682cc4dca..07b3631dc71 100644 --- a/lib/galaxy/datatypes/converters/gff_to_interval_index_converter.py +++ b/lib/galaxy/datatypes/converters/gff_to_interval_index_converter.py @@ -18,23 +18,22 @@ from bx.interval_index_file import Indexes def main(): # Arguments input_fname, out_fname = sys.argv[1:] - + # Do conversion. index = Indexes() offset = 0 reader_wrapper = GFFReaderWrapper( fileinput.FileInput( input_fname ), fix_strand=True ) - for feature in list( reader_wrapper ): + for feature in list( reader_wrapper ): # Add feature; index expects BED coordinates. if isinstance( feature, GenomicInterval ): convert_gff_coords_to_bed( feature ) index.add( feature.chrom, feature.start, feature.end, offset ) - + # Always increment offset, even if feature is not an interval and hence # not included in the index. offset += feature.raw_size index.write( open(out_fname, "w") ) - -if __name__ == "__main__": + +if __name__ == "__main__": main() - \ No newline at end of file diff --git a/lib/galaxy/datatypes/converters/interval_to_bed_converter.py b/lib/galaxy/datatypes/converters/interval_to_bed_converter.py index f39c6be2b53..cfa48cedd28 100644 --- a/lib/galaxy/datatypes/converters/interval_to_bed_converter.py +++ b/lib/galaxy/datatypes/converters/interval_to_bed_converter.py @@ -1,62 +1,62 @@ -#!/usr/bin/env python -#Dan Blankenberg - -import sys -from galaxy import eggs -import pkg_resources; pkg_resources.require( "bx-python" ) -import bx.intervals.io - -assert sys.version_info[:2] >= ( 2, 4 ) - -def stop_err( msg ): - sys.stderr.write( msg ) - sys.exit() - -def __main__(): - output_name = sys.argv[1] - input_name = sys.argv[2] - try: - chromCol = int( sys.argv[3] ) - 1 - except: - stop_err( "'%s' is an invalid chrom column, correct the column settings before attempting to convert the data format." % str( sys.argv[3] ) ) - try: - startCol = int( sys.argv[4] ) - 1 - except: - stop_err( "'%s' is an invalid start column, correct the column settings before attempting to convert the data format." % str( sys.argv[4] ) ) - try: - endCol = int( sys.argv[5] ) - 1 - except: - stop_err( "'%s' is an invalid end column, correct the column settings before attempting to convert the data format." % str( sys.argv[5] ) ) - try: - strandCol = int( sys.argv[6] ) - 1 - except: - strandCol = -1 - try: - nameCol = int( sys.argv[7] ) - 1 - except: - nameCol = -1 - skipped_lines = 0 - first_skipped_line = 0 - out = open( output_name,'w' ) - count = 0 - for count, region in enumerate( bx.intervals.io.NiceReaderWrapper( open( input_name, 'r' ), chrom_col=chromCol, start_col=startCol, end_col=endCol, strand_col=strandCol, fix_strand=True, return_header=False, return_comments=False ) ): - try: - if nameCol >= 0: - name = region.fields[nameCol] - else: - raise IndexError - except: - name = "region_%i" % count - try: - - out.write( "%s\t%i\t%i\t%s\t%i\t%s\n" % ( region.chrom, region.start, region.end, name, 0, region.strand ) ) - except: - skipped_lines += 1 - if not first_skipped_line: - first_skipped_line = count + 1 - out.close() - print "%i regions converted to BED." % ( count + 1 - skipped_lines ) - if skipped_lines > 0: - print "Skipped %d blank or invalid lines starting with line # %d." % ( skipped_lines, first_skipped_line ) - -if __name__ == "__main__": __main__() +#!/usr/bin/env python +#Dan Blankenberg + +import sys +from galaxy import eggs +import pkg_resources; pkg_resources.require( "bx-python" ) +import bx.intervals.io + +assert sys.version_info[:2] >= ( 2, 4 ) + +def stop_err( msg ): + sys.stderr.write( msg ) + sys.exit() + +def __main__(): + output_name = sys.argv[1] + input_name = sys.argv[2] + try: + chromCol = int( sys.argv[3] ) - 1 + except: + stop_err( "'%s' is an invalid chrom column, correct the column settings before attempting to convert the data format." % str( sys.argv[3] ) ) + try: + startCol = int( sys.argv[4] ) - 1 + except: + stop_err( "'%s' is an invalid start column, correct the column settings before attempting to convert the data format." % str( sys.argv[4] ) ) + try: + endCol = int( sys.argv[5] ) - 1 + except: + stop_err( "'%s' is an invalid end column, correct the column settings before attempting to convert the data format." % str( sys.argv[5] ) ) + try: + strandCol = int( sys.argv[6] ) - 1 + except: + strandCol = -1 + try: + nameCol = int( sys.argv[7] ) - 1 + except: + nameCol = -1 + skipped_lines = 0 + first_skipped_line = 0 + out = open( output_name,'w' ) + count = 0 + for count, region in enumerate( bx.intervals.io.NiceReaderWrapper( open( input_name, 'r' ), chrom_col=chromCol, start_col=startCol, end_col=endCol, strand_col=strandCol, fix_strand=True, return_header=False, return_comments=False ) ): + try: + if nameCol >= 0: + name = region.fields[nameCol] + else: + raise IndexError + except: + name = "region_%i" % count + try: + + out.write( "%s\t%i\t%i\t%s\t%i\t%s\n" % ( region.chrom, region.start, region.end, name, 0, region.strand ) ) + except: + skipped_lines += 1 + if not first_skipped_line: + first_skipped_line = count + 1 + out.close() + print "%i regions converted to BED." % ( count + 1 - skipped_lines ) + if skipped_lines > 0: + print "Skipped %d blank or invalid lines starting with line # %d." % ( skipped_lines, first_skipped_line ) + +if __name__ == "__main__": __main__() diff --git a/lib/galaxy/datatypes/converters/interval_to_bedstrict_converter.py b/lib/galaxy/datatypes/converters/interval_to_bedstrict_converter.py index 804378eb019..2fb612c4d66 100644 --- a/lib/galaxy/datatypes/converters/interval_to_bedstrict_converter.py +++ b/lib/galaxy/datatypes/converters/interval_to_bedstrict_converter.py @@ -64,7 +64,7 @@ def __main__(): force_num_columns = int( sys.argv[9] ) except: force_num_columns = None - + skipped_lines = 0 first_skipped_line = None out = open( output_name,'w' ) @@ -88,32 +88,32 @@ def __main__(): break #name (fields[3]) can be anything, no verification needed if len( fields ) > 4: - float( fields[4] ) #score - A score between 0 and 1000. If the track line useScore attribute is set to 1 for this annotation data set, the score value will determine the level of gray in which this feature is displayed (higher numbers = darker gray). + float( fields[4] ) #score - A score between 0 and 1000. If the track line useScore attribute is set to 1 for this annotation data set, the score value will determine the level of gray in which this feature is displayed (higher numbers = darker gray). if len( fields ) > 5: - assert fields[5] in [ '+', '-' ], 'Invalid strand' #strand - Defines the strand - either '+' or '-'. + assert fields[5] in [ '+', '-' ], 'Invalid strand' #strand - Defines the strand - either '+' or '-'. if len( fields ) > 6: - int( fields[6] ) #thickStart - The starting position at which the feature is drawn thickly (for example, the start codon in gene displays). + int( fields[6] ) #thickStart - The starting position at which the feature is drawn thickly (for example, the start codon in gene displays). if len( fields ) > 7: - int( fields[7] ) #thickEnd - The ending position at which the feature is drawn thickly (for example, the stop codon in gene displays). - if len( fields ) > 8: + int( fields[7] ) #thickEnd - The ending position at which the feature is drawn thickly (for example, the stop codon in gene displays). + if len( fields ) > 8: if fields[8] != '0': #itemRgb - An RGB value of the form R,G,B (e.g. 255,0,0). If the track line itemRgb attribute is set to "On", this RBG value will determine the display color of the data contained in this BED line. NOTE: It is recommended that a simple color scheme (eight colors or less) be used with this attribute to avoid overwhelming the color resources of the Genome Browser and your Internet browser. fields2 = fields[8].split( ',' ) assert len( fields2 ) == 3, 'RGB value must be 0 or have length of 3' for field in fields2: int( field ) #rgb values are integers if len( fields ) > 9: - int( fields[9] ) #blockCount - The number of blocks (exons) in the BED line. + int( fields[9] ) #blockCount - The number of blocks (exons) in the BED line. if len( fields ) > 10: - if fields[10] != ',': #blockSizes - A comma-separated list of the block sizes. The number of items in this list should correspond to blockCount. + if fields[10] != ',': #blockSizes - A comma-separated list of the block sizes. The number of items in this list should correspond to blockCount. fields2 = fields[10].rstrip( "," ).split( "," ) #remove trailing comma and split on comma - for field in fields2: + for field in fields2: int( field ) if len( fields ) > 11: - if fields[11] != ',': #blockStarts - A comma-separated list of block starts. All of the blockStart positions should be calculated relative to chromStart. The number of items in this list should correspond to blockCount. + if fields[11] != ',': #blockStarts - A comma-separated list of block starts. All of the blockStart positions should be calculated relative to chromStart. The number of items in this list should correspond to blockCount. fields2 = fields[11].rstrip( "," ).split( "," ) #remove trailing comma and split on comma for field in fields2: int( field ) - except: + except: strict_bed = False break if force_num_columns is not None and len( fields ) != force_num_columns: @@ -122,7 +122,7 @@ def __main__(): else: strict_bed = False out.close() - + if not strict_bed: skipped_lines = 0 first_skipped_line = None diff --git a/lib/galaxy/datatypes/converters/interval_to_coverage.py b/lib/galaxy/datatypes/converters/interval_to_coverage.py index a73d25a4ddf..07093be0adc 100644 --- a/lib/galaxy/datatypes/converters/interval_to_coverage.py +++ b/lib/galaxy/datatypes/converters/interval_to_coverage.py @@ -50,12 +50,12 @@ def main( interval, coverage ): forward = forward_covs[partition] reverse = reverse_covs[partition] if forward+reverse > 0: - coverage.write(chrom=chrom, position=xrange(partitions[partition],partitions[partition+1]), + coverage.write(chrom=chrom, position=xrange(partitions[partition],partitions[partition+1]), forward=forward, reverse=reverse) partitions = [] forward_covs = [] reverse_covs = [] - + start_index = bisect(partitions, record.start) forward = int(record.strand == "+") reverse = int(record.strand == "-") @@ -74,43 +74,43 @@ def main( interval, coverage ): partitions.insert(end_index, record.end) forward_covs.insert(end_index, forward_covs[end_index-1] - forward ) reverse_covs.insert(end_index, reverse_covs[end_index-1] - reverse ) - + if partitions: for partition in xrange(0, start_index): forward = forward_covs[partition] reverse = reverse_covs[partition] if forward+reverse > 0: - coverage.write(chrom=chrom, position=xrange(partitions[partition],partitions[partition+1]), + coverage.write(chrom=chrom, position=xrange(partitions[partition],partitions[partition+1]), forward=forward, reverse=reverse) partitions = partitions[start_index:] forward_covs = forward_covs[start_index:] reverse_covs = reverse_covs[start_index:] - + lastchrom = chrom - + # Finish the last chromosome if partitions: for partition in xrange(0, len(partitions)-1): forward = forward_covs[partition] reverse = reverse_covs[partition] if forward+reverse > 0: - coverage.write(chrom=chrom, position=xrange(partitions[partition],partitions[partition+1]), + coverage.write(chrom=chrom, position=xrange(partitions[partition],partitions[partition+1]), forward=forward, reverse=reverse) - + class CoverageWriter( object ): def __init__( self, out_stream=None, chromCol=0, positionCol=1, forwardCol=2, reverseCol=3 ): self.out_stream = out_stream self.reverseCol = reverseCol self.nlines = 0 - positions = {str(chromCol):'%(chrom)s', - str(positionCol):'%(position)d', - str(forwardCol):'%(forward)d', + positions = {str(chromCol):'%(chrom)s', + str(positionCol):'%(position)d', + str(forwardCol):'%(forward)d', str(reverseCol):'%(reverse)d'} - if reverseCol < 0: + if reverseCol < 0: self.template = "%(0)s\t%(1)s\t%(2)s\n" % positions else: self.template = "%(0)s\t%(1)s\t%(2)s\t%(3)s\n" % positions - + def write(self, **kwargs ): if self.reverseCol < 0: kwargs['forward'] += kwargs['reverse'] posgen = kwargs['position'] @@ -121,12 +121,12 @@ class CoverageWriter( object ): def close(self): self.out_stream.flush() self.out_stream.close() - + if __name__ == "__main__": options, args = doc_optparse.parse( __doc__ ) try: chr_col_1, start_col_1, end_col_1, strand_col_1 = [int(x)-1 for x in options.cols1.split(',')] - chr_col_2, position_col_2, forward_col_2, reverse_col_2 = [int(x)-1 for x in options.cols2.split(',')] + chr_col_2, position_col_2, forward_col_2, reverse_col_2 = [int(x)-1 for x in options.cols2.split(',')] in_fname, out_fname = args except: doc_optparse.exception() @@ -141,7 +141,7 @@ if __name__ == "__main__": chromCol = chr_col_2, positionCol = position_col_2, forwardCol = forward_col_2, reverseCol = reverse_col_2, ) temp_file.seek(0) - interval = io.NiceReaderWrapper( temp_file, + interval = io.NiceReaderWrapper( temp_file, chrom_col=chr_col_1, start_col=start_col_1, end_col=end_col_1, diff --git a/lib/galaxy/datatypes/converters/interval_to_fli.py b/lib/galaxy/datatypes/converters/interval_to_fli.py index 8448ee62d29..22b429d1945 100644 --- a/lib/galaxy/datatypes/converters/interval_to_fli.py +++ b/lib/galaxy/datatypes/converters/interval_to_fli.py @@ -78,13 +78,13 @@ def main(): if len( fields ) < 4: continue - # Process line + # Process line name_loc_dict[ fields[3] ] = { 'contig': fields[0], 'start': int( fields[1] ), 'end': int ( fields[2] ) } - + # Create sorted list of entries. out = open( out_fname, 'w' ) max_len = 0 @@ -95,7 +95,7 @@ def main(): if len( entry ) > max_len: max_len = len( entry ) entries.append( entry ) - + # Write padded entries. out.write( str( max_len + 1 ).ljust( max_len ) + '\n' ) for entry in entries: diff --git a/lib/galaxy/datatypes/converters/interval_to_tabix_converter.py b/lib/galaxy/datatypes/converters/interval_to_tabix_converter.py index 39705f44004..13fb2e53c73 100644 --- a/lib/galaxy/datatypes/converters/interval_to_tabix_converter.py +++ b/lib/galaxy/datatypes/converters/interval_to_tabix_converter.py @@ -20,20 +20,19 @@ def main(): parser.add_option( '-P', '--preset', dest='preset' ) (options, args) = parser.parse_args() input_fname, index_fname, out_fname = args - + # Create index. if options.preset: # Preset type. - ctabix.tabix_index(filename=index_fname, preset=options.preset, keep_original=True, + ctabix.tabix_index(filename=index_fname, preset=options.preset, keep_original=True, already_compressed=True, index_filename=out_fname) else: # For interval files; column indices are 0-based. - ctabix.tabix_index(filename=index_fname, seq_col=(options.chrom_col - 1), - start_col=(options.start_col - 1), end_col=(options.end_col - 1), + ctabix.tabix_index(filename=index_fname, seq_col=(options.chrom_col - 1), + start_col=(options.start_col - 1), end_col=(options.end_col - 1), keep_original=True, already_compressed=True, index_filename=out_fname) if os.path.getsize(index_fname) == 0: sys.stderr.write("The converted tabix index file is empty, meaning the input data is invalid.") - -if __name__ == "__main__": + +if __name__ == "__main__": main() - \ No newline at end of file diff --git a/lib/galaxy/datatypes/converters/lped_to_fped_converter.py b/lib/galaxy/datatypes/converters/lped_to_fped_converter.py index 8e595a0955c..3ec59727b68 100644 --- a/lib/galaxy/datatypes/converters/lped_to_fped_converter.py +++ b/lib/galaxy/datatypes/converters/lped_to_fped_converter.py @@ -1,110 +1,110 @@ -# for rgenetics - lped to fbat -# recode to numeric fbat version -# much slower so best to always -# use numeric alleles internally - -import sys,os,time - - -prog = os.path.split(sys.argv[0])[-1] -myversion = 'Oct 10 2009' - -galhtmlprefix = """ - - -
- - -