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


Python SparqlQueryBuilder.get_all_taxon方法代码示例

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


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

示例1: source_files_overview

# 需要导入模块: from askomics.libaskomics.rdfdb.SparqlQueryBuilder import SparqlQueryBuilder [as 别名]
# 或者: from askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder import get_all_taxon [as 别名]
    def source_files_overview(self):
        """
        Get preview data for all the available files
        """
        self.log.debug(" ========= Askview:source_files_overview =============")
        sfc = SourceFileConvertor(self.settings, self.request.session)

        source_files = sfc.get_source_files()

        data = {}
        data['files'] = []

        # get all taxon in the TS
        sqb = SparqlQueryBuilder(self.settings, self.request.session)
        ql = QueryLauncher(self.settings, self.request.session)
        res = ql.execute_query(sqb.get_all_taxon().query)
        taxons_list = []
        for elem in res['results']['bindings']:
            taxons_list.append(elem['taxon']['value'])
        data['taxons'] = taxons_list

        for src_file in source_files:
            infos = {}
            infos['name'] = src_file.name
            infos['type'] = src_file.type
            if src_file.type == 'tsv':
                try:
                    infos['headers'] = src_file.headers
                    infos['preview_data'] = src_file.get_preview_data()
                    infos['column_types'] = []
                    header_num = 0
                    for ih in range(0, len(infos['headers'])):
                        #if infos['headers'][ih].find("@")>0:
                        #    infos['column_types'].append("entity")
                        #else:
                        infos['column_types'].append(src_file.guess_values_type(infos['preview_data'][ih], infos['headers'][header_num]))
                        header_num += 1
                except Exception as e:
                    traceback.print_exc(file=sys.stdout)
                    infos['error'] = 'Could not read input file, are you sure it is a valid tabular file?'
                    self.log.error(str(e))

                data['files'].append(infos)

            elif src_file.type == 'gff':
                try:
                    entities = src_file.get_entities()
                    infos['entities'] = entities
                except Exception as e:
                    self.log.debug('error !!')
                    traceback.print_exc(file=sys.stdout)
                    infos['error'] = 'Could not parse the file, are you sure it is a valid GFF3 file?'
                    self.log.error('error with gff examiner: ' + str(e))

                data['files'].append(infos)

            elif src_file.type == 'ttl':
                infos['preview'] = src_file.get_preview_ttl()
                data['files'].append(infos)


        return data
开发者ID:cbettemb,项目名称:askomics,代码行数:64,代码来源:ask_view.py


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