Exemple #1
0
        else:
            bar_pattern_non_quality_counts += 1
    else:
        non_bar_pattern_counts += 1

print('The total counts of reads is ' + str(total_counts))
print('The barcode pattern matching reads is ' + str(bar_pattern_counts))
print('The non barcode pattern matching reads is ' +
      str(non_bar_pattern_counts))
print('The barcode pattern matching and quality reads is ' +
      str(bar_pattern_quality_counts))
print('The barcode pattern matching and non quality reads is ' +
      str(bar_pattern_non_quality_counts))
print(
    'The barcode pattern matching, quality, and multitag matching reads is ' +
    str(bar_pattern_quality_multitag_counts))

#Close the files
for i in multitag:
    vars()[i + '_multitag'].close()
    vars()[i + '_lintag1'].close()
    vars()[i + '_lintag2'].close()

f_file.close()
r_file.close()

# run bartender to cluster the barcodes
#for i in multitag:
#    os.system("bartender_single_com -f " + i + "_lintag1_umi.txt -c 2 -t 8 -d 2 -o " + i + "_bartender_lintag1" )
#    os.system("bartender_single_com -f " + i + "_lintag2_umi.txt -c 2 -t 8 -d 2 -o " + i + "_bartender_lintag2")
Exemple #2
0
                             break
                     if not found:
                         with gzip.open(
                                 output_dir + 'discarded.fq.gz',
                                 'at') as out_handle:
                             [
                                 out_handle.write(field + '\n')
                                 for read in g[bc] for field in read
                             ]
                         global_counter['discarded'] += len(g[bc])
                         local_counter['discarded'] += len(g[bc])
             if verbose:
                 print(
                     os.path.basename(input_file) + ':',
                     'processed', processed, 'reads')
         file_iterator.close()
     out_stats = re.sub('(fq|fastq).*$', 'stats.txt',
                        os.path.basename(input_file))
     with open(output_dir + out_stats, 'wt') as out_handle:
         for key in barcode_files.keys():
             out_handle.write('\t'.join([
                 'Barcode', key,
                 str(local_counter[key] - 1),
                 str((local_counter[key] - 1) / processed)
             ]) + '\n')
         out_handle.write('\t'.join([
             'Barcode', 'Discarded',
             str(local_counter['discarded'] - 1),
             str((local_counter['discarded'] - 1) / processed)
         ]) + '\n')
 if len(inFile) > 1: