簡體   English   中英

使用 Uniprot SPARQL 端點和 CONSTRUCT 的問題

[英]problem using Uniprot SPARQL endpoint and CONSTRUCT

在 SPARQLwrapper 中,我可以使用 SPARQL select 成功查詢並返回結果。 當我嘗試使用網站上的 CONSTRUCT 示例時,我得到錯誤“ ExpatError: no element found: line 1, column 0

我已經用 dbpedia 示例測試了我的代碼

sparql = SPARQLWrapper("http://dbpedia.org/sparql")
sparql.setQuery("""
    PREFIX dbo: <http://dbpedia.org/ontology/>
    PREFIX sdo: <https://schema.org/>

    CONSTRUCT {
      ?lang a sdo:Language ;
      sdo:alternateName ?iso6391Code .
    }
    WHERE {
      ?lang a dbo:Language ;
      dbo:iso6391Code ?iso6391Code .
      FILTER (STRLEN(?iso6391Code)=2) # to filter out non-valid values
    }
    LIMIT 3
""")

results = sparql.queryAndConvert()

print("results")
print(results.serialize())
print("- - - - - - - - -")

DBpedia 示例工作正常。但是,當在 Uniprot 上嘗試同樣的操作時......

sparql = SPARQLWrapper("http://sparql.uniprot.org/sparql")
sparql.setQuery("""
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
CONSTRUCT
{
    ?protein a up:HumanProtein .
}
WHERE
{
    ?protein a up:Protein .
    ?protein up:organism taxon:9606 .
}
""")

results = sparql.queryAndConvert()

我收到這個錯誤

“ExpatError:未找到元素:第 1 行,第 0 列”

您能否嘗試直接訪問https://sparql.uniprot.org ,因為這可能是問題所在。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM