def test_make_fastqs_icell8_protocol(self):
     """make_fastqs: icell8 protocol
     """
     # Create mock source data
     illumina_run = MockIlluminaRun("171020_SN7001250_00002_AHGXXXX",
                                    "hiseq",
                                    top_dir=self.wd)
     illumina_run.create()
     # Create mock bcl2fastq
     # Check that bases mask is as expected
     MockBcl2fastq2Exe.create(os.path.join(self.bin, "bcl2fastq"),
                              assert_bases_mask="y25n76,I8,I8,y101")
     os.environ['PATH'] = "%s:%s" % (self.bin, os.environ['PATH'])
     # Do the test
     ap = AutoProcess()
     ap.setup(os.path.join(self.wd, "171020_SN7001250_00002_AHGXXXX"))
     self.assertTrue(ap.params.sample_sheet is not None)
     ap.make_fastqs(protocol="icell8")
     # Check outputs
     analysis_dir = os.path.join(self.wd,
                                 "171020_SN7001250_00002_AHGXXXX_analysis")
     for subdir in (os.path.join("primary_data",
                                 "171020_SN7001250_00002_AHGXXXX"),
                    os.path.join("logs",
                                 "002_make_fastqs_icell8"), "bcl2fastq"):
         self.assertTrue(os.path.isdir(os.path.join(analysis_dir, subdir)),
                         "Missing subdir: %s" % subdir)
     for filen in ("statistics.info", "statistics_full.info",
                   "per_lane_statistics.info", "per_lane_sample_stats.info",
                   "projects.info", "processing_qc.html"):
         self.assertTrue(os.path.isfile(os.path.join(analysis_dir, filen)),
                         "Missing file: %s" % filen)
 def test_make_fastqs_specify_platform_via_metadata(self):
     """make_fastqs: implicitly specify the platform via metadata
     """
     # Create mock source data
     illumina_run = MockIlluminaRun("171020_UNKNOWN_00002_AHGXXXX",
                                    "miseq",
                                    top_dir=self.wd)
     illumina_run.create()
     # Create mock bcl2fastq
     MockBcl2fastq2Exe.create(os.path.join(self.bin, "bcl2fastq"),
                              platform="miseq")
     os.environ['PATH'] = "%s:%s" % (self.bin, os.environ['PATH'])
     # Do the test
     ap = AutoProcess()
     ap.setup(os.path.join(self.wd, "171020_UNKNOWN_00002_AHGXXXX"))
     self.assertTrue(ap.params.sample_sheet is not None)
     self.assertTrue(ap.metadata.platform is None)
     ap.metadata["platform"] = "miseq"
     ap.make_fastqs(protocol="standard")
     # Check outputs
     analysis_dir = os.path.join(self.wd,
                                 "171020_UNKNOWN_00002_AHGXXXX_analysis")
     for subdir in (os.path.join("primary_data",
                                 "171020_UNKNOWN_00002_AHGXXXX"),
                    os.path.join("logs", "002_make_fastqs"), "bcl2fastq"):
         self.assertTrue(os.path.isdir(os.path.join(analysis_dir, subdir)),
                         "Missing subdir: %s" % subdir)
     for filen in ("statistics.info", "statistics_full.info",
                   "per_lane_statistics.info", "per_lane_sample_stats.info",
                   "projects.info", "processing_qc.html"):
         self.assertTrue(os.path.isfile(os.path.join(analysis_dir, filen)),
                         "Missing file: %s" % filen)
 def test_make_fastqs_missing_fastqs_with_placeholders(self):
     """make_fastqs: missing fastqs with placeholders
     """
     # Create mock source data
     illumina_run = MockIlluminaRun("171020_M00879_00002_AHGXXXX",
                                    "miseq",
                                    top_dir=self.wd)
     illumina_run.create()
     # Create mock bcl2fastq
     MockBcl2fastq2Exe.create(os.path.join(self.bin, "bcl2fastq"),
                              missing_fastqs=(
                                  "Sample1_S1_L001_R1_001.fastq.gz",
                                  "Sample1_S1_L001_R2_001.fastq.gz",
                              ))
     os.environ['PATH'] = "%s:%s" % (self.bin, os.environ['PATH'])
     # Do the test
     ap = AutoProcess()
     ap.setup(os.path.join(self.wd, "171020_M00879_00002_AHGXXXX"))
     self.assertTrue(ap.params.sample_sheet is not None)
     ap.make_fastqs(protocol="standard", create_empty_fastqs=True)
     # Check outputs
     analysis_dir = os.path.join(self.wd,
                                 "171020_M00879_00002_AHGXXXX_analysis")
     for subdir in (os.path.join("primary_data",
                                 "171020_M00879_00002_AHGXXXX"),
                    os.path.join("logs", "002_make_fastqs"), "bcl2fastq"):
         self.assertTrue(os.path.isdir(os.path.join(analysis_dir, subdir)),
                         "Missing subdir: %s" % subdir)
     for filen in ("statistics.info", "statistics_full.info",
                   "per_lane_statistics.info", "per_lane_sample_stats.info",
                   "projects.info"):
         self.assertTrue(os.path.exists(os.path.join(analysis_dir, filen)),
                         "Missing file: %s" % filen)
     self.assertTrue(
         os.path.exists(
             os.path.join(analysis_dir, "logs", "002_make_fastqs",
                          "missing_fastqs.log")))
     elif options.use_lane_splitting:
         no_lane_splitting = False
     else:
         no_lane_splitting = None
     # Do the make_fastqs step
     d.make_fastqs(skip_rsync=options.skip_rsync,
                   nprocessors=options.nprocessors,
                   runner=options.runner,
                   remove_primary_data=options.remove_primary_data,
                   ignore_missing_bcl=options.ignore_missing_bcl,
                   ignore_missing_stats=options.ignore_missing_stats,
                   generate_stats=(not options.no_stats),
                   require_bcl2fastq_version=options.bcl2fastq_version,
                   unaligned_dir=options.unaligned_dir,
                   sample_sheet=options.sample_sheet,
                   bases_mask=options.bases_mask,
                   no_lane_splitting=no_lane_splitting,
                   minimum_trimmed_read_length=options.minimum_trimmed_read_length,
                   mask_short_adapter_reads=options.mask_short_adapter_reads,
                   stats_file=options.stats_file,
                   per_lane_stats_file=options.per_lane_stats_file,
                   report_barcodes=options.report_barcodes,
                   barcodes_file=options.barcodes_file,
                   skip_bcl2fastq=options.skip_bcl2fastq,
                   only_fetch_primary_data=options.only_fetch_primary_data,
                   create_empty_fastqs=options.create_empty_fastqs)
 elif cmd == 'merge_fastq_dirs':
     d.merge_fastq_dirs(options.unaligned_dir,
                        dry_run=options.dry_run)
 elif cmd == 'update_fastq_stats':
     d.set_log_dir(d.get_log_subdir(cmd))