def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)
    
    if opts.qual_score_window and not opts.qual_fnames:
        option_parser.error('To enable sliding window quality test (-w), '+\
        '.qual files must be included.')
  
    mapping_file = opts.map_fname
    fasta_files = set(opts.fasta_fnames.split(','))
    if opts.qual_fnames:
        qual_files = set(opts.qual_fnames.split(','))
    else:
        qual_files = set()

    for q in qual_files:
        if not q.endswith('qual'):
            stderr.write(
            "Qual file does not end with .qual: is it really a qual file?\n%s\n" 
            % q)

    for f in fasta_files:
        if not (f.endswith('fasta') or f.endswith('fna')):
            stderr.write(
            "Fasta file does not end with .fna: is it really a seq file?\n%s\n" 
            % f)
    
    preprocess(fasta_files, qual_files, mapping_file,
               barcode_type=opts.barcode_type,
               starting_ix = opts.start_index,
               min_seq_len = opts.min_seq_len,
               max_seq_len = opts.max_seq_len, 
               min_qual_score=opts.min_qual_score,
               keep_barcode=opts.keep_barcode,
               keep_primer=opts.keep_primer,
               max_ambig=opts.max_ambig,
               max_primer_mm=opts.max_primer_mm,
               trim_seq_len=opts.trim_seq_len,
               dir_prefix=opts.dir_prefix,
               max_bc_errors = opts.max_bc_errors,
               max_homopolymer = opts.max_homopolymer,
               retain_unassigned_reads = opts.retain_unassigned_reads,
               #remove_unassigned = opts.remove_unassigned,
               attempt_bc_correction = not opts.disable_bc_correction,
               qual_score_window = opts.qual_score_window,
               disable_primer_check = opts.disable_primers,
               reverse_primers = opts.reverse_primers,
               record_qual_scores = opts.record_qual_scores,
               discard_bad_windows = opts.discard_bad_windows,
               median_length_filtering = opts.median_length_filtering,
               added_demultiplex_field = opts.added_demultiplex_field)
Beispiel #2
0
def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)

    if opts.qual_score_window and not opts.qual_fnames:
        option_parser.error('To enable sliding window quality test (-w), ' +
                            '.qual files must be included.')

    if opts.record_qual_scores and not opts.qual_fnames:
        option_parser.error('To enable recording of truncated quality ' +
                            'scores, one must supply quality score files.')

    min_qual_score = opts.min_qual_score
    if min_qual_score is None:
        min_qual_score = min_qual_score_default
    else:
        if not opts.qual_fnames:
            option_parser.error('To specify a minimum quality score for '
                                'reads, one must supply quality score files.')

    mapping_file = opts.map_fname

    try:
        m = open(mapping_file, "U")
    except IOError:
        raise IOError('Unable to open mapping file %s ' % mapping_file +
                      'Please check filepath and read permissions.')
    fasta_files = set(opts.fasta_fnames)
    if opts.qual_fnames:
        qual_files = set(opts.qual_fnames)
    else:
        qual_files = set()

    for q in qual_files:
        try:
            test_qual_file = open(q, "U")
            test_qual_file.close()
        except IOError:
            raise IOError('Unable to open file %s ' % q + ' please check ' +
                          'filepath and read permissions.')

    for f in fasta_files:
        try:
            test_fasta_file = open(f, "U")
            test_fasta_file.close()
        except IOError:
            raise IOError('Unable to open file %s ' % f + ' please check ' +
                          'filepath and read permissions.')

    preprocess(
        fasta_files,
        qual_files,
        mapping_file,
        barcode_type=opts.barcode_type,
        starting_ix=opts.start_index,
        min_seq_len=opts.min_seq_len,
        max_seq_len=opts.max_seq_len,
        min_qual_score=min_qual_score,
        keep_barcode=opts.keep_barcode,
        keep_primer=opts.keep_primer,
        max_ambig=opts.max_ambig,
        max_primer_mm=opts.max_primer_mm,
        trim_seq_len=opts.trim_seq_len,
        dir_prefix=opts.dir_prefix,
        max_bc_errors=opts.max_bc_errors,
        max_homopolymer=opts.max_homopolymer,
        retain_unassigned_reads=opts.retain_unassigned_reads,
        #remove_unassigned = opts.remove_unassigned,
        attempt_bc_correction=not opts.disable_bc_correction,
        qual_score_window=opts.qual_score_window,
        disable_primer_check=opts.disable_primers,
        reverse_primers=opts.reverse_primers,
        reverse_primer_mismatches=opts.reverse_primer_mismatches,
        record_qual_scores=opts.record_qual_scores,
        discard_bad_windows=opts.discard_bad_windows,
        median_length_filtering=opts.median_length_filtering,
        added_demultiplex_field=opts.added_demultiplex_field,
        truncate_ambi_bases=opts.truncate_ambi_bases)
Beispiel #3
0
def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)
    
    if opts.qual_score_window and not opts.qual_fnames:
        option_parser.error('To enable sliding window quality test (-w), '+\
        '.qual files must be included.')
        
    if opts.record_qual_scores and not opts.qual_fnames:
        option_parser.error('To enable recording of truncated quality '+\
         'scores, one must supply quality score files.')
  
    mapping_file = opts.map_fname
    
    try:
        m = open(mapping_file, "U")
    except IOError:
        raise IOError,('Unable to open mapping file %s ' % mapping_file +\
         'Please check filepath and read permissions.')
    fasta_files = set(opts.fasta_fnames)
    if opts.qual_fnames:
        qual_files = set(opts.qual_fnames)
    else:
        qual_files = set()

    for q in qual_files:
        try:
            test_qual_file = open(q, "U")
            test_qual_file.close()
        except IOError:
            raise IOError,('Unable to open file %s ' % q +' please check '+\
             'filepath and read permissions.')
        if not q.endswith('qual'):
            stderr.write(
            "Qual file does not end with .qual: is it really a qual file?\n%s\n" 
            % q)

    for f in fasta_files:
        try:
            test_fasta_file = open(f, "U")
            test_fasta_file.close()
        except IOError:
            raise IOError,('Unable to open file %s ' % f +' please check '+\
             'filepath and read permissions.')
        if not (f.endswith('fasta') or f.endswith('fna')):
            stderr.write(
            "Fasta file does not end with .fna: is it really a seq file?\n%s\n" 
            % f)
    
    preprocess(fasta_files, qual_files, mapping_file,
               barcode_type=opts.barcode_type,
               starting_ix = opts.start_index,
               min_seq_len = opts.min_seq_len,
               max_seq_len = opts.max_seq_len, 
               min_qual_score=opts.min_qual_score,
               keep_barcode=opts.keep_barcode,
               keep_primer=opts.keep_primer,
               max_ambig=opts.max_ambig,
               max_primer_mm=opts.max_primer_mm,
               trim_seq_len=opts.trim_seq_len,
               dir_prefix=opts.dir_prefix,
               max_bc_errors = opts.max_bc_errors,
               max_homopolymer = opts.max_homopolymer,
               retain_unassigned_reads = opts.retain_unassigned_reads,
               #remove_unassigned = opts.remove_unassigned,
               attempt_bc_correction = not opts.disable_bc_correction,
               qual_score_window = opts.qual_score_window,
               disable_primer_check = opts.disable_primers,
               reverse_primers = opts.reverse_primers,
               reverse_primer_mismatches = opts.reverse_primer_mismatches,
               record_qual_scores = opts.record_qual_scores,
               discard_bad_windows = opts.discard_bad_windows,
               median_length_filtering = opts.median_length_filtering,
               added_demultiplex_field = opts.added_demultiplex_field,
               truncate_ambi_bases = opts.truncate_ambi_bases)