• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python data.ProcessedData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中qiita_db.data.ProcessedData的典型用法代码示例。如果您正苦于以下问题:Python ProcessedData类的具体用法?Python ProcessedData怎么用?Python ProcessedData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: test_status_setter_error

    def test_status_setter_error(self):
        pd = ProcessedData(1)
        pd.status = 'public'
        self.assertEqual(pd.status, 'public')

        with self.assertRaises(QiitaDBStatusError):
            pd.status = 'sandbox'
开发者ID:zonca,项目名称:qiita,代码行数:7,代码来源:test_data.py


示例2: get

    def get(self, analysis_id):
        analysis_id = int(analysis_id.split("/")[0])
        analysis = Analysis(analysis_id)
        check_analysis_access(self.current_user, analysis)

        jobres = defaultdict(list)
        for job in analysis.jobs:
            jobject = Job(job)
            jobres[jobject.datatype].append((jobject.command[0],
                                             jobject.results))

        dropped_samples = analysis.dropped_samples
        dropped = defaultdict(list)
        for proc_data_id, samples in viewitems(dropped_samples):
            if not samples:
                continue
            proc_data = ProcessedData(proc_data_id)
            data_type = proc_data.data_type()
            study = proc_data.study
            dropped[data_type].append((Study(study).title, len(samples),
                                       ', '.join(samples)))

        self.render("analysis_results.html", analysis_id=analysis_id,
                    jobres=jobres, aname=analysis.name, dropped=dropped,
                    basefolder=get_db_files_base_dir())
开发者ID:DarcyMyers,项目名称:qiita,代码行数:25,代码来源:analysis_handlers.py


示例3: delete_processed_data

    def delete_processed_data(self, study, user, callback):
        """Delete the selected processed data

        Parameters
        ----------
        study : Study
            The current study object
        user : User
            The current user object
        callback : function
            The callback function to call with the results once the processing
            is done
        """
        pd_id = int(self.get_argument('processed_data_id'))

        try:
            ProcessedData.delete(pd_id)
            msg = ("Processed data %d has been deleted" % pd_id)
            msg_level = "success"
            pd_id = None
        except Exception as e:
            msg = ("Couldn't remove processed data %d: %s" %
                   (pd_id, str(e)))
            msg_level = "danger"

        callback((msg, msg_level, 'processed_data_tab', pd_id, None))
开发者ID:adamrp,项目名称:qiita,代码行数:26,代码来源:description_handlers.py


示例4: post

    def post(self, analysis_id):
        command_args = self.get_arguments("commands")
        split = [x.split("#") for x in command_args]
        analysis = Analysis(analysis_id)

        commands = []
        # HARD CODED HACKY THING FOR DEMO, FIX  Issue #164
        fp, mapping_file = mkstemp(suffix="_map_file.txt")
        close(fp)
        SampleTemplate(1).to_file(mapping_file)
        study_fps = {}
        for pd in Study(1).processed_data:
            processed = ProcessedData(pd)
            study_fps[processed.data_type] = processed.get_filepaths()[0][0]
        for data_type, command in split:
            opts = {
                "--otu_table_fp": study_fps[data_type],
                "--mapping_fp": mapping_file
            }
            if command == "Beta Diversity" and data_type in {'16S', '18S'}:
                opts["--tree_fp"] = join(get_db_files_base_dir(), "reference",
                                         "gg_97_otus_4feb2011.tre")
            elif command == "Beta Diversity":
                opts["--parameter_fp"] = join(get_db_files_base_dir(),
                                              "reference", "params_qiime.txt")
            Job.create(data_type, command, opts, analysis)
            commands.append("%s: %s" % (data_type, command))
        user = self.get_current_user()
        self.render("analysis_waiting.html", user=user,
                    aid=analysis_id, aname=analysis.name,
                    commands=commands)
        # fire off analysis run here
        # currently synch run so redirect done here. Will remove after demo
        run_analysis(user, analysis)
开发者ID:teravest,项目名称:qiita,代码行数:34,代码来源:analysis_handlers.py


示例5: get

    def get(self, analysis_id):
        user = self.current_user
        analysis_id = int(analysis_id)
        check_analysis_access(User(user), analysis_id)

        analysis = Analysis(analysis_id)
        jobres = defaultdict(list)
        for job in analysis.jobs:
            jobject = Job(job)
            jobres[jobject.datatype].append((jobject.command[0],
                                             jobject.results))

        dropped = {}
        for proc_data_id, samples in viewitems(analysis.dropped_samples):
            proc_data = ProcessedData(proc_data_id)
            key = "Data type %s, Study: %s" % (proc_data.data_type(),
                                               proc_data.study)
            dropped[key] = samples

        self.render("analysis_results.html", user=self.current_user,
                    jobres=jobres, aname=analysis.name, dropped=dropped,
                    basefolder=get_db_files_base_dir())

        # wipe out cached messages for this analysis
        r_server = Redis()
        key = '%s:messages' % self.current_user
        oldmessages = r_server.lrange(key, 0, -1)
        if oldmessages is not None:
            for message in oldmessages:
                if '"analysis": %d' % analysis_id in message:
                    r_server.lrem(key, message, 1)
开发者ID:Jorge-C,项目名称:qiita,代码行数:31,代码来源:analysis_handlers.py


示例6: test_get_filepath

 def test_get_filepath(self):
     """Correctly returns the filepaths to the processed files"""
     # check the test data
     pd = ProcessedData(1)
     obs = pd.get_filepaths()
     exp = [(11, join(self.db_test_pd_dir,
             '1_study_1001_closed_reference_otu_table.biom'), "biom")]
     self.assertEqual(obs, exp)
开发者ID:BrindhaBioinfo,项目名称:qiita,代码行数:8,代码来源:test_data.py


示例7: test_get_by_status_grouped_by_study

    def test_get_by_status_grouped_by_study(self):
        obs = ProcessedData.get_by_status_grouped_by_study('sandbox')
        self.assertEqual(obs, dict())

        obs = ProcessedData.get_by_status_grouped_by_study('private')
        self.assertEqual(obs, {1: [1]})

        ProcessedData.create(self.params_table, self.params_id,
                             self.filepaths,
                             preprocessed_data=self.preprocessed_data)
        obs = ProcessedData.get_by_status_grouped_by_study('sandbox')
        self.assertEqual(obs, {1: [2]})
开发者ID:zonca,项目名称:qiita,代码行数:12,代码来源:test_data.py


示例8: filter_by_processed_data

    def filter_by_processed_data(self, datatypes=None):
        """Filters results to what is available in each processed data

        Parameters
        ----------
        datatypes : list of str, optional
            Datatypes to selectively return. Default all datatypes available

        Returns
        -------
        study_proc_ids : dict of dicts of lists
            Processed data ids with samples for each study, in the format
            {study_id: {datatype: [proc_id, proc_id, ...], ...}, ...}
        proc_data_samples : dict of lists
            Samples available in each processed data id, in the format
            {proc_data_id: [samp_id1, samp_id2, ...], ...}
        samples_meta : dict of pandas DataFrames
            metadata for the found samples, keyed by study. Pandas indexed on
            sample_id, column headers are the metadata categories searched
            over
        """
        with TRN:
            if datatypes is not None:
                # convert to set for easy lookups
                datatypes = set(datatypes)
            study_proc_ids = {}
            proc_data_samples = {}
            samples_meta = {}
            headers = {c: val for c, val in enumerate(self.meta_headers)}
            for study_id, study_meta in viewitems(self.results):
                # add metadata to dataframe and dict
                # use from_dict because pandas doesn't like cursor objects
                samples_meta[study_id] = pd.DataFrame.from_dict(
                    {s[0]: s[1:] for s in study_meta}, orient='index')
                samples_meta[study_id].rename(columns=headers, inplace=True)
                # set up study-based data needed
                study = Study(study_id)
                study_sample_ids = {s[0] for s in study_meta}
                study_proc_ids[study_id] = defaultdict(list)
                for proc_data_id in study.processed_data():
                    proc_data = ProcessedData(proc_data_id)
                    datatype = proc_data.data_type()
                    # skip processed data if it doesn't fit the given datatypes
                    if datatypes is not None and datatype not in datatypes:
                        continue
                    filter_samps = proc_data.samples.intersection(
                        study_sample_ids)
                    if filter_samps:
                        proc_data_samples[proc_data_id] = sorted(filter_samps)
                        study_proc_ids[study_id][datatype].append(proc_data_id)

            return study_proc_ids, proc_data_samples, samples_meta
开发者ID:adamrp,项目名称:qiita,代码行数:52,代码来源:search.py


示例9: _insert_processed_data_target_gene

def _insert_processed_data_target_gene(preprocessed_data, params,
                                       pick_otus_out, **kwargs):
    """Inserts the preprocessed data to the database

    Parameters
    ----------
    preprocessed_data : PreprocessedData
        The preprocessed_data to process
    params : ProcessedSortmernaParams
        The parameters to use for the processing
    pick_otus_out : str
        Path to the pick_closed_reference_otus.py output directory
    kwargs: ignored
        Necessary to include to support execution via moi.

    Raises
    ------
    ValueError
        If the processed output directory does not contain all the expected
        files
    """
    from os.path import exists, join, isdir
    from glob import glob
    from functools import partial
    from qiita_db.data import ProcessedData

    # The filepaths that we are interested in are:
    #   1) otu_table.biom -> the output OTU table
    #   2) sortmerna_picked_otus -> intermediate output of pick_otus.py
    #   3) log_20141217091339.log -> log file

    path_builder = partial(join, pick_otus_out)
    biom_fp = path_builder('otu_table.biom')
    otus_dp = path_builder('sortmerna_picked_otus')
    log_fp = glob(path_builder('log_*.txt'))[0]

    # Check that all the files exist
    if not (exists(biom_fp) and isdir(otus_dp) and exists(log_fp)):
        raise ValueError("The output directory %s does not contain all the "
                         "expected files." % pick_otus_out)

    filepaths = [(biom_fp, "biom"),
                 (otus_dp, "directory"),
                 (log_fp, "log")]

    ProcessedData.create(params._table, params.id, filepaths,
                         preprocessed_data=preprocessed_data)

    # Change the preprocessed_data status to processed
    preprocessed_data.processing_status = 'processed'
开发者ID:jwdebelius,项目名称:qiita,代码行数:50,代码来源:processing_pipeline.py


示例10: test_status

    def test_status(self):
        rd = RawData(1)
        s = Study(1)
        self.assertEqual(rd.status(s), 'private')

        # Since the status is inferred from the processed data, change the
        # status of the processed data so we can check how it changes in the
        # preprocessed data
        pd = ProcessedData(1)
        pd.status = 'public'
        self.assertEqual(rd.status(s), 'public')

        # Check that new raw data has sandbox as status since no
        # processed data exists for them
        rd = RawData.create(self.filetype, self.studies, self.filepaths)
        self.assertEqual(rd.status(s), 'sandbox')
开发者ID:zonca,项目名称:qiita,代码行数:16,代码来源:test_data.py


示例11: test_create_no_date

    def test_create_no_date(self):
        """Correctly adds a processed data with no date on it"""
        # All the other settings have been already tested on test_create
        # here we will only check that the code added a good date
        before = datetime.now()
        ProcessedData.create(self.params_table, self.params_id, self.filepaths,
                             preprocessed_data=self.preprocessed_data)
        after = datetime.now()
        obs = self.conn_handler.execute_fetchone(
            "SELECT processed_date FROM qiita.processed_data WHERE "
            "processed_data_id=2")[0]

        # Make sure that we clean up the environment
        exp_biom_fp = join(self.db_test_pd_dir,
                           "2_%s" % basename(self.biom_fp))
        self._clean_up_files.append(exp_biom_fp)

        self.assertTrue(before <= obs <= after)
开发者ID:BrindhaBioinfo,项目名称:qiita,代码行数:18,代码来源:test_data.py


示例12: test_create

    def test_create(self):
        """Correctly creates all the rows in the DB for the processed data"""
        # Check that the returned object has the correct id
        obs = ProcessedData.create(self.params_table, self.params_id,
                                   self.filepaths,
                                   preprocessed_data=self.preprocessed_data,
                                   processed_date=self.date)
        self.assertEqual(obs.id, 2)

        # Check that the processed data have been correctly added to the DB
        obs = self.conn_handler.execute_fetchall(
            "SELECT * FROM qiita.processed_data WHERE processed_data_id=2")
        # processed_data_id, processed_params_table, processed_params_id,
        # processed_date, data_type_id, link_filepaths_status,
        # processed_data_status_id
        exp = [[2, "processed_params_uclust", 1, self.date, 2, 'idle', 4]]
        self.assertEqual(obs, exp)

        # Check that the files have been copied to right location
        exp_biom_fp = join(self.db_test_pd_dir,
                           "2_%s" % basename(self.biom_fp))
        self.assertTrue(exists(exp_biom_fp))
        self._clean_up_files.append(exp_biom_fp)

        # Check that the filepaths have been correctly added to the DB
        obs_id = self.conn_handler.execute_fetchone(
            "SELECT count(1) from qiita.filepath")[0]
        obs = self.conn_handler.execute_fetchall(
            "SELECT * FROM qiita.filepath WHERE filepath_id=%d" % obs_id)
        exp_biom_fp = "2_%s" % basename(self.biom_fp)
        # Filepath_id, path, filepath_type_id
        exp = [[obs_id, exp_biom_fp, 6, '852952723', 1, 4]]
        self.assertEqual(obs, exp)

        # Check that the processed data have been correctly linked
        # with the fileapths
        obs = self.conn_handler.execute_fetchall(
            "SELECT * FROM qiita.processed_filepath WHERE processed_data_id=2")
        # processed_data_id, filepath_id
        self.assertEqual(obs, [[2, obs_id]])

        # Check that the processed data have been correctly linked with the
        # study
        obs = self.conn_handler.execute_fetchall(
            "SELECT * FROM qiita.study_processed_data WHERE "
            "processed_data_id=2")
        # study_id, processed_data
        self.assertEqual(obs, [[1, 2]])

        # Check that the processed data have been correctly linked with the
        # preprocessed data
        obs = self.conn_handler.execute_fetchall(
            "SELECT * FROM qiita.preprocessed_processed_data WHERE "
            "processed_data_id=2")
        # preprocessed_data_id, processed_Data_id
        self.assertEqual(obs, [[1, 2]])
开发者ID:zonca,项目名称:qiita,代码行数:56,代码来源:test_data.py


示例13: request_approval

    def request_approval(self, study, user, callback):
        """Changes the status of the current study to "awaiting_approval"

        Parameters
        ----------
        study : Study
            The current study object
        user : User
            The current user object
        callback : function
            The callback function to call with the results once the processing
            is done
        """
        pd_id = int(self.get_argument('pd_id'))
        pd = ProcessedData(pd_id)
        pd.status = 'awaiting_approval'
        msg = "Processed data sent to admin for approval"
        msg_level = "success"
        callback((msg, msg_level, "processed_data_tab", pd_id, None))
开发者ID:adamrp,项目名称:qiita,代码行数:19,代码来源:description_handlers.py


示例14: make_sandbox

    def make_sandbox(self, study, user, callback):
        """Reverts the current study to the 'sandbox' status

        Parameters
        ----------
        study : Study
            The current study object
        user : User
            The current user object
        callback : function
            The callback function to call with the results once the processing
            is done
        """
        pd_id = int(self.get_argument('pd_id'))
        pd = ProcessedData(pd_id)
        pd.status = 'sandbox'
        msg = "Processed data reverted to sandbox"
        msg_level = "success"
        callback((msg, msg_level, "processed_data_tab", pd_id, None))
开发者ID:adamrp,项目名称:qiita,代码行数:19,代码来源:description_handlers.py


示例15: make_public

    def make_public(self, study, user, callback):
        """Makes the current study public

        Parameters
        ----------
        study : Study
            The current study object
        user : User
            The current user object
        callback : function
            The callback function to call with the results once the processing
            is done
        """
        pd_id = int(self.get_argument('pd_id'))
        pd = ProcessedData(pd_id)
        pd.status = 'public'
        msg = "Processed data set to public"
        msg_level = "success"
        callback((msg, msg_level, "processed_data_tab", pd_id, None))
开发者ID:adamrp,项目名称:qiita,代码行数:19,代码来源:description_handlers.py


示例16: test_link_filepaths_status_setter

 def test_link_filepaths_status_setter(self):
     pd = ProcessedData(1)
     self.assertEqual(pd.link_filepaths_status, 'idle')
     pd._set_link_filepaths_status('linking')
     self.assertEqual(pd.link_filepaths_status, 'linking')
     pd._set_link_filepaths_status('unlinking')
     self.assertEqual(pd.link_filepaths_status, 'unlinking')
     pd._set_link_filepaths_status('failed: error')
     self.assertEqual(pd.link_filepaths_status, 'failed: error')
开发者ID:BrindhaBioinfo,项目名称:qiita,代码行数:9,代码来源:test_data.py


示例17: get

    def get(self):
        user = self.current_user
        if user.level != 'admin':
            raise HTTPError(403, 'User %s is not admin' % self.current_user)

        result_generator = viewitems(
            ProcessedData.get_by_status_grouped_by_study('awaiting_approval'))
        study_generator = ((Study(sid), pds) for sid, pds in result_generator)
        parsed_studies = [(s.id, s.title, s.owner, pds)
                          for s, pds in study_generator]

        self.render('admin_approval.html',
                    study_info=parsed_studies)
开发者ID:DarcyMyers,项目名称:qiita,代码行数:13,代码来源:listing_handlers.py


示例18: get

    def get(self, analysis_id):
        user = self.current_user
        analysis_id = int(analysis_id.split("/")[0])
        analysis = Analysis(analysis_id)
        check_analysis_access(User(user), analysis)

        jobres = defaultdict(list)
        for job in analysis.jobs:
            jobject = Job(job)
            jobres[jobject.datatype].append((jobject.command[0],
                                             jobject.results))

        dropped = {}
        for proc_data_id, samples in viewitems(analysis.dropped_samples):
            proc_data = ProcessedData(proc_data_id)
            key = "Data type %s, Study: %s" % (proc_data.data_type(),
                                               proc_data.study)
            dropped[key] = samples

        self.render("analysis_results.html", user=self.current_user,
                    jobres=jobres, aname=analysis.name, dropped=dropped,
                    basefolder=get_db_files_base_dir())
开发者ID:BrindhaBioinfo,项目名称:qiita,代码行数:22,代码来源:analysis_handlers.py


示例19: approve_study

    def approve_study(self, study, user, callback):
        """Approves the current study if and only if the current user is admin

        Parameters
        ----------
        study : Study
            The current study object
        user : User
            The current user object
        callback : function
            The callback function to call with the results once the processing
            is done
        """
        if _approve(user.level):
            pd_id = int(self.get_argument("pd_id"))
            pd = ProcessedData(pd_id)
            pd.status = "private"
            msg = "Processed data approved"
            msg_level = "success"
        else:
            msg = "The current user does not have permission to approve " "the processed data"
            msg_level = "danger"
        callback((msg, msg_level, "processed_data_tab", pd_id, None))
开发者ID:DarcyMyers,项目名称:qiita,代码行数:23,代码来源:description_handlers.py


示例20: test_create_params_table_error

 def test_create_params_table_error(self):
     """Raises an error if the processed_params_table does not exist"""
     with self.assertRaises(IncompetentQiitaDeveloperError):
         ProcessedData.create("foo", self.params_id, self.filepaths,
                              preprocessed_data=self.preprocessed_data)
     with self.assertRaises(IncompetentQiitaDeveloperError):
         ProcessedData.create("processed_params_foo", self.params_id,
                              self.filepaths,
                              preprocessed_data=self.preprocessed_data)
     with self.assertRaises(IncompetentQiitaDeveloperError):
         ProcessedData.create("processed_params_", self.params_id,
                              self.filepaths,
                              preprocessed_data=self.preprocessed_data)
开发者ID:BrindhaBioinfo,项目名称:qiita,代码行数:13,代码来源:test_data.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python data.RawData类代码示例发布时间:2022-05-26
下一篇:
Python data.PreprocessedData类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap