Beispiel #1
0
    def test_per_sample_ainfo_error(self):
        in_dir = mkdtemp()
        self._clean_up_files.append(in_dir)
        makedirs(join(in_dir, 'sampleA'))
        makedirs(join(in_dir, 'sampleB'))

        # Paired-end
        with self.assertRaises(ValueError):
            _per_sample_ainfo(in_dir, (('sampleA', None, None, None),
                                       ('sampleB', None, None, None)), [],
                              'filtering', 'QC_Filter Files', True)
Beispiel #2
0
def filter(qclient, job_id, parameters, out_dir):
    """Run filtering using Bowtie2 with the given parameters

    Parameters
    ----------
    qclient : tgp.qiita_client.QiitaClient
        The Qiita server client
    job_id : str
        The job id
    parameters : dict
        The parameter values to run split libraries
    out_dir : str
        The path to the job's output directory

    Returns
    -------
    bool, list, str
        The results of the job
    """
    # Step 1 get the rest of the information need to run Bowtie2
    qclient.update_job_step(job_id, "Step 1 of 4: Collecting information")
    artifact_id = parameters['input']
    del parameters['input']

    # Get the artifact filepath information
    artifact_info = qclient.get("/qiita_db/artifacts/%s/" % artifact_id)
    fps = artifact_info['files']

    # Get the artifact metadata
    prep_info = qclient.get('/qiita_db/prep_template/%s/' %
                            artifact_info['prep_information'][0])
    qiime_map = prep_info['qiime-map']

    # Step 2 generating command
    qclient.update_job_step(job_id, "Step 2 of 4: Generating"
                            " QC_Filter commands")
    # Creating temporary directory for intermediate files
    with TemporaryDirectory(dir=out_dir, prefix='filter_') as temp_dir:
        rs = fps['raw_reverse_seqs'] if 'raw_reverse_seqs' in fps else []
        commands, samples = generate_filter_commands(fps['raw_forward_seqs'],
                                                     rs, qiime_map, out_dir,
                                                     temp_dir, parameters)

        # Step 3 execute filtering command
        len_cmd = len(commands)
        msg = "Step 3 of 4: Executing QC_Filter job (%d/{0})".format(len_cmd)
        success, msg = _run_commands(qclient, job_id, commands, msg,
                                     'QC_Filter')
        if not success:
            return False, None, msg

    # Step 4 generating artifacts
    msg = "Step 4 of 4: Generating new artifacts (%d/{0})".format(len_cmd)
    suffixes = ['%s.R1.fastq.gz', '%s.R2.fastq.gz']
    prg_name = 'Filtering'
    file_type_name = 'Filtered files'
    ainfo = _per_sample_ainfo(out_dir, samples, suffixes, prg_name,
                              file_type_name, bool(rs))

    return True, ainfo, ""