def test_phred_score_out_of_range(self): barcodes = self.barcodes[:3] sequences = [('@s1/1 abc/1', 'GGG', '+', 'jjj'), ('@s2/1 abc/1', 'CCC', '+', 'iii'), ('@s3/1 abc/1', 'AAA', '+', 'hhh')] bsi = BarcodeSequenceFastqIterator(barcodes, sequences) barcode_map = pd.Series(['AAAA', 'AACC', 'TTAA'], name='bc', index=pd.Index( ['sample1', 'sample2', 'sample3'], name='id')) barcode_map = qiime2.CategoricalMetadataColumn(barcode_map) demux_data = emp_single(bsi, barcode_map) with tempfile.TemporaryDirectory() as output_dir: result = summarize(output_dir, _PlotQualView(demux_data, paired=False), n=50) self.assertTrue(result is None) plot_fp = os.path.join(output_dir, 'quality-plot.html') with open(plot_fp, 'r') as fh: html = fh.read() self.assertIn('<strong>Danger:</strong>', html)
def test_paired_end(self): barcodes = self.barcodes[:3] forward = self.sequences[:3] reverse = [('@s1/1 abc/1', 'CCC', '+', 'YYY'), ('@s2/1 abc/1', 'GGG', '+', 'PPP'), ('@s3/1 abc/1', 'TTT', '+', 'PPP')] bpsi = BarcodePairedSequenceFastqIterator(barcodes, forward, reverse) barcode_map = pd.Series(['AAAA', 'AACC', 'TTAA'], name='bc', index=pd.Index( ['sample1', 'sample2', 'sample3'], name='id')) barcode_map = qiime2.CategoricalMetadataColumn(barcode_map) demux_data = emp_paired(bpsi, barcode_map) with tempfile.TemporaryDirectory() as output_dir: result = summarize(output_dir, _PlotQualView(demux_data, paired=True), n=2) self.assertTrue(result is None) plot_fp = os.path.join(output_dir, 'quality-plot.html') with open(plot_fp, 'r') as fh: html = fh.read() self.assertIn('<h5 class="text-center">Forward Reads</h5>', html) self.assertIn('<h5 class="text-center">Reverse Reads</h5>', html)
def test_single_sample(self): bsi = BarcodeSequenceFastqIterator(self.barcodes[:1], self.sequences[:1]) barcode_map = pd.Series(['AAAA'], name='bc', index=pd.Index(['sample1'], name='id')) barcode_map = qiime2.CategoricalMetadataColumn(barcode_map) demux_data = emp_single(bsi, barcode_map) # test that an index.html file is created and that it has size > 0 with tempfile.TemporaryDirectory() as output_dir: # TODO: Remove _PlotQualView wrapper result = summarize(output_dir, _PlotQualView(demux_data, paired=False), n=1) self.assertTrue(result is None) index_fp = os.path.join(output_dir, 'overview.html') self.assertTrue(os.path.exists(index_fp)) self.assertTrue(os.path.getsize(index_fp) > 0) csv_fp = os.path.join(output_dir, 'per-sample-fastq-counts.csv') self.assertTrue(os.path.exists(csv_fp)) self.assertTrue(os.path.getsize(csv_fp) > 0) pdf_fp = os.path.join(output_dir, 'demultiplex-summary.pdf') self.assertFalse(os.path.exists(pdf_fp)) png_fp = os.path.join(output_dir, 'demultiplex-summary.png') self.assertFalse(os.path.exists(png_fp)) with open(index_fp, 'r') as fh: html = fh.read() self.assertIn('<td>Minimum:</td><td>1</td>', html) self.assertIn('<td>Maximum:</td><td>1</td>', html)
def test_subsample_higher_than_seqs_count(self): barcodes = self.barcodes[:1] sequences = self.sequences[:1] bsi = BarcodeSequenceFastqIterator(barcodes, sequences) barcode_map = pd.Series(['AAAA'], index=['sample1']) barcode_map = qiime2.MetadataCategory(barcode_map) demux_data = emp_single(bsi, barcode_map) with tempfile.TemporaryDirectory() as output_dir: result = summarize(output_dir, _PlotQualView(demux_data, paired=False), n=50) self.assertTrue(result is None) plot_fp = os.path.join(output_dir, 'quality-plot.html') with open(plot_fp, 'r') as fh: html = fh.read() self.assertIn('<strong>Warning:</strong>', html)
def test_single_sample_multiple_files(self): # Note, this case came up on the QIIME 2 Forum, due to a user running # `summarize` with demuxed sequences that all had the same Sample ID # in the internal MANIFEST file. With versions of seaborn greater than # 0.8.0 this is no longer a problem, but on prior versions, the user # would see the following error: # TypeError: len() of unsized object files = [ 'sample1_S0_L001_R1_001.fastq.gz', 'sample2_S0_L001_R1_001.fastq.gz', 'sample3_S0_L001_R1_001.fastq.gz', 'MANIFEST', 'metadata.yml' ] for f in files: shutil.copy( self.get_data_path('single_sample_multiple_files/%s' % f), self.temp_dir.name) demux_data = SingleLanePerSampleSingleEndFastqDirFmt( self.temp_dir.name, mode='r') with tempfile.TemporaryDirectory() as output_dir: # TODO: Remove _PlotQualView wrapper result = summarize(output_dir, _PlotQualView(demux_data, paired=False), n=1) self.assertTrue(result is None) index_fp = os.path.join(output_dir, 'overview.html') self.assertTrue(os.path.exists(index_fp)) self.assertTrue(os.path.getsize(index_fp) > 0) csv_fp = os.path.join(output_dir, 'per-sample-fastq-counts.csv') self.assertTrue(os.path.exists(csv_fp)) self.assertTrue(os.path.getsize(csv_fp) > 0) pdf_fp = os.path.join(output_dir, 'demultiplex-summary.pdf') self.assertTrue(os.path.exists(pdf_fp)) png_fp = os.path.join(output_dir, 'demultiplex-summary.png') self.assertTrue(os.path.exists(png_fp)) with open(index_fp, 'r') as fh: html = fh.read() self.assertIn('<td>Minimum:</td><td>1</td>', html) self.assertIn('<td>Maximum:</td><td>1</td>', html)