Beispiel #1
0
def create_reader(options, parser, counter_magnitude="M"):
    interleaved = bool(options.interleaved_input)
    input1 = options.interleaved_input if interleaved else options.input1
    input2 = qualfile = None
    if options.paired and not interleaved:
        input2 = options.input2
    else:
        qualfile = options.input2
    
    try:
        reader = open_reader(input1, file2=input2, qualfile=qualfile,
            colorspace=options.colorspace, fileformat=options.format,
            interleaved=interleaved, single_input_read=options.single_input_read)
    except (UnknownFileType, IOError) as e:
        parser.error(e)
    
    qualities = reader.delivers_qualities
    
    # Wrap reader in subsampler
    if options.subsample:
        reader = subsample(reader, options.subsample)
    
    # Wrap reader in batch iterator
    batch_size = options.batch_size or 1000
    reader = BatchIterator(reader, batch_size, options.max_reads)
    
    # Wrap iterator in progress bar
    if options.progress:
        from .progress import create_progress_reader
        reader = create_progress_reader(
            reader, options.progress, batch_size, options.max_reads,
            counter_magnitude)
    
    return (reader, (input1, input2), qualities, qualfile is not None)
Beispiel #2
0
def create_reader(options, parser, counter_magnitude="M"):
    interleaved = bool(options.interleaved_input)
    input1 = options.interleaved_input if interleaved else options.input1
    input2 = qualfile = None
    if options.paired and not interleaved:
        input2 = options.input2
    else:
        qualfile = options.input2
    
    try:
        reader = open_reader(input1, file2=input2, qualfile=qualfile,
            colorspace=options.colorspace, fileformat=options.format,
            interleaved=interleaved, single_input_read=options.single_input_read)
    except (UnknownFileType, IOError) as e:
        parser.error(e)
    
    qualities = reader.delivers_qualities
    
    # Wrap reader in subsampler
    if options.subsample:
        reader = subsample(reader, options.subsample)
    
    # Wrap reader in batch iterator
    batch_size = options.batch_size or 1000
    reader = BatchIterator(reader, batch_size, options.max_reads)
    
    # Wrap iterator in progress bar
    if options.progress:
        from .progress import create_progress_reader
        reader = create_progress_reader(
            reader, options.progress, batch_size, options.max_reads,
            counter_magnitude)
    
    return (reader, (input1, input2), qualities, qualfile is not None)
Beispiel #3
0
def main():
    parser = ArgumentParser()
    parser.add_argument("-a", "--aligner", choices=('adapter', 'insert'))
    parser.add_argument("-m", "--mode", choices=('time','run'), default='run')
    parser.add_argument("-o", "--outfile")
    parser.add_argument("-1", "--fastq1", default='test1.fq')
    parser.add_argument("-2", "--fastq2", default='test2.fq')
    parser.add_argument("-i", "--iters", default=10)
    args = parser.parse_args()
    
    aligner = create_adapter() if args.aligner == 'adapter' else create_insert()
    
    if args.mode == 'time':
        t = 0
        for i in range(args.iters):
            reader = open_reader(args.fastq1, args.fastq2)
            t += time_process(reader, aligner)
            reader.close()
        print("Average time: {}".format(t / args.iters))
    else:
        run_process(reader, aligner)
Beispiel #4
0
def main():
    parser = ArgumentParser()
    parser.add_argument("-a", "--aligner", choices=('adapter', 'insert'))
    parser.add_argument("-m", "--mode", choices=('time', 'run'), default='run')
    parser.add_argument("-o", "--outfile")
    parser.add_argument("-1", "--fastq1", default='test1.fq')
    parser.add_argument("-2", "--fastq2", default='test2.fq')
    parser.add_argument("-i", "--iters", default=10)
    args = parser.parse_args()

    aligner = create_adapter() if args.aligner == 'adapter' else create_insert(
    )

    if args.mode == 'time':
        t = 0
        for i in range(args.iters):
            reader = open_reader(args.fastq1, args.fastq2)
            t += time_process(reader, aligner)
            reader.close()
        print("Average time: {}".format(t / args.iters))
    else:
        run_process(reader, aligner)