Beispiel #1
0
    def test_shogun_utree(self):
        # inserting new prep template
        prep_info_dict = {
            'SKB8.640193': {'run_prefix': 'S22205_S104'},
            'SKD8.640184': {'run_prefix': 'S22282_S102'}}
        data = {'prep_info': dumps(prep_info_dict),
                # magic #1 = testing study
                'study': 1,
                'data_type': 'Metagenomic'}
        pid = self.qclient.post('/apitest/prep_template/', data=data)['prep']

        # inserting artifacts
        fp1_1, fp1_2, fp2_1, fp2_2 = self._helper_shogun_bowtie()
        data = {
            'filepaths': dumps([
                (fp1_1, 'raw_forward_seqs'),
                (fp1_2, 'raw_reverse_seqs'),
                (fp2_1, 'raw_forward_seqs'),
                (fp2_2, 'raw_reverse_seqs')]),
            'type': "per_sample_FASTQ",
            'name': "Test Shogun artifact",
            'prep': pid}
        aid = self.qclient.post('/apitest/artifact/', data=data)['artifact']

        self.params['input'] = aid
        self.params['Aligner tool'] = 'utree'
        data = {'user': '******',
                'command': dumps(['qp-shogun', '012020', 'Shogun v1.0.7']),
                'status': 'running',
                'parameters': dumps(self.params)}
        jid = self.qclient.post('/apitest/processing_job/', data=data)['job']

        out_dir = mkdtemp()
        self._clean_up_files.append(out_dir)

        success, ainfo, msg = shogun(self.qclient, jid, self.params, out_dir)

        self.assertEqual("", msg)
        self.assertTrue(success)

        # we are expecting 1 artifacts in total
        pout_dir = partial(join, out_dir)
        self.assertCountEqual(ainfo, [
            ArtifactInfo('Shogun Alignment Profile', 'BIOM',
                         [(pout_dir('otu_table.alignment.profile.biom'),
                           'biom'),
                          (pout_dir('alignment.utree.tsv.xz'), 'log')]),
            ArtifactInfo('Taxonomic Predictions - phylum', 'BIOM',
                         [(pout_dir('otu_table.redist.phylum.biom'),
                           'biom')]),
            ArtifactInfo('Taxonomic Predictions - genus', 'BIOM',
                         [(pout_dir('otu_table.redist.genus.biom'),
                           'biom')]),
            ArtifactInfo('Taxonomic Predictions - species', 'BIOM',
                         [(pout_dir('otu_table.redist.species.biom'),
                           'biom')])])
Beispiel #2
0
    def test_shogun_utree(self):
        # generating filepaths
        in_dir = mkdtemp()
        self._clean_up_files.append(in_dir)

        fp1_1 = join(in_dir, 'S22205_S104_L001_R1_001.fastq.gz')
        fp1_2 = join(in_dir, 'S22205_S104_L001_R2_001.fastq.gz')
        fp2_1 = join(in_dir, 'S22282_S102_L001_R1_001.fastq.gz')
        fp2_2 = join(in_dir, 'S22282_S102_L001_R2_001.fastq.gz')

        copyfile('support_files/S22205_S104_L001_R1_001.fastq.gz', fp1_1)
        copyfile('support_files/S22205_S104_L001_R2_001.fastq.gz', fp1_2)
        copyfile('support_files/S22282_S102_L001_R1_001.fastq.gz', fp2_1)
        copyfile('support_files/S22282_S102_L001_R2_001.fastq.gz', fp2_2)

        # inserting new prep template
        prep_info_dict = {
            'SKB8.640193': {
                'run_prefix': 'S22205_S104'
            },
            'SKD8.640184': {
                'run_prefix': 'S22282_S102'
            }
        }
        data = {
            'prep_info': dumps(prep_info_dict),
            # magic #1 = testing study
            'study': 1,
            'data_type': 'Metagenomic'
        }
        pid = self.qclient.post('/apitest/prep_template/', data=data)['prep']

        # inserting artifacts
        data = {
            'filepaths':
            dumps([(fp1_1, 'raw_forward_seqs'), (fp1_2, 'raw_reverse_seqs'),
                   (fp2_1, 'raw_forward_seqs'), (fp2_2, 'raw_reverse_seqs')]),
            'type':
            "per_sample_FASTQ",
            'name':
            "Test Shogun artifact",
            'prep':
            pid
        }
        aid = self.qclient.post('/apitest/artifact/', data=data)['artifact']

        self.params['input'] = aid
        self.params['Aligner tool'] = 'utree'
        data = {
            'user': '******',
            'command': dumps(['qp-shogun', '0.0.1', 'Shogun']),
            'status': 'running',
            'parameters': dumps(self.params)
        }
        jid = self.qclient.post('/apitest/processing_job/', data=data)['job']

        out_dir = mkdtemp()
        self._clean_up_files.append(out_dir)

        success, ainfo, msg = shogun(self.qclient, jid, self.params, out_dir)

        self.assertEqual("", msg)
        self.assertTrue(success)

        # we are expecting 2 artifacts in total
        self.assertEqual(2, len(ainfo))

        obs_func_fps = []
        obs_redist_fps = []
        ainfo_func = ainfo[0]
        ainfo_redist = ainfo[1]
        self.assertEqual('BIOM', ainfo_func.artifact_type)
        self.assertEqual('BIOM', ainfo_redist.artifact_type)
        obs_func_fps = ainfo_func.files
        obs_redist_fps = ainfo_redist.files

        od = partial(join, out_dir)
        func_prefix = "species"
        exp_func_fps = [
            od("otu_table.%s.kegg.modules.coverage.biom" % func_prefix),
            od("otu_table.%s.kegg.modules.biom" % func_prefix),
            od("otu_table.%s.kegg.pathways.coverage.biom" % func_prefix),
            od("otu_table.%s.kegg.pathways.biom" % func_prefix),
            od("otu_table.%s.kegg.biom" % func_prefix),
            od("otu_table.%s.normalized.biom" % func_prefix)
        ]

        exp_redist_fps = [
            od('otu_table.genus.redist.biom'),
            od('otu_table.species.redist.biom'),
            od('otu_table.strain.redist.biom')
        ]

        self.assertEqual(obs_func_fps, exp_func_fps)
        self.assertEqual(obs_redist_fps, exp_redist_fps)
Beispiel #3
0
    def test_shogun_utree(self):
        # generating filepaths
        in_dir = mkdtemp()
        self._clean_up_files.append(in_dir)

        fp1_1 = join(in_dir, 'S22205_S104_L001_R1_001.fastq.gz')
        fp1_2 = join(in_dir, 'S22205_S104_L001_R2_001.fastq.gz')
        fp2_1 = join(in_dir, 'S22282_S102_L001_R1_001.fastq.gz')
        fp2_2 = join(in_dir, 'S22282_S102_L001_R2_001.fastq.gz')

        copyfile('support_files/S22205_S104_L001_R1_001.fastq.gz', fp1_1)
        copyfile('support_files/S22205_S104_L001_R2_001.fastq.gz', fp1_2)
        copyfile('support_files/S22282_S102_L001_R1_001.fastq.gz', fp2_1)
        copyfile('support_files/S22282_S102_L001_R2_001.fastq.gz', fp2_2)

        # inserting new prep template
        prep_info_dict = {
            'SKB8.640193': {
                'run_prefix': 'S22205_S104'
            },
            'SKD8.640184': {
                'run_prefix': 'S22282_S102'
            }
        }
        data = {
            'prep_info': dumps(prep_info_dict),
            # magic #1 = testing study
            'study': 1,
            'data_type': 'Metagenomic'
        }
        pid = self.qclient.post('/apitest/prep_template/', data=data)['prep']

        # inserting artifacts
        data = {
            'filepaths':
            dumps([(fp1_1, 'raw_forward_seqs'), (fp1_2, 'raw_reverse_seqs'),
                   (fp2_1, 'raw_forward_seqs'), (fp2_2, 'raw_reverse_seqs')]),
            'type':
            "per_sample_FASTQ",
            'name':
            "Test Shogun artifact",
            'prep':
            pid
        }
        aid = self.qclient.post('/apitest/artifact/', data=data)['artifact']

        self.params['input'] = aid
        self.params['Aligner tool'] = 'utree'
        data = {
            'user': '******',
            'command': dumps(['qp-shogun', '0.1.4', 'Shogun']),
            'status': 'running',
            'parameters': dumps(self.params)
        }
        jid = self.qclient.post('/apitest/processing_job/', data=data)['job']

        out_dir = mkdtemp()
        self._clean_up_files.append(out_dir)

        success, ainfo, msg = shogun(self.qclient, jid, self.params, out_dir)

        self.assertEqual("", msg)
        self.assertTrue(success)

        # we are expecting 1 artifacts in total
        self.assertEqual(1, len(ainfo))
        ainfo = ainfo[0]
        self.assertEqual(ainfo.artifact_type, 'BIOM')
        exp = [(join(out_dir, 'otu_table.alignment.profile.biom'), 'biom')]
        self.assertCountEqual(ainfo.files, exp)