當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。