Пример #1
0
 def test_qual_02(self):
     # test quality filtering with reduced threshold
     with Capturing() as output:
         main(
             [barcodes_qual, '-f', barcodes_qual, '--qual-filter', '-p', '2'])
     desc, seqs, __, quals = list(zip(*grouper(output, 4)))
     self.assertEqual(len(seqs), 5)
Пример #2
0
 def test_02(self):
     # filter barcode file using itself; get back only the most common
     # barcode
     with Capturing() as output:
         main([barcodes, '-f', barcodes, '--match-filter'])
     desc, seqs, __, quals = list(zip(*grouper(output, 4)))
     self.assertSetEqual(set(seqs), {most_common})
Пример #3
0
    def test_count(self):
        outdir = mkoutdir(self)
        read_counts = path.join(outdir, 'counts.csv')
        main([barcodes, '-f', barcodes,
              '--qual-filter',
              '-o', path.join(outdir, 'filtered.fastq'),
              '--read-counts', read_counts])

        with open(read_counts) as f:
            reader = csv.reader(f)
            fname, input, output = next(reader)
        self.assertEqual(input, '15000')
        self.assertEqual(output, '14729')
Пример #4
0
    def test_empty(self):
        # test filtering of empty fastq
        # with Capturing() as output:

        outdir = mkoutdir(self)
        read_counts = path.join(outdir, 'counts.csv')
        main([empty, '-f', empty,
              '-o', path.join(outdir, 'filtered.fastq'),
              '--read-counts', read_counts])

        with open(read_counts) as f:
            reader = csv.reader(f)
            fname, input, output = next(reader)
        self.assertEqual(input, '0')
        self.assertEqual(output, '0')
Пример #5
0
 def test_04(self):
     # --invert option removes all instances of the most common bc
     with Capturing() as output:
         main([barcodes, '-f', barcodes, '--invert', '--match-filter'])
     desc, seqs, __, quals = list(zip(*grouper(output, 4)))
     self.assertNotIn(most_common, set(seqs))
Пример #6
0
 def test_03(self):
     # --head returns the specified number of records
     with Capturing() as output:
         main([barcodes, '-f', barcodes, '--head', '10'])
     desc, seqs, __, quals = list(zip(*grouper(output, 4)))
     self.assertEqual(len(seqs), 10)
Пример #7
0
 def test_01(self):
     with Capturing() as output:
         # because main() is called in the same global context in
         # each test, '-q' silences logging for all invocations.
         main([barcodes, '-c', '-q'])
     self.assertEqual(output[0].split('\t')[0], most_common)
Пример #8
0
 def test_qual_dual(self):
     # test quality filtering with defaults
     with Capturing() as output:
         main([dual_qual1, dual_qual2, '-f', dual_qual1, '--qual-filter'])
     desc, seqs, __, quals = list(zip(*grouper(output, 4)))
     self.assertEqual(len(seqs), 5)
Пример #9
0
 def test_05(self):
     # test warning when recovery is below --min-pct-assignment
     with Capturing() as output:
         main([barcodes, '-f', barcodes, '--min-pct-assignment', '100'])
Пример #10
0
 def test_02(self):
     # filter barcode file using itself; get back only the most common barcode
     with Capturing() as output:
         main([dual1, dual2, '-f', dual1])
     desc, seqs, __, quals = zip(*grouper(output, 4))
     self.assertSetEqual(set(seqs), {most_common_dual.split('+')[0]})
Пример #11
0
#!/usr/bin/env python

import sys
from barcodecop.barcodecop import main

if __name__ == '__main__':
    sys.exit(main(sys.argv[1:]))