def test_summary_not_demultiplexed_gzipped_no_header(self):
        artifact_type = 'SFF'
        filepaths = {'raw_sff': [join(dirname(__file__), 'test_data',
                                      'Fasting_Example.sff.gz')]}

        obs = _summary_not_demultiplexed(artifact_type, filepaths)
        exp = ["<h3>Fasting_Example.sff.gz (raw_sff)</h3>",
               "<b>MD5:</b>: 2b636ee4833270da41a39aa5fc0a1622</br>"]
        self.assertEqual(obs, exp)
    def test_summary_not_demultiplexed_not_gzipped_header(self):
        test_dir = mkdtemp()
        self._clean_up_files.append(test_dir)

        bcds_fp = join(test_dir, 'barcodes.fastq')
        with open(bcds_fp, 'w') as fh:
            fh.write(BARCODES)

        fwd_fp = join(test_dir, 'reads.fastq')
        with open(fwd_fp, 'w') as fh:
            fh.write(READS)

        artifact_type = 'FASTQ'
        filepaths = {'raw_forward_seqs': [fwd_fp],
                     'raw_barcodes': [bcds_fp]}

        obs = _summary_not_demultiplexed(artifact_type, filepaths)
        exp = [
            '<h3>barcodes.fastq (raw_barcodes)</h3>',
            '<b>MD5:</b>: d0478899bf5c6ba6019b596690e8c261</br>',
            '<p style="font-family:\'Courier New\', Courier, monospace;'
            'font-size:10;">@MISEQ03:123:000000000-A40KM:1:1101:14149:1572 '
            '1:N:0:TCCACAGGAGT\n<br/>TCCACAGGAGT\n<br/>+\n<br/>CCCCCCCCCFF\n'
            '<br/>@MISEQ03:123:000000000-A40KM:1:1101:14170:1596 1:N:0:'
            'TCCACAGGAGT\n<br/>TCCACAGGAGT\n<br/>+\n<br/>CCCCCCCCCCF\n<br/>@'
            'MISEQ03:123:000000000-A40KM:1:1101:14740:1607 1:N:0:TCCACAGGAGT\n'
            '<br/>TCCACAGGAGT\n</p><hr/>',
            '<h3>reads.fastq (raw_forward_seqs)</h3>',
            '<b>MD5:</b>: 97328e860ef506f7b029997b12bf9885</br>',
            '<p style="font-family:\'Courier New\', Courier, monospace;'
            'font-size:10;">@MISEQ03:123:000000000-A40KM:1:1101:14149:1572 '
            '1:N:0:TCCACAGGAGT\n<br/>GGGGGGTGCCAGCCGCCGCGGTAATACGGGGGGGGCAAGCG'
            'TTGTTCGGAATTACTGGGCGTAAAGGGCTCGTAGGCGGCCCACTAAGTCAGACGTGAAATCCCTC'
            'GGCTTAACCGGGGAACTGCGTCTGATACTGGATGGCTTGAGGTTGGGAGAGGGATGCGGAATTCC'
            'AGGTGTAGCGGTGAAATGCGTAGATATCTGGAGGAACACCGGTGGCGAAGGCGGCATCCTGGACC'
            'AATTCTGACGCTGAG\n<br/>+\n<br/>CCCCCCCCCFFFGGGGGGGGGGGGHHHHGGGGGFF'
            'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF-.;FFFFFFFFF9@EFFFF'
            'FFFFFFFFFFFFFFF9CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFECF'
            'FFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFFFFF;CDEA@FFFFF'
            'FFFFFFFFFFFFFFFFFFFFF\n<br/>@MISEQ03:123:000000000-A40KM:1:1101:1'
            '4170:1596 1:N:0:TCCACAGGAGT\n<br/>ATGGCGTGCCAGCAGCCGCGGTAATACGGAG'
            'GGGGCTAGCGTTGTTCGGAATTACTGGGCGTAAAGCGCACGTAGGCGGCTTTGTAAGTTAGAGGT'
            'GAAAGCCCGGGGCTCAACTCCGGAACTGCCTTTAAGACTGCATCGCTAGAATTGTGGAGAGGTGA'
            'GTGGAATTCCGAGTGTAGAGGTGAAATTCGTAGATATTCGGAAGAACACCAGTGGCGAAGGCGAC'
            'TCACTGGACACATATTGACGCTGAG\n<br/>+\n<br/>CCCCCCCCCCFFGGGGGGGGGGGGG'
            'HHHGGGGGGGGGHHHGGGGGHHGGGGGHHHHHHHHGGGGHHHGGGGGHHHGHGGGGGHHHHHHHH'
            'GHGHHHHHHGHHHHGGGGGGHHHHHHHGGGGGHHHHHHHHHGGFGGGGGGGGGGGGGGGGGGGGG'
            'GGGFGGFFFFFFFFFFFFFFFFFF0BFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFF'
            'FDFAFCFFFFFFFFFFFFFFFFFFBDFFFFF\n<br/>@MISEQ03:123:000000000-A40K'
            'M:1:1101:14740:1607 1:N:0:TCCACAGGAGT\n<br/>AGTGTGTGCCAGCAGCCGCGG'
            'TAATACGTAGGGTGCGAGCGTTAATCGGAATTACTGGGCGTAAAGCGTGCGCAGGCGGTTCGTTG'
            'TGTCTGCTGTGAAATCCCCGGGCTCAACCTGGGAATGGCAGTGGAAACTGGCGAGCTTGAGTGTG'
            'GCAGAGGGGGGGGGAATTCCGCGTGTAGCAGTGAAATGCGTAGAGATGCGGAGGAACACCGATGG'
            'CGAAGGCAACCCCCTGGGATAATATTTACGCTCAT\n</p><hr/>']
        self.assertItemsEqual(obs, exp)
    def test_summary_not_demultiplexed_gzipped_header(self):
        test_dir = mkdtemp()
        self._clean_up_files.append(test_dir)

        bcds_fp = join(test_dir, 'barcodes.fastq.gz')
        with GzipFile(bcds_fp, mode='w', mtime=1) as fh:
            fh.write(BARCODES)

        fwd_fp = join(test_dir, 'reads.fastq.gz')
        with GzipFile(fwd_fp, mode='w', mtime=1) as fh:
            fh.write(READS)

        artifact_type = 'FASTQ'
        filepaths = {'raw_forward_seqs': [fwd_fp],
                     'raw_barcodes': [bcds_fp]}

        obs = _summary_not_demultiplexed(artifact_type, filepaths)
        exp = [
            '<h3>barcodes.fastq.gz (raw_barcodes)</h3>',
            '<b>MD5:</b>: 1c6eefa11d8641a6f853b56801351e5a</br>',
            '<p style="font-family:\'Courier New\', Courier, monospace;'
            'font-size:10;">@MISEQ03:123:000000000-A40KM:1:1101:14149:1572 '
            '1:N:0:TCCACAGGAGT\n<br/>TCCACAGGAGT\n<br/>+\n<br/>CCCCCCCCCFF\n'
            '<br/>@MISEQ03:123:000000000-A40KM:1:1101:14170:1596 1:N:0:'
            'TCCACAGGAGT\n<br/>TCCACAGGAGT\n<br/>+\n<br/>CCCCCCCCCCF\n<br/>@'
            'MISEQ03:123:000000000-A40KM:1:1101:14740:1607 1:N:0:TCCACAGGAGT\n'
            '<br/>TCCACAGGAGT\n</p><hr/>',
            '<h3>reads.fastq.gz (raw_forward_seqs)</h3>',
            '<b>MD5:</b>: f3909bcab34565a5d4b88c300d40bbfc</br>',
            '<p style="font-family:\'Courier New\', Courier, monospace;'
            'font-size:10;">@MISEQ03:123:000000000-A40KM:1:1101:14149:1572 '
            '1:N:0:TCCACAGGAGT\n<br/>GGGGGGTGCCAGCCGCCGCGGTAATACGGGGGGGGCAAGCG'
            'TTGTTCGGAATTACTGGGCGTAAAGGGCTCGTAGGCGGCCCACTAAGTCAGACGTGAAATCCCTC'
            'GGCTTAACCGGGGAACTGCGTCTGATACTGGATGGCTTGAGGTTGGGAGAGGGATGCGGAATTCC'
            'AGGTGTAGCGGTGAAATGCGTAGATATCTGGAGGAACACCGGTGGCGAAGGCGGCATCCTGGACC'
            'AATTCTGACGCTGAG\n<br/>+\n<br/>CCCCCCCCCFFFGGGGGGGGGGGGHHHHGGGGGFF'
            'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF-.;FFFFFFFFF9@EFFFF'
            'FFFFFFFFFFFFFFF9CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFECF'
            'FFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFFFFF;CDEA@FFFFF'
            'FFFFFFFFFFFFFFFFFFFFF\n<br/>@MISEQ03:123:000000000-A40KM:1:1101:1'
            '4170:1596 1:N:0:TCCACAGGAGT\n<br/>ATGGCGTGCCAGCAGCCGCGGTAATACGGAG'
            'GGGGCTAGCGTTGTTCGGAATTACTGGGCGTAAAGCGCACGTAGGCGGCTTTGTAAGTTAGAGGT'
            'GAAAGCCCGGGGCTCAACTCCGGAACTGCCTTTAAGACTGCATCGCTAGAATTGTGGAGAGGTGA'
            'GTGGAATTCCGAGTGTAGAGGTGAAATTCGTAGATATTCGGAAGAACACCAGTGGCGAAGGCGAC'
            'TCACTGGACACATATTGACGCTGAG\n<br/>+\n<br/>CCCCCCCCCCFFGGGGGGGGGGGGG'
            'HHHGGGGGGGGGHHHGGGGGHHGGGGGHHHHHHHHGGGGHHHGGGGGHHHGHGGGGGHHHHHHHH'
            'GHGHHHHHHGHHHHGGGGGGHHHHHHHGGGGGHHHHHHHHHGGFGGGGGGGGGGGGGGGGGGGGG'
            'GGGFGGFFFFFFFFFFFFFFFFFF0BFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFF'
            'FDFAFCFFFFFFFFFFFFFFFFFFBDFFFFF\n<br/>@MISEQ03:123:000000000-A40K'
            'M:1:1101:14740:1607 1:N:0:TCCACAGGAGT\n<br/>AGTGTGTGCCAGCAGCCGCGG'
            'TAATACGTAGGGTGCGAGCGTTAATCGGAATTACTGGGCGTAAAGCGTGCGCAGGCGGTTCGTTG'
            'TGTCTGCTGTGAAATCCCCGGGCTCAACCTGGGAATGGCAGTGGAAACTGGCGAGCTTGAGTGTG'
            'GCAGAGGGGGGGGGAATTCCGCGTGTAGCAGTGAAATGCGTAGAGATGCGGAGGAACACCGATGG'
            'CGAAGGCAACCCCCTGGGATAATATTTACGCTCAT\n</p><hr/>']
        self.assertItemsEqual(obs, exp)
    def test_summary_not_demultiplexed_empty(self):
        test_dir = mkdtemp()
        self._clean_up_files.append(test_dir)

        fwd_fp = join(test_dir, 'reads.fastq')
        open(fwd_fp, 'w', 0).close()

        artifact_type = 'per_sample_FASTQ'
        filepaths = {'preprocessed_fastq': [fwd_fp]}
        obs = _summary_not_demultiplexed(artifact_type, filepaths)
        exp = [
            '<h3>reads.fastq (preprocessed_fastq)</h3>',
            '<b>MD5:</b>: d41d8cd98f00b204e9800998ecf8427e</br>']
        self.assertItemsEqual(obs, exp)