def main(): # Read options, args. parser = optparse.OptionParser() parser.add_option('-c', '--chr-col', type='int', dest='chrom_col') parser.add_option('-s', '--start-col', type='int', dest='start_col') parser.add_option('-e', '--end-col', type='int', dest='end_col') 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, 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), 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." )
def main(): # Read options, args. usage = "Usage: %prog [options] tabular_input_file bgzip_output_file" parser = optparse.OptionParser(usage = usage) parser.add_option( '-c', '--chr-col', type='int', default=0, dest='chrom_col' ) parser.add_option( '-s', '--start-col', type='int', default=1, dest='start_col' ) parser.add_option( '-e', '--end-col', type='int', default=1, dest='end_col' ) (options, args) = parser.parse_args() if len(args) != 2: parser.print_usage() exit(1) input_fname, output_fname = args output_dir = os.path.dirname(output_fname) if not os.path.exists(output_dir): os.makedirs(output_dir) ctabix.tabix_compress(input_fname, output_fname, force=True) # Column indices are 0-based. ctabix.tabix_index(output_fname, seq_col=options.chrom_col,start_col=options.start_col,end_col=options.end_col)
def main(): # Read options, args. parser = optparse.OptionParser() parser.add_option( '-c', '--chr-col', type='int', dest='chrom_col' ) parser.add_option( '-s', '--start-col', type='int', dest='start_col' ) parser.add_option( '-e', '--end-col', type='int', dest='end_col' ) 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, 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), 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.")