BH12.12/SPARQLthon/MEO SPARQL

提供:TogoWiki

2012年10月31日 (水) 07:11時点におけるSachiboo (トーク | 投稿記録)による版
移動: 案内, 検索

目次

前提条件

TTLだけをまとめたグラフをhttp://localhost:8890/DAV/idに用意する。

RefSeq(ID)->MEO(ID)一覧取得

DEFINE sql:select-option "order"
prefix ncbi_gi:<http://www.ncbi.nlm.nih.gov/nuccore/>
prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#>
prefix meo:<http://purl.jp/bio/11/meo/> 
prefix gold:<http://www.genomesonline.org/cgi-bin/GOLD/GOLDCards.cgi?goldstamp=>
SELECT ?seealso ?gi ?gold ?meo
FROM <http://localhost:8890/DAV/id>
WHERE {
  ?s rdfs:seeAlso ?gi
  FILTER regex(?gi, ncbi_gi:CP000768.1, "i" ).
  ?s rdfs:seeAlso ?seealso.
  ?seealso rdfs:label ?typelabel
  FILTER regex(?typelabel, "Genome sequencing", "i" ). 
  ?seealso rdfs:seeAlso ?gold.
  ?gold meo:environmentalDescribed ?meo.
}

MEO(ID)->RefSeq(ID)一覧取得

DEFINE sql:select-option "order"
prefix ncbi_gi:<http://www.ncbi.nlm.nih.gov/nuccore/>
prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#>
prefix meo:<http://purl.jp/bio/11/meo/> 
prefix gold:<http://www.genomesonline.org/cgi-bin/GOLD/GOLDCards.cgi?goldstamp=>
SELECT ?s ?seealso ?gold ?meo 
FROM <http://localhost:8890/DAV/id>
WHERE {
  ?s rdfs:seeAlso ?seealso.
  ?seealso rdfs:label ?typelabel
  FILTER regex(?typelabel, "Genome sequencing", "i" ). 
  ?seealso rdfs:seeAlso ?gold.
  ?gold meo:environmentalDescribed ?meo
  FILTER regex(?meo, meo:MEO_0000059, "i").
}

個数を調べるには...

DEFINE sql:select-option "order"
DEFINE input:inference <http://localhost:8890/DAV/20121031owl>
prefix ncbi_gi:<http://www.ncbi.nlm.nih.gov/nuccore/>
prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#>
prefix meo: <http://purl.jp/bio/11/meo/>

SELECT count(?proid)
FROM <http://localhost:8890/DAV/id>
WHERE {
  ?proid rdfs:label ?typelabel
  FILTER regex(?typelabel, "RefSeq Genome", "i" ).
  ?proid  rdfs:seeAlso ?oriproid.
  ?oriproid rdfs:label ?typelabel2
  FILTER regex(?typelabel2, "Genome sequencing", "i" ).
  ?oriproid rdfs:seeAlso ?gold.
  FILTER regex(?gold, "GOLD", "i" ).
  ?gold a meo:MEO_0000043
}


MEO(ID)->MEO取得

prefix meo:<http://purl.jp/bio/11/meo/> 
SELECT * FROM <http://localhost:8890/meo20121030>
WHERE {
  {
    SELECT distinct(?meo) as ?meo2 FROM <http://localhost:8890/DAV/id>
    WHERE {
      ?gold meo:environmentalDescribed ?meo
      FILTER regex(?meo, meo:MEO_0000059, "i").
    }
  }
  ?s ?p ?o
  FILTER regex(?s, ?meo2, "i").
}

複数のグラフ(ユーザ固有グラフを想定)の検索

prefix meo:<http://purl.jp/bio/11/meo/> 
SELECT * FROM <http://localhost:8890/meo20121030>
WHERE {
  {
    SELECT distinct(?meo) as ?meo2 FROM <http://localhost:8890/DAV/id>
    WHERE {
      ?gold meo:environmentalDescribed ?meo
      FILTER regex(?meo, meo:MEO_0000059, "i").
    }
  }
  {
    SELECT distinct(?meo) as ?meo3 FROM <http://localhost:8890/DAV/id>
    WHERE {
      ?gold meo:environmentalDescribed ?meo
      FILTER regex(?meo, meo:MEO_0000060, "i").
    }
  }

  ?s ?p ?o
  FILTER (regex(?s, ?meo2, "i") || regex(?s, ?meo3, "i")).
}

MEOからRefSeq(ID)をオントロジー検索

DEFINE input:inference <http://localhost:8890/DAV/20121031owl>
PREFIX meo:<http://purl.jp/bio/11/meo/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

select  ?refseqProjectId
from<http://localhost:8890/DAV/id> where
{
  ?goldid a meo:MEO_0000043 .
  ?oriProjectId rdfs:seeAlso ?goldid.
  ?refseqProjectId rdfs:seeAlso ?oriProjectId.
  ?refseqProjectId rdfs:label ?dataType
  FILTER regex(?dataType, "RefSeq Genome", "i" ).
}