-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rudimentary genotype-phenotype search
- Loading branch information
Adam Coffman
committed
Sep 15, 2016
1 parent
b63bb45
commit 86baa91
Showing
6 changed files
with
169 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
require 'ga4gh/common_pb' | ||
|
||
add_message "ga4gh.ExternalIdentifier" do | ||
optional :database, :string, 1 | ||
optional :identifier, :string, 2 | ||
optional :version, :string, 3 | ||
end | ||
module Ga4gh; module Converters | ||
class ExternalIdentifier | ||
attr_reader :ext_id | ||
|
||
def initialize(ext_id) | ||
@ext_id = ext_id | ||
end | ||
|
||
def is_supported? | ||
self.class.databases(ext_id) | ||
end | ||
|
||
def error | ||
if is_supported? | ||
nil | ||
else | ||
"Database #{ext_id.database} version #{ext_id.version} is not currently supported" | ||
end | ||
end | ||
|
||
private | ||
def self.databases(ext_id) | ||
@databases ||= { | ||
'entrez' => :handle_entrez | ||
'disease ontology' => :handle_doid | ||
'sequence ontology' => :handle_soid | ||
'pubmed' => :handle_pubmed | ||
} | ||
end | ||
def handle_entrez(query) | ||
query.where(evidence_items: { variants: { genes: { entrez_id: ext_id.identifier }}} | ||
end | ||
def handle_doid(query) | ||
term = if ext_id.identifier =~ /doid/i | ||
ext_id.identifier.downcase.gsub('doid:', '') | ||
else | ||
ext_id.identifier | ||
end | ||
query.where(doid: term) | ||
end | ||
def handle_soid(query) | ||
term = if ext_id.identifier =~ /soid/i | ||
ext_id.identifier.downcase.gsub('soid:', '') | ||
else | ||
ext_id.identifier | ||
end | ||
query.where(evidence_items: { variants: { variant_types: { soid: term }}}) | ||
end | ||
|
||
def handle_pubmed(query) | ||
query.where(evidence_items: { sources: { pubmed_id: ext_id.identifier }}) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters