BH12.12/SPARQLthon8/TogoStanza
提供:TogoWiki
TogoGenome, MicrobeDB.jp, CyanoBase などで必要なスタンザをリストアップし、これから実装するもののプライオリティをつけた。
各スタンザで利用する SPARQL エンドポイントは DBCLS, 東工大, DDBJ, MBGD で相互に公開し、スタンザは最終的には各サーバで分散ホスティング。
目次 |
スタンザの分担
プライオリティ表に基づき、未実装で松クラスのスタンザから各担当者が SPRAQL 開発を行う。
- 作成した SPARQL は http://sparqlbin.com に貼って Share! した URL を貼っておくと便利そう。
- 達成率は SPARQL 完成で 50%、スタンザ完成で 100%。
- 目標は5月中に SPARQL 完成、6/3 に SPARQLthon9、6/23 の BH13 までにスタンザ完成 + 新 CSS 適用。
松クラスのスタンザ
- Gene/Transcript/Protein
- 70% gene_attributes (藤澤) → SPARQL
- 10% gene_sequence (藤澤, 片山) → TogoWS で location 文字列から取れる API を作るか事前に RDF に含めておくか → TogoWSのリンクをgene_attributesスタンザに追加した。
- 0% gene_view (片山)
- 10% gene_cross_reference (小澤, 片山) → EdgeStore
- 80% protein_ortholog (千葉, 西出, 片山)
- 50% ortholog_taxon_profile (千葉, 西出) → 生物種単位の ortholog_profile を treemap/sunburst などにマップするだけで OK かも
- 30% taxon_ortholog_profile (千葉, 西出)
- Genome
- 40% genome_information (片山, 岡本, 藤澤) → SPARQL BioProject 単位で genome をまとめた統計、【Todo】SIGS からも情報を拾う
- 50% replicon_information (片山, 岡本, 藤澤) → SPARQL BioProject 単位で replicon をまとめた統計
- 90% genome_cross_reference (片山) → http://sparqlbin.com/#f6f6f895efec7b1e0116f1f76a51463d
- Organism
- 0% organism_info (岡本, 片山)
- 90% lineage_info (竹原)
- 30% phenotype_info (川島, 小澤)
- 0% taxon_cross_reference (森)
- 0% BRC (森)
- 50% pathogen_info (山本)
- Disease
- 50 % disease_info (山本)
- Environment
- 0% environment_info (川島)
- Metagenome
- 50% metagenome_sample_list (竹原)
- 50% meta16S_sample_list (竹原)
- 50% metagenome_sample_attributes (竹原)
- 50% metagenome_sequencing_attributes (竹原)
- 50% metagenome_cross_reference (竹原)
- 0% metagenome_reference (竹原)
- その他
- 20% EdgeStore (小澤)
- 0% Ontology_viewer (森)
- 10% scatter_plot (岡別府)
- 0% slide_bar (岡別府)
- 25% draft_genome_information(藤澤) → 非公開データ用SPARQL
TODO
- スタンザの統廃合
- スタンザの命名規則
- スタンザのホスティング分担
SPARQL for TogoStanza
- /mw/index.php/BH12.12/stanza_takehara ← 東工大エンドポイント分
- /mw/index.php/BH12.12/SPARQLthon8/MBGD ← 基生研エンドポイント分
phenotype_info stanza
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix up: <http://purl.uniprot.org/core/>
SELECT ?name ?pl1 ?o ?ol1
WHERE {
graph <http://togogenome.org/uniprot/> {
<http://purl.uniprot.org/taxonomy/383372> up:scientificName ?name .
}
graph <http://togogenome.org/mpo/> {
<http://purl.uniprot.org/taxonomy/383372> ?p ?o .
?p rdfs:label ?pl .
FILTER (lang(?pl) = "en") .
BIND (str(?pl) AS ?pl1) .
OPTIONAL {
?o rdfs:label ?ol .
FILTER (lang(?ol) = "en") .
BIND (str(?ol) AS ?ol1)
}
}
}
SELECT ?p ?v
FROM <http://togogenome.org/mpo/>
WHERE {
<http://identifiers.org/taxonomy/395019> ?p ?o .
OPTIONAL { ?o rdfs:label ?o2 }
BIND( IF(bound(?o2) ,?o2 , ?o) as ?v )
}
genome_cross_reference stanza
prefix obo: <http://purl.obolibrary.org/obo/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix insdc: <http://insdc.org/owl/>
prefix idorg: <http://rdf.identifiers.org/database/>
prefix idtax: <http://identifiers.org/taxonomy/>
select ?bp ?rs ?desc ?label ?xref
from <http://togogenome.org/refseq/>
where {
values ?tax_id { idtax:386585 }
values ?so { obo:SO_0000340 obo:SO_0000155 }
?seq rdfs:seeAlso ?tax_id .
?seq a ?so .
?seq rdfs:label ?desc .
?seq insdc:sequence_version ?rs .
?seq rdfs:seeAlso ?xref .
?xref rdfs:label ?label .
?seq rdfs:seeAlso ?xref_bp .
?xref_bp a idorg:BioProject .
?xref_bp rdfs:label ?bp .
}
order by ?bp ?rs ?label
SELECT DISTINCT ?o1 ?o3
WHERE {
GRAPH <http://togogenome.org/edgestore/>
{<http://identifiers.org/taxonomy/1148> rdfs:seeAlso ?o1 .
?o1 rdf:type ?o2 .
?o2 <http://www.biomodels.net/MIRIAM/namespace> ?o3
}
};
o1 o3
VARCHAR VARCHAR
_______________________________________________________________________________
http://identifiers.org/pubmed/8905231 PubMed
http://identifiers.org/pubmed/8590279 PubMed
http://identifiers.org/pubmed/21803841 PubMed
http://identifiers.org/pubmed/23069868 PubMed
http://identifiers.org/refseq/NC_020288 RefSeq
http://identifiers.org/refseq/NC_020297 RefSeq
http://identifiers.org/refseq/NC_005232 RefSeq
http://identifiers.org/refseq/NC_005230 RefSeq
http://identifiers.org/refseq/NC_020290 RefSeq
http://identifiers.org/refseq/NC_020286 RefSeq
http://identifiers.org/refseq/NC_000911 RefSeq
http://identifiers.org/refseq/NC_017277 RefSeq
http://identifiers.org/refseq/NC_020289 RefSeq
http://identifiers.org/refseq/NC_005229 RefSeq
http://identifiers.org/refseq/NC_020298 RefSeq
http://identifiers.org/refseq/NC_020287 RefSeq
http://identifiers.org/refseq/NC_005231 RefSeq
http://identifiers.org/refseq/NC_020296 RefSeq
http://identifiers.org/ec-code/1.14.19.6 Enzyme Nomenclature
http://identifiers.org/ec-code/2.1.1.11 Enzyme Nomenclature
http://identifiers.org/ec-code/1.2.1.70 Enzyme Nomenclature
http://identifiers.org/ec-code/2.8.1.7 Enzyme Nomenclature
http://identifiers.org/ec-code/3.1.3.69 Enzyme Nomenclature
http://identifiers.org/ec-code/2.4.1.213 Enzyme Nomenclature
http://identifiers.org/ec-code/3.1.3.24 Enzyme Nomenclature
http://identifiers.org/ec-code/1.2.1.59 Enzyme Nomenclature
http://identifiers.org/ec-code/2.4.1.14 Enzyme Nomenclature
http://identifiers.org/ec-code/1.3.7.5 Enzyme Nomenclature
http://identifiers.org/ec-code/1.14.13.81 Enzyme Nomenclature
http://identifiers.org/ec-code/1.14.99.41 Enzyme Nomenclature
30 Rows. -- 290 msec.
gene_attributes
locus_tag = slr0473 (かつ taxid = 1148)
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix obo: <http://purl.obolibrary.org/obo/>
prefix faldo: <http://biohackathon.org/resource/faldo#>
prefix idorg: <http://rdf.identifiers.org/database/>
prefix insdc: <http://insdc.org/owl/>
SELECT
distinct ?locus_tag
?label
?gene_symbol
?insdc_location
?faldo_begin_position
?faldo_end_position
(?faldo_begin_type as ?strand)
(str(?strand_label) as ?strand_label) #strand from ?faldo_begin_type
?faldo_type
(str(?faldo_type_label) as ?faldo_type_label)
((xsd:int(?faldo_end_position) - xsd:int(?faldo_begin_position) +1) as ?gene_length)
?gene_type
(str(?gene_type_label) as ?gene_type_label)
?seq_label
?seq_type
(str(?seq_type_label) as ?seq_type_label)
?refseq_label
?ncbi_taxid
?organism
concat("http://togows.dbcls.jp/entry/nucleotide/", replace(?refseq_label,"RefSeq:",""),"/seq/", ?insdc_location) as ?seqence
from <http://togogenome.org/refseq/>
from <http://togogenome.org/so/>
from <http://togogenome.org/faldo>
where{
values ?locus_tag {"slr0473"} #param "slr0473"
#values ?ncbi_taxid {"taxon:1148"} #param "taxon:1148"
values ?seq_type { obo:SO_0000340 obo:SO_0000155 }
values ?gene_type { obo:SO_0000704 obo:SO_0000252 obo:SO_0000253}
values ?faldo_begin_type {faldo:ForwardStrandPosition faldo:ReverseStrandPosition}
?gene a ?gene_type.
?gene_type rdfs:label ?gene_type_label.
?gene insdc:feature_locus_tag ?locus_tag.
?gene rdfs:label ?label.
?gene rdfs:seeAlso ?seeAlso.
?gene obo:so_part_of ?seq.
?gene ?gene_p ?gene_o.
OPTIONAL {?gene insdc:feature_gene ?gene_symbol.}
?seq rdfs:label ?seq_label.
?seq a ?seq_type.
?seq_type rdfs:label ?seq_type_label.
?seq rdfs:seeAlso ?refseq .
?refseq a idorg:RefSeq .
?refseq rdfs:label ?refseq_label .
?seq insdc:source_organism ?organism .
#taxonomy ncbi
?seq rdfs:seeAlso ?taxonomy .
?taxonomy a idorg:Taxonomy .
?taxonomy rdfs:label ?ncbi_taxid .
#faldo
?gene faldo:location ?faldo.
?faldo insdc:location ?insdc_location.
?faldo faldo:begin ?faldo_begin.
?faldo_begin faldo:position ?faldo_begin_position.
?faldo_begin rdf:type ?faldo_begin_type.
?faldo_begin_type rdfs:label ?strand_label.
?faldo faldo:end ?faldo_end.
?faldo_end faldo:position ?faldo_end_position.
?faldo_end rdf:type ?faldo_end_type.
?faldo rdf:type ?faldo_type.
?faldo_type rdfs:label ?faldo_type_label.
}
genome_information
taxid = 1148 (かつ bioproject = 57659)
- identifiers.org のBioProject URIが、http://identifiers.org/bioproject/57659 になっているけど、http://identifiers.org/bioproject/PRJDB57659 が正しい
prefix obo: <http://purl.obolibrary.org/obo/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix insdc: <http://insdc.org/owl/>
prefix idorg: <http://rdf.identifiers.org/database/>
prefix idtax: <http://identifiers.org/taxonomy/>
select
(replace(str(?bioproject),"http://identifiers.org/bioproject/","http://identifiers.org/bioproject/PRJDB") as ?bioproject_uri)
?bioproject_id
#?refseq
#?refseq_version
# ?so
# concat(?so_label) as ?so_label
# ?topology
# concat(?topology_label) as ?topology_label
# ?desc
#?sequence_length
# ?mol_type
?feature_type (str(?feature_type_label) as ?feature_type_label)
#?feature_label
(count(distinct(?locus_tag)) as ?locus_tag_count)
# (SUM(?sequence_length) AS ?sequence_length_sum)
from <http://togogenome.org/refseq/>
from <http://togogenome.org/so/>
where {
values ?tax_id { idtax:1148 }
values ?so { obo:SO_0000340 obo:SO_0000155 }
values ?topology { obo:SO_0000988 obo:SO_0000987 }
values ?bioproject {<http://identifiers.org/bioproject/57659>}
#values ?bioproject {<http://identifiers.org/bioproject/PRJDB57659>}
?seq rdfs:seeAlso ?tax_id .
?seq a ?so .
?seq a ?topology .
?so rdfs:label ?so_label.
?topology rdfs:label ?topology_label.
?seq rdfs:label ?desc .
?seq insdc:sequence_version ?refseq_version .
#bioprojct
?seq rdfs:seeAlso ?bioproject .
?bioproject a idorg:BioProject .
?bioproject rdfs:label ?bioproject_id .
#refseq
?seq rdfs:seeAlso ?refseq .
?refseq a idorg:RefSeq .
?refseq rdfs:label ?refseq_label .
#taxonomy ncbi
?seq rdfs:seeAlso ?taxonomy .
?taxonomy a idorg:Taxonomy .
?taxonomy rdfs:label ?ncbi_taxid .
#taxonomy uniprotも?
#sequence_length
?seq insdc:sequence_length ?sequence_length.
?seq insdc:source_mol_type ?mol_type.
?feature obo:so_part_of ?seq.
?feature a ?feature_type .
?feature insdc:feature_locus_tag ?locus_tag .
?feature_type rdfs:label ?feature_type_label.
#OPTIONAL{ ?feature rdfs:label ?feature_label.}
}
#group by ?feature_type
order by desc(?locus_tag_count)
#order by ?bioproject_id desc(?sequence_length) desc(?locus_tag_count)
replicon_information
prefix obo: <http://purl.obolibrary.org/obo/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix insdc: <http://insdc.org/owl/>
prefix idorg: <http://rdf.identifiers.org/database/>
prefix idtax: <http://identifiers.org/taxonomy/>
select
#(replace(str(?bioproject),"http://identifiers.org/bioproject/","http://identifiers.org/bioproject/PRJDB") as ?bioproject_uri)
# ?bioproject_id
?refseq ?refseq_version ?so concat(?so_label) as ?so_label ?topology concat(?topology_label) as ?topology_label ?desc ?sequence_length ?mol_type
#?feature_type (concat(?feature_type_label) as ?feature_type_label)
#?feature_label
#?feature_p ?feature_o count(?feature_o)
# ?locus_tag
(count(distinct(?locus_tag)) as ?locus_tag_count)
#?seq ?seq_p ?seq_o ?seq_o_label
from <http://togogenome.org/refseq/>
from <http://togogenome.org/so/>
where {
values ?tax_id { idtax:1148 }
values ?so { obo:SO_0000340 obo:SO_0000155 }
values ?topology { obo:SO_0000988 obo:SO_0000987 }
values ?bioproject {<http://identifiers.org/bioproject/57659>}
#values ?bioproject {<http://identifiers.org/bioproject/PRJDB57659>}
?seq rdfs:seeAlso ?tax_id .
?seq a ?so .
?seq a ?topology .
?so rdfs:label ?so_label.
?topology rdfs:label ?topology_label.
?seq rdfs:label ?desc .
?seq insdc:sequence_version ?refseq_version .
#bioprojct
?seq rdfs:seeAlso ?bioproject .
?bioproject a idorg:BioProject .
?bioproject rdfs:label ?bioproject_id .
#refseq
?seq rdfs:seeAlso ?refseq .
?refseq a idorg:RefSeq .
?refseq rdfs:label ?refseq_label .
#taxonomy ncbi
?seq rdfs:seeAlso ?taxonomy .
?taxonomy a idorg:Taxonomy .
?taxonomy rdfs:label ?ncbi_taxid .
#taxonomy uniprotも?
#sequence_length
?seq insdc:sequence_length ?sequence_length.
#source_moltype
?seq insdc:source_mol_type ?mol_type.
#seq
#?seq ?seq_p ?seq_o .
#OPTIONAL{ ?seq_o rdfs:label ?seq_o_label}.
#xref
#?seq rdfs:seeAlso ?xref .
#?xref rdfs:label ?label .
#?xref a ?xref_type .
#feature
?feature obo:so_part_of ?seq.
?feature a ?feature_type .
?feature insdc:feature_locus_tag ?locus_tag .
## ?feature_type rdfs:label ?feature_type_label.
## OPTIONAL{ ?feature rdfs:label ?feature_label.}
?feature ?feature_p ?feature_o.
}
order by ?bioproject_id desc(?sequence_length)
#order by ?bioproject_id desc(?sequence_length) desc(?locus_tag_count)
#group by (?feature_type)
Stanza の作り方
TogoStanza の入手からデプロイまでの概略
GitHub と Heroku のアカウントを取得し、ローカルに必要な開発環境をインストールし、TogoStanza を fork して clone する。(使わない PostgreSQL への依存がなくなるといいのだが)
% git clone git@github.com:ktym/TogoStanza.git % cd TogoStanza % rake db:setup % git checkout -b my-awesome-stanza % rails g stanza my_awesome (スタンザを開発する) % rails s -p 4000 (↑デフォルトは 3000 番ポート http://localhost:4000/my_awesome/help) % git add . % git status % git commit
動作確認したら、
% heroku create % git push heroku my-awesome-stanza:master % heroku run rake db:migrate % heroku open
これで作成した my_awesome スタンザが Heroku にデプロイされる。
最新版コードベースとのマージ
TogoStanza は ESM 版も改定が続いているので、自分の開発部分と定期的なマージが必要。
% cd TogoStanza % git remote -v (ここに esminc がなければ) % git remote add esm git@github.com:esminc/TogoStanza.git % git remote -v (追加されたことを確認) % git fetch esm % git merge esm/master % bundle
もしコンフリクトがあればググって適切に対処する。
% git merge esm/master CONFLICT (modify/delete): app/views/demo/index.html.haml deleted in esm/master and modified in HEAD. Version HEAD of app/views/demo/index.html.haml left in tree. % git rm app/views/demo/index.html.haml % git commit % git merge esm/master Already up-to-date.
スタンザの開発例
いまの TogoStanza のコードベースは UniProt のスタンザを表示するサンプルが付いてきているので参考にしつつ編集する。
% git checkout -b genome_cross_references
Switched to a new branch 'genome_cross_references'
% rails g stanza genome_cross_references
create app/stanza/genome_cross_references_stanza.rb
create app/stanza/genome_cross_references/template.hbs
create app/stanza/genome_cross_references/help.md
% vi app/stanza/genome_cross_references_stanza.rb # SPARQL 検索し返したいオブジェクトを最後に評価するコードを書く
% vi app/stanza/genome_cross_references/template.hbs # オブジェクト(通常は Array of Hash)をレンダリング
% vi app/stanza/genome_cross_references/help.md # 引数と仕様を記述
app/stanza/genome_cross_references_stanza.rb
class GenomeCrossReferencesStanza < Stanza::Base
property :xrefs do |tax_id|
results = query("http://ep.dbcls.jp/sparql", <<-SPARQL.strip_heredoc)
prefix obo: <http://purl.obolibrary.org/obo/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix insdc: <http://insdc.org/owl/>
select ?label ?xref
where {
graph <http://togogenome.org/refseq/> {
?seq rdfs:seeAlso <http://identifiers.org/taxonomy/#{tax_id}> .
?seq a obo:SO_0000340 .
?seq rdfs:label ?description .
?seq insdc:sequence_version ?ver .
?seq rdfs:seeAlso ?xref .
?xref rdfs:label ?label .
}
}
SPARQL
results.map { |hash|
xref_db, xref_id = hash[:label].split(':')
hash.merge(:xref_db => xref_db, :xref_id => xref_id)
}.sort_by { |hash|
hash[:xref_db]
}
end
end
app/stanza/genome_cross_references/template.hbs
<!DOCTYPE html>
<html>
<head>
<title>Genome Cross References</title>
<link rel="stylesheet" href="{{css_uri}}" />
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.2.2/bootstrap.min.js"></script>
{{adjust_iframe_height_script}}
</head>
<body>
{{#if xrefs}}
<table class='table table-bordered'>
<tbody>
{{#each xrefs}}
<tr>
<th>{{xref_db}}</th>
<td><a href="{{xref}}">{{xref_id}}</a></td>
</tr>
{{/each}}
</tbody>
</table>
{{/if}}
</body>
</html>
app/stanza/genome_cross_references/help.md
Genome Cross References ======================= Table of cross references of a given genome. ## Parameters: (* = required) | Name | Description | |---------------------|------------------| | *data-stanza-tax-id | NCBI taxonomy ID | ## Sample: ```html <div data-stanza="http://togogenome.org/stanza/genome_cross_references_stanza" data-stanza-tax-id="386585"></div> ``` The above `<div>` will automatically embed the following Stanza in your HTML page. <div data-stanza="http://togogenome.org/stanza/genome_cross_references_stanza" data-stanza-tax-id="386585"></div>
ローカルでのスタンザサーバの起動と作成したスタンザの表示・動作確認は下記コマンドで引数を渡すと容易。
% rails s % script/stanza open genome_cross_references tax_id=386585 # → ブラウザ % script/stanza show_context genome_cross_references tax_id=386585 # → JSON % script/stanza render genome_cross_references tax_id=386585 # → HTML