lib/sequenceserver/links.rb in sequenceserver-1.0.3 vs lib/sequenceserver/links.rb in sequenceserver-1.0.4

- old
+ new

@@ -6,11 +6,12 @@ # Provide a method to URL encode _query parameters_. See [1]. include ERB::Util # alias_method :encode, :url_encode - NCBI_ID_PATTERN = /gi\|(\d+)\|/ + NCBI_ID_PATTERN = /gi\|(\d+)\|/ + UNIPROT_ID_PATTERN = /sp\|(\w+)\|/ # Link generators return a Hash like below. # # { # # Required. Display title. @@ -95,9 +96,22 @@ ncbi_id = encode ncbi_id url = "http://www.ncbi.nlm.nih.gov/#{querydb.first.type}/#{ncbi_id}" { :order => 2, :title => 'NCBI', + :url => url, + :icon => 'fa-external-link' + } + end + + def uniprot + return nil unless id.match(UNIPROT_ID_PATTERN) + uniprot_id = Regexp.last_match[1] + uniprot_id = encode uniprot_id + url = "http://www.uniprot.org/uniprot/#{uniprot_id}" + { + :order => 2, + :title => 'Uniprot', :url => url, :icon => 'fa-external-link' } end end