Sha256: dd674a39121ea55e43b5711767cae4f0ef7a93b34f49b845d9cc4a1777a97120

Contents?: true

Size: 1.24 KB

Versions: 30

Compression:

Stored size: 1.24 KB

Contents

require 'sparql/client'

module TogoStanza::Stanza
  module Querying
    MAPPINGS = {
      togogenome: 'http://ep.dbcls.jp/sparql7',
      uniprot:    'http://ep.dbcls.jp/sparql7',
      go:         'http://ep.dbcls.jp/sparql7'
    }

    def query(endpoint, sparql)
      client = SPARQL::Client.new(MAPPINGS[endpoint] || endpoint)

      #Rails.logger.debug "SPARQL QUERY: \n#{sparql}"

      client.query(sparql).map {|binding|
        binding.each_with_object({}) {|(name, term), hash|
          hash[name] = term.to_s
        }
      }
    end

    def uniprot_url_from_togogenome(gene_id)
      # refseq の UniProt
      # slr1311 の時 "http://purl.uniprot.org/refseq/NP_439906.1"
      query(:togogenome, <<-SPARQL).first[:up]
      PREFIX insdc: <http://insdc.org/owl/>
      PREFIX idorg: <http://rdf.identifiers.org/database/>

      SELECT DISTINCT ?up
      FROM <http://togogenome.org/graph/refseq/>
      WHERE {
          ?s insdc:feature_locus_tag "#{gene_id}" .
          ?s rdfs:seeAlso ?np .
          ?s rdfs:seeAlso ?xref .
          ?np rdf:type idorg:Protein .
          BIND (STRAFTER(STR(?np), "ncbiprotein/") AS ?npid)
          BIND (IRI(CONCAT("http://purl.uniprot.org/refseq/", ?npid)) AS ?up)
      }
      SPARQL
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
togostanza-2.0.0 lib/togostanza/stanza/querying.rb
togostanza-1.5.0 lib/togostanza/stanza/querying.rb
togostanza-1.4.1 lib/togostanza/stanza/querying.rb
togostanza-1.4.0 lib/togostanza/stanza/querying.rb
togostanza-1.3.3 lib/togostanza/stanza/querying.rb
togostanza-1.3.2 lib/togostanza/stanza/querying.rb
togostanza-1.3.1 lib/togostanza/stanza/querying.rb
togostanza-1.3.0 lib/togostanza/stanza/querying.rb
togostanza-1.2.2 lib/togostanza/stanza/querying.rb
togostanza-1.2.1 lib/togostanza/stanza/querying.rb
togostanza-1.2.0 lib/togostanza/stanza/querying.rb
togostanza-1.1.0 lib/togostanza/stanza/querying.rb
togostanza-1.0.6 lib/togostanza/stanza/querying.rb
togostanza-1.0.5 lib/togostanza/stanza/querying.rb
togostanza-1.0.4 lib/togostanza/stanza/querying.rb
togostanza-1.0.3 lib/togostanza/stanza/querying.rb
togostanza-1.0.2 lib/togostanza/stanza/querying.rb
togostanza-1.0.1 lib/togostanza/stanza/querying.rb
togostanza-1.0.0 lib/togostanza/stanza/querying.rb
togostanza-0.1.1 lib/togostanza/stanza/querying.rb