Exemple #1
0
    def setUp(self):
        # Create a directory with the test split libraries output
        self.test_slo = mkdtemp(prefix='test_slo_')
        path_builder = partial(join, self.test_slo)
        fna_fp = path_builder('seqs.fna')
        fastq_fp = path_builder('seqs.fastq')
        log_fp = path_builder('split_library_log.txt')
        demux_fp = path_builder('seqs.demux')

        with open(fna_fp, 'w') as f:
            f.write(FASTA_SEQS)

        with open(fastq_fp, 'w') as f:
            f.write(FASTQ_SEQS)

        with open(log_fp, 'w') as f:
            f.write("Test log\n")

        generate_demux_file(self.test_slo)

        self._filepaths_to_remove = [fna_fp, fastq_fp, demux_fp, log_fp]
        self._dirpaths_to_remove = [self.test_slo]

        # Generate a directory with test split libraries output missing files
        self.missing_slo = mkdtemp(prefix='test_missing_')
        path_builder = partial(join, self.test_slo)
        fna_fp = path_builder('seqs.fna')
        fastq_fp = path_builder('seqs.fastq')

        with open(fna_fp, 'w') as f:
            f.write(FASTA_SEQS)

        with open(fastq_fp, 'w') as f:
            f.write(FASTQ_SEQS)

        self._filepaths_to_remove.append(fna_fp)
        self._filepaths_to_remove.append(fastq_fp)
        self._dirpaths_to_remove.append(self.missing_slo)

        # Create a study with no preprocessed data
        info = {
            "timeseries_type_id": 1,
            "metadata_complete": True,
            "mixs_compliant": True,
            "number_samples_collected": 25,
            "number_samples_promised": 28,
            "study_alias": "FCM",
            "study_description": "Microbiome of people who eat nothing but "
                                 "fried chicken",
            "study_abstract": "Exploring how a high fat diet changes the "
                              "gut microbiome",
            "emp_person_id": StudyPerson(2),
            "principal_investigator_id": StudyPerson(3),
            "lab_person_id": StudyPerson(1)
        }
        self.no_ppd_study = Study.create(
            User('*****@*****.**'), "Test study", [1], info)

        # Get the directory where the preprocessed data is usually copied.
        _, self.db_ppd_dir = get_mountpoint('preprocessed_data')[0]
    def test_generate_demux_file(self):
        prep_out_dir = mkdtemp()
        with open(join(prep_out_dir, 'seqs.fastq'), "w") as f:
            f.write(DEMUX_SEQS)

        obs_fp = generate_demux_file(prep_out_dir)

        exp_fp = join(prep_out_dir, 'seqs.demux')
        self.assertEqual(obs_fp, exp_fp)
        self.assertTrue(exists(exp_fp))
    def test_generate_demux_file(self):
        prep_out_dir = mkdtemp()
        with open(join(prep_out_dir, 'seqs.fastq'), "w") as f:
            f.write(DEMUX_SEQS)

        obs_fp = generate_demux_file(prep_out_dir)

        exp_fp = join(prep_out_dir, 'seqs.demux')
        self.assertEqual(obs_fp, exp_fp)
        self.assertTrue(exists(exp_fp))
Exemple #4
0
    def setUp(self):
        # Create a directory with the test split libraries output
        self.test_slo = mkdtemp(prefix='test_slo_')
        path_builder = partial(join, self.test_slo)
        fna_fp = path_builder('seqs.fna')
        fastq_fp = path_builder('seqs.fastq')
        log_fp = path_builder('split_library_log.txt')
        demux_fp = path_builder('seqs.demux')

        with open(fna_fp, 'w') as f:
            f.write(FASTA_SEQS)

        with open(fastq_fp, 'w') as f:
            f.write(FASTQ_SEQS)

        with open(log_fp, 'w') as f:
            f.write("Test log\n")

        generate_demux_file(self.test_slo)

        self._filepaths_to_remove = [fna_fp, fastq_fp, demux_fp, log_fp]
        self._dirpaths_to_remove = [self.test_slo]

        # Generate a directory with test split libraries output missing files
        self.missing_slo = mkdtemp(prefix='test_missing_')
        path_builder = partial(join, self.test_slo)
        fna_fp = path_builder('seqs.fna')
        fastq_fp = path_builder('seqs.fastq')

        with open(fna_fp, 'w') as f:
            f.write(FASTA_SEQS)

        with open(fastq_fp, 'w') as f:
            f.write(FASTQ_SEQS)

        self._filepaths_to_remove.append(fna_fp)
        self._filepaths_to_remove.append(fastq_fp)
        self._dirpaths_to_remove.append(self.missing_slo)

        # Create a study with no preprocessed data
        info = {
            "timeseries_type_id": 1,
            "metadata_complete": True,
            "mixs_compliant": True,
            "number_samples_collected": 25,
            "number_samples_promised": 28,
            "portal_type_id": 3,
            "study_alias": "FCM",
            "study_description": "Microbiome of people who eat nothing but "
            "fried chicken",
            "study_abstract": "Exploring how a high fat diet changes the "
            "gut microbiome",
            "emp_person_id": StudyPerson(2),
            "principal_investigator_id": StudyPerson(3),
            "lab_person_id": StudyPerson(1)
        }
        self.no_ppd_study = Study.create(User('*****@*****.**'), "Test study",
                                         [1], info)

        # Get the directory where the preprocessed data is usually copied.
        _, self.db_ppd_dir = get_mountpoint('preprocessed_data')[0]