Exemplo n.º 1
0
    def test_load_processed_data_from_cmd(self):
        filepaths = [self.otu_table_fp, self.otu_table_2_fp]
        filepath_types = ['biom', 'biom']

        initial_processed_data_count = get_count('qiita.processed_data')
        initial_processed_fp_count = get_count('qiita.processed_filepath')
        initial_fp_count = get_count('qiita.filepath')

        new = load_processed_data_cmd(filepaths, filepath_types,
                                      'processed_params_uclust', 1, 1, None)
        processed_data_id = new.id
        self.files_to_remove.append(
            join(self.db_test_processed_data_dir,
                 '%d_%s' % (processed_data_id, basename(self.otu_table_fp))))
        self.files_to_remove.append(
            join(self.db_test_processed_data_dir,
                 '%d_%s' % (processed_data_id,
                            basename(self.otu_table_2_fp))))

        self.assertTrue(check_count('qiita.processed_data',
                                    initial_processed_data_count + 1))
        self.assertTrue(check_count('qiita.processed_filepath',
                                    initial_processed_fp_count + 2))
        self.assertTrue(check_count('qiita.filepath',
                                    initial_fp_count + 2))

        # Ensure that the ValueError is raised when a filepath_type is not
        # provided for each and every filepath
        with self.assertRaises(ValueError):
            load_processed_data_cmd(filepaths, filepath_types[:-1],
                                    'processed_params_uclust', 1, 1, None)
Exemplo n.º 2
0
    def test_post_edit(self):
        study_count_before = get_count('qiita.study')
        study = Study(1)
        study_info = study.info

        post_data = {
            'new_people_names': [],
            'new_people_emails': [],
            'new_people_affiliations': [],
            'new_people_addresses': [],
            'new_people_phones': [],
            'study_title': 'New title - test post edit',
            'study_alias': study_info['study_alias'],
            'publications_doi':
            ','.join([doi for doi, _ in study.publications]),
            'study_abstract': study_info['study_abstract'],
            'study_description': study_info['study_description'],
            'principal_investigator': study_info['principal_investigator'].id,
            'lab_person': study_info['lab_person'].id
        }

        self.post('/study/edit/1', post_data)

        # Check that the study was updated
        self.assertTrue(check_count('qiita.study', study_count_before))
        self.assertEqual(study.title, 'New title - test post edit')
Exemplo n.º 3
0
    def test_post_edit(self):
        study_count_before = get_count('qiita.study')
        study = Study(1)
        study_info = study.info

        post_data = {
            'new_people_names': [],
            'new_people_emails': [],
            'new_people_affiliations': [],
            'new_people_addresses': [],
            'new_people_phones': [],
            'study_title': 'dummy title',
            'study_alias': study_info['study_alias'],
            'pubmed_id': ','.join(study.pmids),
            'study_abstract': study_info['study_abstract'],
            'study_description': study_info['study_description'],
            'principal_investigator': study_info['principal_investigator_id'],
            'lab_person': study_info['lab_person_id']
        }

        self.post('/study/edit/1', post_data)

        # Check that the study was updated
        self.assertTrue(check_count('qiita.study', study_count_before))
        self.assertEqual(study.title, 'dummy title')
Exemplo n.º 4
0
    def test_post_edit_blank_doi(self):
        study_count_before = get_count('qiita.study')
        study = Study(1)
        study_info = study.info

        post_data = {
            'new_people_names': [],
            'new_people_emails': [],
            'new_people_affiliations': [],
            'new_people_addresses': [],
            'new_people_phones': [],
            'study_title': 'New title - test post edit',
            'study_alias': study_info['study_alias'],
            'publications_doi': '',
            'study_abstract': study_info['study_abstract'],
            'study_description': study_info['study_description'],
            'principal_investigator': study_info['principal_investigator'].id,
            'lab_person': study_info['lab_person'].id}

        self.post('/study/edit/1', post_data)

        # Check that the study was updated
        self.assertTrue(check_count('qiita.study', study_count_before))
        self.assertEqual(study.title, 'New title - test post edit')
        self.assertEqual(study.publications, [])
Exemplo n.º 5
0
 def test_import_preprocessed_data(self):
     initial_ppd_count = get_count('qiita.preprocessed_data')
     initial_fp_count = get_count('qiita.filepath')
     ppd = load_preprocessed_data_from_cmd(
         1, 'preprocessed_sequence_illumina_params',
         self.tmpdir, 'preprocessed_sequences', 1, False, 1)
     self.files_to_remove.append(
         join(self.db_test_ppd_dir,
              '%d_%s' % (ppd.id, basename(self.file1))))
     self.files_to_remove.append(
         join(self.db_test_ppd_dir,
              '%d_%s' % (ppd.id, basename(self.file2))))
     self.assertEqual(ppd.id, 3)
     self.assertTrue(check_count('qiita.preprocessed_data',
                                 initial_ppd_count + 1))
     self.assertTrue(check_count('qiita.filepath', initial_fp_count+2))
Exemplo n.º 6
0
    def test_post_edit(self):
        study_count_before = get_count('qiita.study')
        study = Study(1)
        study_info = study.info

        post_data = {
            'new_people_names': [],
            'new_people_emails': [],
            'new_people_affiliations': [],
            'new_people_addresses': [],
            'new_people_phones': [],
            'study_title': 'dummy title',
            'study_alias': study_info['study_alias'],
            'publications_doi': ','.join(
                [doi for doi, _ in study.publications]),
            'study_abstract': study_info['study_abstract'],
            'study_description': study_info['study_description'],
            'principal_investigator': study_info['principal_investigator_id'],
            'lab_person': study_info['lab_person_id']}

        self.post('/study/edit/1', post_data)

        # Check that the study was updated
        self.assertTrue(check_count('qiita.study', study_count_before))
        self.assertEqual(study.title, 'dummy title')
Exemplo n.º 7
0
    def test_new_person_created(self):
        person_count_before = get_count('qiita.study_person')

        post_data = {'new_people_names': ['Adam', 'Ethan'],
                     'new_people_emails': ['*****@*****.**', '*****@*****.**'],
                     'new_people_affiliations': ['CU Boulder', 'NYU'],
                     'new_people_addresses': ['Some St., Boulder, CO 80305',
                                              ''],
                     'new_people_phones': ['', ''],
                     'study_title': 'dummy title',
                     'study_alias': 'dummy alias',
                     'pubmed_id': 'dummy pmid',
                     'investigation_type': 'eukaryote',
                     'environmental_packages': 'air',
                     'is_timeseries': 'y',
                     'study_abstract': "dummy abstract",
                     'study_description': 'dummy description',
                     'principal_investigator': '-2',
                     'lab_person': '1'}

        self.post('/study/create/', post_data)

        # Check that the new person was created
        expected_id = person_count_before + 1
        self.assertTrue(check_count('qiita.study_person', expected_id))

        new_person = StudyPerson(expected_id)
        self.assertTrue(new_person.name == 'Ethan')
        self.assertTrue(new_person.email == '*****@*****.**')
        self.assertTrue(new_person.affiliation == 'NYU')
        self.assertTrue(new_person.address is None)
        self.assertTrue(new_person.phone is None)
Exemplo n.º 8
0
    def test_load_data_from_cmd(self):
        filepaths = [self.forward_fp, self.reverse_fp, self.barcodes_fp]
        filepath_types = ['raw_forward_seqs', 'raw_reverse_seqs',
                          'raw_barcodes']

        filetype = 'FASTQ'
        metadata_dict = {
            'SKB8.640193': {'center_name': 'ANL',
                            'primer': 'GTGCCAGCMGCCGCGGTAA',
                            'barcode': 'GTCCGCAAGTTA',
                            'run_prefix': "s_G1_L001_sequences",
                            'platform': 'ILLUMINA',
                            'instrument_model': 'Illumina MiSeq',
                            'library_construction_protocol': 'AAAA',
                            'experiment_design_description': 'BBBB'}}
        metadata = pd.DataFrame.from_dict(metadata_dict, orient='index')
        pt1 = PrepTemplate.create(metadata, Study(1), "16S")
        prep_templates = [pt1.id]

        initial_raw_count = get_count('qiita.raw_data')
        initial_fp_count = get_count('qiita.filepath')
        initial_raw_fp_count = get_count('qiita.raw_filepath')

        new = load_raw_data_cmd(filepaths, filepath_types, filetype,
                                prep_templates)
        raw_data_id = new.id
        self.files_to_remove.append(
            join(self.db_test_raw_dir,
                 '%d_%s' % (raw_data_id, basename(self.forward_fp))))
        self.files_to_remove.append(
            join(self.db_test_raw_dir,
                 '%d_%s' % (raw_data_id, basename(self.reverse_fp))))
        self.files_to_remove.append(
            join(self.db_test_raw_dir,
                 '%d_%s' % (raw_data_id, basename(self.barcodes_fp))))

        self.assertTrue(check_count('qiita.raw_data', initial_raw_count + 1))
        self.assertTrue(check_count('qiita.filepath',
                                    initial_fp_count + 3))
        self.assertTrue(check_count('qiita.raw_filepath',
                                    initial_raw_fp_count + 3))

        # Ensure that the ValueError is raised when a filepath_type is not
        # provided for each and every filepath
        with self.assertRaises(ValueError):
            load_raw_data_cmd(filepaths, filepath_types[:-1], filetype,
                              prep_templates)
Exemplo n.º 9
0
    def test_load_data_from_cmd(self):
        filepaths = [self.forward_fp, self.reverse_fp, self.barcodes_fp]
        filepath_types = ['raw_forward_seqs', 'raw_reverse_seqs',
                          'raw_barcodes']

        filetype = 'FASTQ'
        study_ids = [1]

        initial_raw_count = get_count('qiita.raw_data')
        initial_fp_count = get_count('qiita.filepath')
        initial_raw_fp_count = get_count('qiita.raw_filepath')

        new = load_raw_data_cmd(filepaths, filepath_types, filetype,
                                study_ids)
        raw_data_id = new.id
        self.files_to_remove.append(
            join(self.db_test_raw_dir,
                 '%d_%s' % (raw_data_id, basename(self.forward_fp))))
        self.files_to_remove.append(
            join(self.db_test_raw_dir,
                 '%d_%s' % (raw_data_id, basename(self.reverse_fp))))
        self.files_to_remove.append(
            join(self.db_test_raw_dir,
                 '%d_%s' % (raw_data_id, basename(self.barcodes_fp))))

        self.assertTrue(check_count('qiita.raw_data', initial_raw_count + 1))
        self.assertTrue(check_count('qiita.filepath',
                                    initial_fp_count + 3))
        self.assertTrue(check_count('qiita.raw_filepath',
                                    initial_raw_fp_count + 3))
        self.assertTrue(check_count('qiita.study_raw_data',
                                    initial_raw_count + 1))

        # Ensure that the ValueError is raised when a filepath_type is not
        # provided for each and every filepath
        with self.assertRaises(ValueError):
            load_raw_data_cmd(filepaths, filepath_types[:-1], filetype,
                              study_ids)
Exemplo n.º 10
0
    def test_post(self):
        person_count_before = get_count('qiita.study_person')
        study_count_before = get_count('qiita.study')

        post_data = {
            'new_people_names': ['Adam', 'Ethan'],
            'new_people_emails': ['*****@*****.**', '*****@*****.**'],
            'new_people_affiliations': ['CU Boulder', 'NYU'],
            'new_people_addresses': ['Some St., Boulder, CO 80305', ''],
            'new_people_phones': ['', ''],
            'study_title': 'dummy title',
            'study_alias': 'dummy alias',
            'pubmed_id': 'dummy pmid',
            'environmental_packages': ['air'],
            'timeseries': '1',
            'study_abstract': "dummy abstract",
            'study_description': 'dummy description',
            'principal_investigator': '-2',
            'notes': '',
            'lab_person': '1'
        }

        self.post('/study/create/', post_data)

        # Check that the new person was created
        expected_id = person_count_before + 1
        self.assertTrue(check_count('qiita.study_person', expected_id))

        new_person = StudyPerson(expected_id)
        self.assertTrue(new_person.name == 'Ethan')
        self.assertTrue(new_person.email == '*****@*****.**')
        self.assertTrue(new_person.affiliation == 'NYU')
        self.assertTrue(new_person.address is None)
        self.assertTrue(new_person.phone is None)

        # Check the study was created
        expected_id = study_count_before + 1
        self.assertTrue(check_count('qiita.study', expected_id))
Exemplo n.º 11
0
    def test_load_data_from_cmd(self):
        filepaths = [self.forward_fp, self.reverse_fp, self.barcodes_fp]
        filepath_types = ['raw_sequences', 'raw_sequences', 'raw_barcodes']

        filetype = 'FASTQ'
        study_ids = [1]

        initial_raw_count = get_count('qiita.raw_data')
        initial_fp_count = get_count('qiita.filepath')
        initial_raw_fp_count = get_count('qiita.raw_filepath')

        new = load_raw_data_cmd(filepaths, filepath_types, filetype,
                                study_ids)
        raw_data_id = new.id
        self.files_to_remove.append(
            join(self.db_test_raw_dir,
                 '%d_%s' % (raw_data_id, basename(self.forward_fp))))
        self.files_to_remove.append(
            join(self.db_test_raw_dir,
                 '%d_%s' % (raw_data_id, basename(self.reverse_fp))))
        self.files_to_remove.append(
            join(self.db_test_raw_dir,
                 '%d_%s' % (raw_data_id, basename(self.barcodes_fp))))

        self.assertTrue(check_count('qiita.raw_data', initial_raw_count + 1))
        self.assertTrue(check_count('qiita.filepath',
                                    initial_fp_count + 3))
        self.assertTrue(check_count('qiita.raw_filepath',
                                    initial_raw_fp_count + 3))
        self.assertTrue(check_count('qiita.study_raw_data',
                                    initial_raw_count + 1))

        # Ensure that the ValueError is raised when a filepath_type is not
        # provided for each and every filepath
        with self.assertRaises(ValueError):
            load_raw_data_cmd(filepaths, filepath_types[:-1], filetype,
                              study_ids)
Exemplo n.º 12
0
    def test_post_edit_blank_doi(self):
        study_count_before = get_count('qiita.study')
        study = Study(1)
        study_info = study.info

        post_data = {
            'new_people_names': [],
            'new_people_emails': [],
            'new_people_affiliations': [],
            'new_people_addresses': [],
            'new_people_phones': [],
            'study_title': 'New title - test post edit',
            'study_alias': study_info['study_alias'],
            'publications_doi': '',
            'study_abstract': study_info['study_abstract'],
            'study_description': study_info['study_description'],
            'notes': '',
            'principal_investigator': study_info['principal_investigator'].id,
            'lab_person': study_info['lab_person'].id
        }

        response = self.post('/study/edit/1', post_data)
        self.assertEqual(response.code, 200)
        # Check that the study was updated
        self.assertTrue(check_count('qiita.study', study_count_before))
        self.assertEqual(study.title, 'New title - test post edit')
        self.assertEqual(study.publications, [])

        # check for failure
        old_title = post_data['study_title']
        post_data['study_title'] = 'My new title!'
        shared = User('*****@*****.**')
        study.unshare(shared)
        BaseHandler.get_current_user = Mock(return_value=shared)
        response = self.post('/study/edit/1', post_data)
        self.assertEqual(response.code, 403)
        # Check that the study wasn't updated
        self.assertEqual(study.title, old_title)

        # returning sharing
        study.share(shared)
Exemplo n.º 13
0
    def test_post_edit_blank_doi(self):
        study_count_before = get_count('qiita.study')
        study = Study(1)
        study_info = study.info

        post_data = {
            'new_people_names': [],
            'new_people_emails': [],
            'new_people_affiliations': [],
            'new_people_addresses': [],
            'new_people_phones': [],
            'study_title': 'New title - test post edit',
            'study_alias': study_info['study_alias'],
            'publications_doi': '',
            'study_abstract': study_info['study_abstract'],
            'study_description': study_info['study_description'],
            'principal_investigator': study_info['principal_investigator'].id,
            'lab_person': study_info['lab_person'].id}

        response = self.post('/study/edit/1', post_data)
        self.assertEqual(response.code, 200)
        # Check that the study was updated
        self.assertTrue(check_count('qiita.study', study_count_before))
        self.assertEqual(study.title, 'New title - test post edit')
        self.assertEqual(study.publications, [])

        # check for failure
        old_title = post_data['study_title']
        post_data['study_title'] = 'My new title!'
        shared = User('*****@*****.**')
        study.unshare(shared)
        BaseHandler.get_current_user = Mock(return_value=shared)
        response = self.post('/study/edit/1', post_data)
        self.assertEqual(response.code, 403)
        # Check that the study wasn't updated
        self.assertEqual(study.title, old_title)

        # returning sharing
        study.share(shared)
Exemplo n.º 14
0
 def test_ontology_terms(self):
     self.assertTrue(check_count('qiita.term', 14))
Exemplo n.º 15
0
 def test_ontology(self):
     self.assertTrue(check_count('qiita.ontology', 1))
Exemplo n.º 16
0
 def test_raw_filepath(self):
     check_count("qiita.raw_filepath", 4)
Exemplo n.º 17
0
 def test_study_raw_data(self):
     check_count("qiita.study_raw_data", 2)
Exemplo n.º 18
0
 def test_filepath_type(self):
     check_count("qiita.filepath_type", 8)
Exemplo n.º 19
0
 def test_raw_preprocessed_data(self):
     check_count("qiita.raw_preprocessed_data", 2)
Exemplo n.º 20
0
 def test_study_experimental_factor(self):
     check_count("qiita.study_experimental_factor", 1)
Exemplo n.º 21
0
 def test_check_count(self):
     """Checks that check_count returns True and False appropriately"""
     self.assertTrue(check_count('qiita.study_person', 3))
     self.assertFalse(check_count('qiita.study_person', 2))
Exemplo n.º 22
0
 def test_required_sample_info(self):
     check_count("qiita.required_sample_info", 27)
Exemplo n.º 23
0
 def test_ontology_terms(self):
     self.assertTrue(check_count('qiita.term', 14))
Exemplo n.º 24
0
 def test_preprocessed_processed_data(self):
     check_count("qiita.preprocessed_processed_data", 1)
Exemplo n.º 25
0
 def test_preprocessed_sequence_illumina_params(self):
     check_count("qiita.preprocessed_sequence_illumina_params", 2)
Exemplo n.º 26
0
 def test_study_preprocessed_data(self):
     check_count("qiita.study_preprocessed_data", 2)
Exemplo n.º 27
0
 def test_raw_data(self):
     check_count("qiita.raw_data", 2)
Exemplo n.º 28
0
 def test_sample_1(self):
     check_count("qiita.sample_1", 27)
Exemplo n.º 29
0
 def test_common_prep_info(self):
     check_count("qiita.common_prep_info", 27)
Exemplo n.º 30
0
 def test_raw_data_prep_columns(self):
     check_count("qiita.raw_data_prep_columns", 19)
Exemplo n.º 31
0
 def test_filepath(self):
     check_count("qiita.filepath", 9)
Exemplo n.º 32
0
 def test_prep_1(self):
     check_count("qiita.prep_1", 27)
Exemplo n.º 33
0
 def test_reference(self):
     check_count("qiita.reference", 1)
Exemplo n.º 34
0
 def test_study_sample_columns(self):
     check_count("qiita.study_sample_columns", 23)
Exemplo n.º 35
0
 def test_ontology(self):
     self.assertTrue(check_count('qiita.ontology', 1))
Exemplo n.º 36
0
 def test_processed_params_uclust(self):
     check_count("qiita.processed_params_uclust", 1)
Exemplo n.º 37
0
 def test_check_count(self):
     """Checks that check_count returns True and False appropriately"""
     self.assertTrue(check_count('qiita.study_person', 3))
     self.assertFalse(check_count('qiita.study_person', 2))
Exemplo n.º 38
0
 def test_processed_filepath(self):
     check_count("qiita.processed_filepath", 1)