当前位置: 首页>>代码示例>>Python>>正文


Python Study.create方法代码示例

本文整理汇总了Python中qiita_db.study.Study.create方法的典型用法代码示例。如果您正苦于以下问题:Python Study.create方法的具体用法?Python Study.create怎么用?Python Study.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qiita_db.study.Study的用法示例。


在下文中一共展示了Study.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_accessible_filepath_ids

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import create [as 别名]
    def test_get_accessible_filepath_ids(self):
        self._set_processed_data_private()

        # shared has access to all study files and analysis files

        obs = get_accessible_filepath_ids(User('[email protected]'))
        self.assertEqual(obs, set([1, 2, 5, 6, 7, 11, 12, 13, 14, 15, 16, 17,
                                   18, 19, 20]))

        # Now shared should not have access to the study files
        self._unshare_studies()
        obs = get_accessible_filepath_ids(User('[email protected]'))
        self.assertEqual(obs, set([12, 13, 14, 15]))

        # Now shared should not have access to any files
        self._unshare_analyses()
        obs = get_accessible_filepath_ids(User('[email protected]'))
        self.assertEqual(obs, set())

        # Now shared has access to public study files
        self._set_processed_data_public()
        obs = get_accessible_filepath_ids(User('[email protected]'))
        self.assertEqual(obs, set([1, 2, 5, 6, 7, 11, 16, 19, 20]))

        # Test that it doesn't break: if the SampleTemplate hasn't been added
        exp = set([1, 2, 5, 6, 7, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])
        obs = get_accessible_filepath_ids(User('[email protected]'))
        self.assertEqual(obs, exp)

        info = {
            "timeseries_type_id": 1,
            "metadata_complete": True,
            "mixs_compliant": True,
            "number_samples_collected": 4,
            "number_samples_promised": 4,
            "portal_type_id": 3,
            "study_alias": "TestStudy",
            "study_description": "Description of a test study",
            "study_abstract": "No abstract right now...",
            "emp_person_id": 1,
            "principal_investigator_id": 1,
            "lab_person_id": 1
        }
        Study.create(User('[email protected]'), "Test study", [1], info)
        obs = get_accessible_filepath_ids(User('[email protected]'))
        self.assertEqual(obs, exp)

        # test in case there is a prep template that failed
        self.conn_handler.execute(
            "INSERT INTO qiita.prep_template (data_type_id, raw_data_id) "
            "VALUES (2,1)")
        obs = get_accessible_filepath_ids(User('[email protected]'))
        self.assertEqual(obs, exp)

        # admin should have access to everything
        count = self.conn_handler.execute_fetchone("SELECT count(*) FROM "
                                                   "qiita.filepath")[0]
        exp = set(range(1, count + 1))
        obs = get_accessible_filepath_ids(User('[email protected]'))
        self.assertEqual(obs, exp)
开发者ID:aashish24,项目名称:qiita,代码行数:62,代码来源:test_meta_util.py

示例2: test_build_study_info_new_study

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import create [as 别名]
    def test_build_study_info_new_study(self):
        ProcessedData(1).status = 'public'
        info = {
            'timeseries_type_id': 1,
            'portal_type_id': 1,
            'lab_person_id': None,
            'principal_investigator_id': 3,
            'metadata_complete': False,
            'mixs_compliant': True,
            'study_description': 'desc',
            'study_alias': 'alias',
            'study_abstract': 'abstract'}
        user = User('[email protected]')

        Study.create(user, 'test_study_1', efo=[1], info=info)
        obs = _build_study_info(user)
        self.exp.append({
            'status': 'sandbox',
            'checkbox': "<input type='checkbox' value='2' />",
            'abstract': 'abstract',
            'meta_complete': "<span class='glyphicon glyphicon-remove'>"
            "</span>",
            'title': '<a href=\'#\' data-toggle=\'modal\' data-target=\'#study'
            '-abstract-modal\' onclick=\'fillAbstract("studies-table"'
            ', 1)\'><span class=\'glyphicon glyphicon-file\' aria-hidden=\''
            'true\'></span></a> | <a href=\'/study/description/2\' id=\''
            'study1-title\'>test_study_1</a>',
            'num_raw_data': 0, 'id': 2, 'num_samples': '0',
            'shared': "<span id='shared_html_2'></span><br/><a class='btn "
            "btn-primary btn-xs' data-toggle='modal' data-target='#share-study"
            "-modal-view' onclick='modify_sharing(2);'>Modify</a>",
            'pmid': '', 'pi':
            '<a target="_blank" href="mailto:[email protected]">PIDude</a>'})
        self.assertEqual(obs, self.exp)
开发者ID:zonca,项目名称:qiita,代码行数:36,代码来源:test_study_handlers.py

示例3: test_build_study_info_new_study

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import create [as 别名]
    def test_build_study_info_new_study(self):
        info = {
            'timeseries_type_id': 1,
            'portal_type_id': 1,
            'lab_person_id': None,
            'principal_investigator_id': 3,
            'metadata_complete': False,
            'mixs_compliant': True,
            'study_description': 'desc',
            'study_alias': 'alias',
            'study_abstract': 'abstract'}
        user = User('[email protected]')

        Study.create(user, 'test_study_1', efo=[1], info=info)

        obs = _build_study_info('private', user)

        StudyTuple = namedtuple('StudyInfo', 'id title meta_complete '
                                'num_samples_collected shared num_raw_data pi '
                                'pmids owner status')
        exp = [
            StudyTuple(
                id=2,
                title='test_study_1',
                meta_complete=False, num_samples_collected=None,
                shared='',
                num_raw_data=0,
                pi='<a target="_blank" href="mailto:[email protected]">'
                   'PIDude</a>',
                pmids='',
                owner='<a target="_blank" href="mailto:[email protected]">'
                      '[email protected]</a>',
                status='sandbox')]
        self.assertEqual(obs, exp)
开发者ID:BrindhaBioinfo,项目名称:qiita,代码行数:36,代码来源:test_study_handlers.py

示例4: setUp

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import create [as 别名]
    def setUp(self):
        fd, self.seqs_fp = mkstemp(suffix='_seqs.fastq')
        close(fd)
        fd, self.barcodes_fp = mkstemp(suffix='_barcodes.fastq')
        close(fd)
        self.filetype = 2
        self.filepaths = [(self.seqs_fp, 1), (self.barcodes_fp, 2)]
        self.studies = [Study(1)]
        _, self.db_test_raw_dir = get_mountpoint('raw_data')[0]

        with open(self.seqs_fp, "w") as f:
            f.write("\n")
        with open(self.barcodes_fp, "w") as f:
            f.write("\n")
        self._clean_up_files = []

        # Create a new study
        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)
        }
        Study.create(User("[email protected]"), "Test study 2", [1], info)
开发者ID:zonca,项目名称:qiita,代码行数:36,代码来源:test_data.py

示例5: test_create_nonqiita_portal

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import create [as 别名]
    def test_create_nonqiita_portal(self):
        qiita_config.portal = "EMP"
        Study.create(User("[email protected]"), "NEW!", [1], self.info, Investigation(1))

        # make sure portal is associated
        obs = self.conn_handler.execute_fetchall("SELECT * from qiita.study_portal WHERE study_id = 2")
        self.assertEqual(obs, [[2, 2], [2, 1]])
开发者ID:DarcyMyers,项目名称:qiita,代码行数:9,代码来源:test_study.py

示例6: test_build_study_info_new_study

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import create [as 别名]
    def test_build_study_info_new_study(self):
        info = {
            'timeseries_type_id': 1,
            'lab_person_id': None,
            'principal_investigator_id': 3,
            'metadata_complete': False,
            'mixs_compliant': True,
            'study_description': 'desc',
            'study_alias': 'alias',
            'study_abstract': 'abstract'}
        user = User('[email protected]')

        Study.create(user, 'test_study_1', efo=[1], info=info)
        obs = _build_study_info(user)
        self.exp.append({
            'study_id': 2,
            'status': 'sandbox',
            'study_abstract': 'abstract',
            'metadata_complete': False,
            'study_title': 'test_study_1',
            'num_raw_data': 0,
            'number_samples_collected': 0,
            'shared': '',
            'pmid': '',
            'publication_doi': '',
            'pi':
                '<a target="_blank" href="mailto:[email protected]">PIDude</a>',
            'proc_data_info': []})
        self.assertEqual(obs, self.exp)
开发者ID:mivamo1214,项目名称:qiita,代码行数:31,代码来源:test_study_handlers.py

示例7: test_remove_portal

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import create [as 别名]
    def test_remove_portal(self):
        Portal.create("NEWPORTAL", "SOMEDESC")
        # Select some samples on a default analysis
        qiita_config.portal = "NEWPORTAL"
        a = Analysis(User("[email protected]").default_analysis)
        a.add_samples({1: ['1.SKB8.640193', '1.SKD5.640186']})

        Portal.delete("NEWPORTAL")
        obs = self.conn_handler.execute_fetchall(
            "SELECT * FROM qiita.portal_type")
        exp = [[1, 'QIITA', 'QIITA portal. Access to all data stored '
                'in database.'],
               [2, 'EMP', 'EMP portal']]
        self.assertItemsEqual(obs, exp)

        obs = self.conn_handler.execute_fetchall(
            "SELECT * FROM qiita.analysis_portal")
        exp = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 2], [8, 2],
               [9, 2], [10, 2]]
        self.assertItemsEqual(obs, exp)

        with self.assertRaises(QiitaDBLookupError):
            Portal.delete("NOEXISTPORTAL")
        with self.assertRaises(QiitaDBError):
            Portal.delete("QIITA")

        Portal.create("NEWPORTAL2", "SOMEDESC")
        # Add analysis to this new portal and make sure error raised
        qiita_config.portal = "NEWPORTAL2"
        Analysis.create(User("[email protected]"), "newportal analysis", "desc")
        qiita_config.portal = "QIITA"
        with self.assertRaises(QiitaDBError):
            Portal.delete("NEWPORTAL2")

        # Add study to this new portal and make sure error raised
        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)
        }
        Portal.create("NEWPORTAL3", "SOMEDESC")
        qiita_config.portal = "NEWPORTAL3"
        Study.create(User('[email protected]'), "Fried chicken microbiome",
                     [1], info)
        qiita_config.portal = "QIITA"
        with self.assertRaises(QiitaDBError):
            Portal.delete("NEWPORTAL3")
开发者ID:adamrp,项目名称:qiita,代码行数:59,代码来源:test_portal.py

示例8: test_create_sample_template

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import create [as 别名]
    def test_create_sample_template(self):
        # Test error
        job = self._create_job('create_sample_template', {
            'fp': self.fp, 'study_id': 1, 'is_mapping_file': False,
            'data_type': None})
        private_task(job.id)
        self.assertEqual(job.status, 'error')
        self.assertIn("The 'SampleTemplate' object with attributes (id: 1) "
                      "already exists.", job.log.msg)

        # Test success with a warning
        info = {"timeseries_type_id": '1',
                "metadata_complete": 'true',
                "mixs_compliant": 'true',
                "study_alias": "TDST",
                "study_description": "Test create sample template",
                "study_abstract": "Test create sample template",
                "principal_investigator_id": StudyPerson(1)}
        study = Study.create(User('[email protected]'),
                             "Create Sample Template test", info)
        job = self._create_job('create_sample_template',
                               {'fp': self.fp, 'study_id': study.id,
                                'is_mapping_file': False, 'data_type': None})
        private_task(job.id)
        self.assertEqual(job.status, 'success')
        obs = r_client.get("sample_template_%d" % study.id)
        self.assertIsNotNone(obs)
        obs = loads(obs)
        self.assertCountEqual(obs, ['job_id', 'alert_type', 'alert_msg'])
        self.assertEqual(obs['job_id'], job.id)
        self.assertEqual(obs['alert_type'], 'warning')
        self.assertIn(
            'Some functionality will be disabled due to missing columns:',
            obs['alert_msg'])
开发者ID:antgonza,项目名称:qiita,代码行数:36,代码来源:test_private_plugin.py

示例9: test_get_no_samples

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import create [as 别名]
    def test_get_no_samples(self):
        # /api/v1/study/%d/samples/info -> {'number-of-samples':<int>,
                                        #   'categories': [<str>]}
        info = {
            "timeseries_type_id": 1,
            "metadata_complete": True,
            "mixs_compliant": True,
            "number_samples_collected": 25,
            "number_samples_promised": 28,
            "study_alias": "FCM",
            "study_description": "DESC",
            "study_abstract": "ABS",
            "principal_investigator_id": StudyPerson(3),
            'first_contact': datetime(2015, 5, 19, 16, 10),
            'most_recent_contact': datetime(2015, 5, 19, 16, 11),
        }

        new_study = Study.create(User('[email protected]'),
                                 "Some New Study for test", info)

        exp = {'message': 'Study does not have sample information'}
        response = self.get('/api/v1/study/%d/samples/categories=foo' %
                            new_study.id, headers=self.headers)
        self.assertEqual(response.code, 404)
        obs = json_decode(response.body)
        self.assertEqual(obs, exp)
开发者ID:ElDeveloper,项目名称:qiita,代码行数:28,代码来源:test_study_samples.py

示例10: setUp

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import create [as 别名]
    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('[email protected]'), "Test study", [1], info)

        # Get the directory where the preprocessed data is usually copied.
        _, self.db_ppd_dir = get_mountpoint('preprocessed_data')[0]
开发者ID:MarkBruns,项目名称:qiita,代码行数:62,代码来源:test_commands.py

示例11: test_set_info_disallowed_keys

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import create [as 别名]
 def test_set_info_disallowed_keys(self):
     """Tests for fail if sending non-info keys in info dict"""
     new = Study.create(
         User("[email protected]"), "NOT Identification of the " "Microbiomes for Cannabis Soils", [1], self.info
     )
     with self.assertRaises(QiitaDBColumnError):
         new.info = {"email": "[email protected]"}
开发者ID:DarcyMyers,项目名称:qiita,代码行数:9,代码来源:test_study.py

示例12: test_set_efo_empty

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import create [as 别名]
 def test_set_efo_empty(self):
     """Set efo with list efo_id"""
     new = Study.create(
         User("[email protected]"), "NOT Identification of the " "Microbiomes for Cannabis Soils", [1], self.info
     )
     with self.assertRaises(IncompetentQiitaDeveloperError):
         new.efo = []
开发者ID:DarcyMyers,项目名称:qiita,代码行数:9,代码来源:test_study.py

示例13: test_set_efo

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import create [as 别名]
 def test_set_efo(self):
     """Set efo with list efo_id"""
     new = Study.create(
         User("[email protected]"), "NOT Identification of the " "Microbiomes for Cannabis Soils", [1], self.info
     )
     new.efo = [3, 4]
     self.assertEqual(new.efo, [3, 4])
开发者ID:DarcyMyers,项目名称:qiita,代码行数:9,代码来源:test_study.py

示例14: test_create_study_with_investigation

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import create [as 别名]
 def test_create_study_with_investigation(self):
     """Insert a study into the database with an investigation"""
     obs = Study.create(User("[email protected]"), "Fried chicken microbiome", [1], self.info, Investigation(1))
     self.assertEqual(obs.id, 2)
     # check the investigation was assigned
     obs = self.conn_handler.execute_fetchall("SELECT * from qiita.investigation_study WHERE study_id = 2")
     self.assertEqual(obs, [[1, 2]])
开发者ID:DarcyMyers,项目名称:qiita,代码行数:9,代码来源:test_study.py

示例15: test_create_study_min_data

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import create [as 别名]
    def test_create_study_min_data(self):
        """Insert a study into the database"""
        obs = Study.create(User('[email protected]'), "Fried chicken microbiome",
                           [1], self.info)
        self.assertEqual(obs.id, 2)
        exp = {'mixs_compliant': True, 'metadata_complete': True,
               'reprocess': False, 'study_status_id': 1,
               'number_samples_promised': 28, 'emp_person_id': 2,
               'funding': None, 'vamps_id': None,
               'first_contact': date.today().isoformat(),
               'principal_investigator_id': 3,
               'timeseries_type_id': 1,
               'study_abstract': 'Exploring how a high fat diet changes the '
                                 'gut microbiome',
               'email': '[email protected]', 'spatial_series': None,
               'study_description': 'Microbiome of people who eat nothing but'
                                    ' fried chicken',
               'portal_type_id': 3, 'study_alias': 'FCM', 'study_id': 2,
               'most_recent_contact': None, 'lab_person_id': 1,
               'study_title': 'Fried chicken microbiome',
               'number_samples_collected': 25}

        obsins = self.conn_handler.execute_fetchall(
            "SELECT * FROM qiita.study WHERE study_id = 2")
        self.assertEqual(len(obsins), 1)
        obsins = dict(obsins[0])
        self.assertEqual(obsins, exp)

        # make sure EFO went in to table correctly
        efo = self.conn_handler.execute_fetchall(
            "SELECT efo_id FROM qiita.study_experimental_factor "
            "WHERE study_id = 2")
        self.assertEqual(efo, [[1]])
开发者ID:Jorge-C,项目名称:qiita,代码行数:35,代码来源:test_study.py


注:本文中的qiita_db.study.Study.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。