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


Python Study.raw_data方法代码示例

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


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

示例1: _build_study_info

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import raw_data [as 别名]
def _build_study_info(studytype, user=None):
    """builds list of namedtuples for study listings"""
    if studytype == "private":
        studylist = user.user_studies
    elif studytype == "shared":
        studylist = user.shared_studies
    elif studytype == "public":
        studylist = Study.get_by_status('public')
    else:
        raise IncompetentQiitaDeveloperError("Must use private, shared, "
                                             "or public!")

    StudyTuple = namedtuple('StudyInfo', 'id title meta_complete '
                            'num_samples_collected shared num_raw_data pi '
                            'pmids owner status')

    infolist = []
    for s_id in studylist:
        study = Study(s_id)
        status = study.status
        # Just passing the email address as the name here, since
        # name is not a required field in qiita.qiita_user
        owner = study_person_linkifier((study.owner, study.owner))
        info = study.info
        PI = StudyPerson(info['principal_investigator_id'])
        PI = study_person_linkifier((PI.email, PI.name))
        pmids = ", ".join([pubmed_linkifier([pmid])
                           for pmid in study.pmids])
        shared = _get_shared_links_for_study(study)
        infolist.append(StudyTuple(study.id, study.title,
                                   info["metadata_complete"],
                                   info["number_samples_collected"],
                                   shared, len(study.raw_data()),
                                   PI, pmids, owner, status))
    return infolist
开发者ID:jwdebelius,项目名称:qiita,代码行数:37,代码来源:listing_handlers.py

示例2: _get_accessible_raw_data

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import raw_data [as 别名]
def _get_accessible_raw_data(user):
    """Retrieves a tuple of raw_data_id and one study title for that
    raw_data
    """
    d = {}
    accessible_studies = user.user_studies.union(user.shared_studies)
    for sid in accessible_studies:
        study = Study(sid)
        study_title = study.title
        for rdid in study.raw_data():
            d[int(rdid)] = study_title
    return d
开发者ID:MarkBruns,项目名称:qiita,代码行数:14,代码来源:prep_template_tab.py

示例3: TestStudy

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import raw_data [as 别名]

#.........这里部分代码省略.........
        self.assertEqual(new.pmids, [])

    def test_pmids_setter(self):
        exp = ['123456', '7891011']
        self.assertEqual(self.study.pmids, exp)

        new_values = ['654321', '1101987']
        self.study.pmids = new_values
        self.assertEqual(self.study.pmids, new_values)

    def test_pmids_setter_typeerror(self):
        with self.assertRaises(TypeError):
            self.study.pmids = '123456'

    def test_retrieve_investigation(self):
        self.assertEqual(self.study.investigation, 1)

    def test_retrieve_investigation_empty(self):
        new = Study.create(User('[email protected]'), 'NOT Identification of the '
                           'Microbiomes for Cannabis Soils', [1], self.info)
        self.assertEqual(new.investigation, None)

    def test_retrieve_sample_template(self):
        self.assertEqual(self.study.sample_template, 1)

    def test_retrieve_data_types(self):
        self.assertEqual(self.study.data_types, ['18S'])

    def test_retrieve_data_types_none(self):
        new = Study.create(User('[email protected]'), 'NOT Identification of the '
                           'Microbiomes for Cannabis Soils', [1], self.info)
        self.assertEqual(new.data_types, [])

    def test_retrieve_raw_data(self):
        self.assertEqual(self.study.raw_data(), [1])

    def test_retrieve_raw_data_none(self):
        new = Study.create(User('[email protected]'), 'NOT Identification of the '
                           'Microbiomes for Cannabis Soils', [1], self.info)
        self.assertEqual(new.raw_data(), [])

    def test_retrieve_prep_templates(self):
        self.assertEqual(self.study.prep_templates(), [1])

    def test_retrieve_prep_templates_none(self):
        new = Study.create(User('[email protected]'), 'NOT Identification of the '
                           'Microbiomes for Cannabis Soils', [1], self.info)
        self.assertEqual(new.prep_templates(), [])

    def test_retrieve_preprocessed_data(self):
        self.assertEqual(self.study.preprocessed_data(), [1, 2])

    def test_retrieve_preprocessed_data_none(self):
        new = Study.create(User('[email protected]'), 'NOT Identification of the '
                           'Microbiomes for Cannabis Soils', [1], self.info)
        self.assertEqual(new.preprocessed_data(), [])

    def test_retrieve_processed_data(self):
        self.assertEqual(self.study.processed_data(), [1])

    def test_retrieve_processed_data_none(self):
        new = Study.create(User('[email protected]'), 'NOT Identification of the '
                           'Microbiomes for Cannabis Soils', [1], self.info)
        self.assertEqual(new.processed_data(), [])

    def test_add_pmid(self):
开发者ID:MarkBruns,项目名称:qiita,代码行数:70,代码来源:test_study.py

示例4: TestStudy

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import raw_data [as 别名]

#.........这里部分代码省略.........
        }
        new = Study.create(User('[email protected]'), 'NOT Identification of the '
                           'Microbiomes for Cannabis Soils', [1], self.info)
        self.infoexp.update(newinfo)
        new.info = newinfo
        # add missing table cols
        self.infoexp["funding"] = None
        self.infoexp["spatial_series"] = None
        self.infoexp["most_recent_contact"] = None
        self.infoexp["reprocess"] = False
        self.infoexp["lab_person_id"] = 2
        self.assertEqual(new.info, self.infoexp)

    def test_set_info_public(self):
        """Tests for fail if editing info of a public study"""
        with self.assertRaises(QiitaDBStatusError):
            self.study.info = {"vamps_id": "12321312"}

    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]"}

    def test_info_empty(self):
        new = Study.create(User('[email protected]'), 'NOT Identification of the '
                           'Microbiomes for Cannabis Soils', [1], self.info)
        with self.assertRaises(IncompetentQiitaDeveloperError):
            new.info = {}

    def test_retrieve_status(self):
        self.assertEqual(self.study.status, "public")

    def test_set_status(self):
        new = Study.create(User('[email protected]'), 'NOT Identification of the '
                           'Microbiomes for Cannabis Soils', [1], self.info)
        new.status = "private"
        self.assertEqual(new.status, "private")

    def test_retrieve_shared_with(self):
        self.assertEqual(self.study.shared_with, ['[email protected]',
                         '[email protected]'])

    def test_retrieve_pmids(self):
        exp = ['123456', '7891011']
        self.assertEqual(self.study.pmids, exp)

    def test_retrieve_pmids_empty(self):
        new = Study.create(User('[email protected]'), 'NOT Identification of the '
                           'Microbiomes for Cannabis Soils', [1], self.info)
        self.assertEqual(new.pmids, [])

    def test_retrieve_investigation(self):
        self.assertEqual(self.study.investigation, 1)

    def test_retrieve_investigation_empty(self):
        new = Study.create(User('[email protected]'), 'NOT Identification of the '
                           'Microbiomes for Cannabis Soils', [1], self.info)
        self.assertEqual(new.investigation, None)

    def test_retrieve_sample_template(self):
        self.assertEqual(self.study.sample_template, 1)

    def test_retrieve_data_types(self):
        self.assertEqual(self.study.data_types, ['18S'])

    def test_retrieve_data_types_none(self):
        new = Study.create(User('[email protected]'), 'NOT Identification of the '
                           'Microbiomes for Cannabis Soils', [1], self.info)
        self.assertEqual(new.data_types, [])

    def test_retrieve_raw_data(self):
        self.assertEqual(self.study.raw_data(), [1, 2])

    def test_retrieve_raw_data_none(self):
        new = Study.create(User('[email protected]'), 'NOT Identification of the '
                           'Microbiomes for Cannabis Soils', [1], self.info)
        self.assertEqual(new.raw_data(), [])

    def test_retrieve_preprocessed_data(self):
        self.assertEqual(self.study.preprocessed_data(), [1, 2])

    def test_retrieve_preprocessed_data_none(self):
        new = Study.create(User('[email protected]'), 'NOT Identification of the '
                           'Microbiomes for Cannabis Soils', [1], self.info)
        self.assertEqual(new.preprocessed_data(), [])

    def test_retrieve_processed_data(self):
        self.assertEqual(self.study.processed_data(), [1])

    def test_retrieve_processed_data_none(self):
        new = Study.create(User('[email protected]'), 'NOT Identification of the '
                           'Microbiomes for Cannabis Soils', [1], self.info)
        self.assertEqual(new.processed_data(), [])

    def test_add_pmid(self):
        self.study.add_pmid('4544444')
        exp = ['123456', '7891011', '4544444']
        self.assertEqual(self.study.pmids, exp)
开发者ID:Jorge-C,项目名称:qiita,代码行数:104,代码来源:test_study.py

示例5: _build_study_info

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import raw_data [as 别名]
def _build_study_info(user, results=None):
    """builds list of dicts for studies table, with all html formatted"""
    # get list of studies for table
    study_list = user.user_studies.union(
        Study.get_by_status('public')).union(user.shared_studies)
    if results is not None:
        study_list = study_list.intersection(results)
    if not study_list:
        # No studies left so no need to continue
        return []

    # get info for the studies
    cols = ['study_id', 'email', 'principal_investigator_id',
            'pmid', 'study_title', 'metadata_complete',
            'number_samples_collected', 'study_abstract']
    study_info = Study.get_info(study_list, cols)

    infolist = []
    for row, info in enumerate(study_info):
        study = Study(info['study_id'])
        status = study.status
        # Just passing the email address as the name here, since
        # name is not a required field in qiita.qiita_user
        PI = StudyPerson(info['principal_investigator_id'])
        PI = study_person_linkifier((PI.email, PI.name))
        if info['pmid'] is not None:
            pmids = ", ".join([pubmed_linkifier([p])
                               for p in info['pmid']])
        else:
            pmids = ""
        if info["number_samples_collected"] is None:
            info["number_samples_collected"] = "0"
        shared = _get_shared_links_for_study(study)
        meta_complete_glyph = "ok" if info["metadata_complete"] else "remove"
        # build the HTML elements needed for table cell
        title = ("<a href='#' data-toggle='modal' "
                 "data-target='#study-abstract-modal' "
                 "onclick='fillAbstract(\"studies-table\", {0})'>"
                 "<span class='glyphicon glyphicon-file' "
                 "aria-hidden='true'></span></a> | "
                 "<a href='/study/description/{1}' "
                 "id='study{0}-title'>{2}</a>").format(
                     str(row), str(study.id), info["study_title"])
        meta_complete = "<span class='glyphicon glyphicon-%s'></span>" % \
            meta_complete_glyph
        if status == 'public':
            shared = "Not Available"
        else:
            shared = ("<span id='shared_html_{0}'>{1}</span><br/>"
                      "<a class='btn btn-primary btn-xs' data-toggle='modal' "
                      "data-target='#share-study-modal-view' "
                      "onclick='modify_sharing({0});'>Modify</a>".format(
                          study.id, shared))

        infolist.append({
            "checkbox": "<input type='checkbox' value='%d' />" % study.id,
            "id": study.id,
            "title": title,
            "meta_complete": meta_complete,
            "num_samples": info["number_samples_collected"],
            "shared": shared,
            "num_raw_data": len(study.raw_data()),
            "pi": PI,
            "pmid": pmids,
            "status": status,
            "abstract": info["study_abstract"]

        })
    return infolist
开发者ID:zonca,项目名称:qiita,代码行数:71,代码来源:listing_handlers.py

示例6: TestUpdateRawDataFromCmd

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import raw_data [as 别名]
class TestUpdateRawDataFromCmd(TestCase):
    def setUp(self):
        fd, seqs_fp = mkstemp(suffix='_seqs.fastq')
        close(fd)
        fd, barcodes_fp = mkstemp(suffix='_barcodes.fastq')
        close(fd)
        self.filepaths = [seqs_fp, barcodes_fp]
        self.checksums = []
        for fp in sorted(self.filepaths):
            with open(fp, 'w') as f:
                f.write("%s\n" % fp)
            self.checksums.append(compute_checksum(fp))
        self.filepaths_types = ["raw_forward_seqs", "raw_barcodes"]
        self._clean_up_files = [seqs_fp, barcodes_fp]

        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.new_study = Study.create(User("[email protected]"),
                                      "Update raw data test",
                                      efo=[1], info=info)
        self.study = Study(1)
        # The files for the RawData object attached to study 1 does not exist.
        # Create them so we can actually perform the tests
        for _, fp, _ in RawData(1).get_filepaths():
            with open(fp, 'w') as f:
                f.write('\n')
            self._clean_up_files.append(fp)

        self.uploaded_files = get_files_from_uploads_folders(
            str(self.study.id))

    def tearDown(self):
        new_uploaded_files = get_files_from_uploads_folders(str(self.study.id))
        new_files = set(new_uploaded_files).difference(self.uploaded_files)
        path_builder = partial(join, get_mountpoint("uploads")[0][1], '1')
        for _, fp in new_files:
            self._clean_up_files.append(path_builder(fp))
        for f in self._clean_up_files:
            if exists(f):
                remove(f)

    def test_update_raw_data_from_cmd_diff_length(self):
        with self.assertRaises(ValueError):
            update_raw_data_from_cmd(self.filepaths[1:], self.filepaths_types,
                                     self.study.id)
        with self.assertRaises(ValueError):
            update_raw_data_from_cmd(self.filepaths, self.filepaths_types[1:],
                                     self.study.id)

    def test_update_raw_data_from_cmd_no_raw_data(self):
        with self.assertRaises(ValueError):
            update_raw_data_from_cmd(self.filepaths, self.filepaths_types,
                                     self.new_study.id)

    def test_update_raw_data_from_cmd_wrong_raw_data_id(self):
        # Using max(raw_data_ids) + 1 to make sure that the raw data id
        # passed does not belong to the study
        with self.assertRaises(ValueError):
            update_raw_data_from_cmd(self.filepaths, self.filepaths_types,
                                     self.study.id,
                                     max(self.study.raw_data()) + 1)

    def test_update_raw_data_from_cmd(self):
        rd = update_raw_data_from_cmd(self.filepaths, self.filepaths_types,
                                      self.study.id)
        # Make sure that we are cleaning the environment
        for _, fp, _ in rd.get_filepaths():
            self._clean_up_files.append(fp)

        # The checkums are in filepath order. If we sort the rd.get_filepath()
        # result by the filepath (itemgetter(1)) we will get them in the same
        # order, so the checksums will not fail
        for obs, exp in zip(sorted(rd.get_filepaths(), key=itemgetter(1)),
                            self.checksums):
            self.assertEqual(compute_checksum(obs[1]), exp)

    def test_update_raw_data_from_cmd_rd_id(self):
        rd = update_raw_data_from_cmd(self.filepaths, self.filepaths_types,
                                      self.study.id, self.study.raw_data()[0])
        # Make sure that we are cleaning the environment
        for _, fp, _ in rd.get_filepaths():
            self._clean_up_files.append(fp)

        # The checkums are in filepath order. If we sort the rd.get_filepath()
        # result by the filepath (itemgetter(1)) we will get them in the same
        # order, so the checksums will not fail
        for obs, exp in zip(sorted(rd.get_filepaths(), key=itemgetter(1)),
#.........这里部分代码省略.........
开发者ID:jenwei,项目名称:qiita,代码行数:103,代码来源:test_commands.py


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