Exemplo n.º 1
0
    def test_validate_demux_file_error(self):
        demux_fp, _, out_dir = self._generate_files({'s1': 's1', 's2': 's2'})

        # Run prefix not provided and demux samples do not match
        prep_info = {
            "1.SKB2.640194": {
                "not_a_run_prefix": "prefix1"
            },
            "1.SKM4.640180": {
                "not_a_run_prefix": "prefix2"
            },
            "1.SKB3.640195": {
                "not_a_run_prefix": "prefix3"
            }
        }
        files = {'preprocessed_demux': [demux_fp]}
        job_id = self._create_template_and_job(prep_info, files,
                                               "Demultiplexed")
        obs_success, obs_ainfo, obs_error = _validate_demux_file(
            self.qclient, job_id, prep_info, out_dir, demux_fp)
        self.assertFalse(obs_success)
        self.assertIsNone(obs_ainfo)
        self.assertEqual(
            obs_error, 'The sample ids in the demultiplexed files do not '
            'match the ones in the prep information. Please, '
            'provide the column "run_prefix" in the prep '
            'information to map the existing sample ids to the '
            'prep information sample ids.')

        # Incorrect run prefix column
        prep_info = {
            "1.SKB2.640194": {
                "run_prefix": "prefix1"
            },
            "1.SKM4.640180": {
                "run_prefix": "prefix2"
            },
            "1.SKB3.640195": {
                "run_prefix": "prefix3"
            }
        }
        job_id = self._create_template_and_job(prep_info, files,
                                               "Demultiplexed")
        obs_success, obs_ainfo, obs_error = _validate_demux_file(
            self.qclient, job_id, prep_info, out_dir, demux_fp)
        self.assertFalse(obs_success)
        self.assertIsNone(obs_ainfo)
        self.assertEqual(
            obs_error, 'The sample ids in the "run_prefix" columns from the '
            'prep information do not match the ones in the demux '
            'file. Please, correct the column "run_prefix" in '
            'the prep information to map the existing sample ids '
            'to the prep information sample ids.')
Exemplo n.º 2
0
 def test_validate_demux_file_infer(self):
     demux_fp, _, out_dir = self._generate_files({'s1': 'SKB2.640194',
                                                  's2': 'SKM4.640180'})
     prep_info = {"1.SKB2.640194": {"not_a_run_prefix": "s1"},
                  "1.SKM4.640180": {"not_a_run_prefix": "s2"},
                  "1.SKB3.640195": {"not_a_run_prefix": "s3"},
                  "1.SKB6.640176": {"not_a_run_prefix": "s4"}}
     files = {'preprocessed_demux': [demux_fp]}
     job_id = self._create_template_and_job(
         prep_info, files, "Demultiplexed")
     obs_success, obs_ainfo, obs_error = _validate_demux_file(
         self.qclient, job_id, prep_info, out_dir, demux_fp)
     self.assertTrue(obs_success)
     name = splitext(basename(demux_fp))[0]
     exp_fastq_fp = join(out_dir, "%s.fastq" % name)
     exp_fasta_fp = join(out_dir, "%s.fasta" % name)
     exp_demux_fp = join(out_dir, basename(demux_fp))
     filepaths = [
         (exp_fastq_fp, 'preprocessed_fastq'),
         (exp_fasta_fp, 'preprocessed_fasta'),
         (exp_demux_fp, 'preprocessed_demux')]
     exp = [ArtifactInfo(None, "Demultiplexed", filepaths)]
     self.assertEqual(obs_ainfo, exp)
     self.assertEqual(obs_error, "")
     with File(exp_demux_fp) as f:
         self.assertItemsEqual(f.keys(), ["1.SKB2.640194", "1.SKM4.640180"])
Exemplo n.º 3
0
 def test_validate_demux_file(self):
     demux_fp, _, out_dir = self._generate_files({'s1': 's1', 's2': 's2'})
     prep_info = {
         "1.SKB2.640194": {
             "run_prefix": "s1"
         },
         "1.SKM4.640180": {
             "run_prefix": "s2"
         },
         "1.SKB3.640195": {
             "run_prefix": "s3"
         },
         "1.SKB6.640176": {
             "run_prefix": "s4"
         }
     }
     files = {'preprocessed_demux': demux_fp}
     job_id = self._create_template_and_job(prep_info, files,
                                            "Demultiplexed")
     obs_success, obs_ainfo, obs_error = _validate_demux_file(
         self.qclient, job_id, prep_info, out_dir, demux_fp)
     self.assertTrue(obs_success)
     name = splitext(basename(demux_fp))[0]
     exp_fastq_fp = join(out_dir, "%s.fastq" % name)
     exp_fasta_fp = join(out_dir, "%s.fasta" % name)
     exp_demux_fp = join(out_dir, basename(demux_fp))
     filepaths = [(exp_fastq_fp, 'preprocessed_fastq'),
                  (exp_fasta_fp, 'preprocessed_fasta'),
                  (exp_demux_fp, 'preprocessed_demux')]
     exp = [ArtifactInfo(None, "Demultiplexed", filepaths)]
     self.assertEqual(obs_ainfo, exp)
     self.assertEqual(obs_error, "")
     with File(exp_demux_fp) as f:
         self.assertItemsEqual(f.keys(), ["1.SKB2.640194", "1.SKM4.640180"])
Exemplo n.º 4
0
    def test_validate_demux_file_error(self):
        demux_fp, _, out_dir = self._generate_files({'s1': 's1', 's2': 's2'})

        # Run prefix not provided and demux samples do not match
        prep_info = {"1.SKB2.640194": {"not_a_run_prefix": "prefix1"},
                     "1.SKM4.640180": {"not_a_run_prefix": "prefix2"},
                     "1.SKB3.640195": {"not_a_run_prefix": "prefix3"}}
        files = {'preprocessed_demux': [demux_fp]}
        job_id = self._create_template_and_job(
            prep_info, files, "Demultiplexed")
        obs_success, obs_ainfo, obs_error = _validate_demux_file(
            self.qclient, job_id, prep_info, out_dir, demux_fp)
        self.assertFalse(obs_success)
        self.assertIsNone(obs_ainfo)
        self.assertEqual(obs_error,
                         'The sample ids in the demultiplexed files do not '
                         'match the ones in the prep information. Please, '
                         'provide the column "run_prefix" in the prep '
                         'information to map the existing sample ids to the '
                         'prep information sample ids.')

        # Incorrect run prefix column
        prep_info = {"1.SKB2.640194": {"run_prefix": "prefix1"},
                     "1.SKM4.640180": {"run_prefix": "prefix2"},
                     "1.SKB3.640195": {"run_prefix": "prefix3"}}
        job_id = self._create_template_and_job(
            prep_info, files, "Demultiplexed")
        obs_success, obs_ainfo, obs_error = _validate_demux_file(
            self.qclient, job_id, prep_info, out_dir, demux_fp)
        self.assertFalse(obs_success)
        self.assertIsNone(obs_ainfo)
        self.assertEqual(obs_error,
                         'The sample ids in the "run_prefix" columns from the '
                         'prep information do not match the ones in the demux '
                         'file. Please, correct the column "run_prefix" in '
                         'the prep information to map the existing sample ids '
                         'to the prep information sample ids.')