Skip to content

Commit 5815858

Browse files
committed
Support for number_tr
1 parent 65ed47a commit 5815858

4 files changed

Lines changed: 19 additions & 4 deletions

File tree

data/catalogues.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# matches a catalogue code
66
# - name_en: Name of the culture collection in English, if +name+ is spelled in
77
# a different language
8+
# - number_tr: A two-string array indicating that characters in the first list
9+
# should be replaced by those in the second list prior to passing the number
10+
# to the `url_pattern`
811
# - organization: Name of the organization generating the catalogue. If a
912
# well-known acronym exists, this field should start with this acronym
1013
# followed by colon (:) and the spelled-out name of the organization
@@ -116,6 +119,14 @@ catalogues:
116119
organization: Czech Academy of Sciences
117120
country_code: CZ
118121
url_pattern: "https://ccala.butbn.cas.cz/strain/%s"
122+
- codes: [ CCAP ]
123+
name: "Culture Collection of Algae & Protozoa"
124+
organization: "SAMS: Scottish Association for Marine Science"
125+
country_code: UK
126+
url: "https://www.ccap.ac.uk/"
127+
number_tr: ["/", "-"]
128+
url_pattern: "https://www.ccap.ac.uk/catalogue/strain-%s"
129+
_examples: [ CCAP 1460/5 ]
119130
- codes: [ CCM ]
120131
name: Czech Collection of Microorganisms
121132
organization: Masaryk University
@@ -389,7 +400,8 @@ catalogues:
389400
name: National Institute for Environmental Studies Collection
390401
organization: National Institute for Environmental Studies
391402
country_code: JP
392-
url_pattern: "https://mcc.nies.go.jp/numberSearch.do?strainNumber=%s"
403+
url: "https://mcc.nbrp.jp/index_en.html"
404+
_examples: [ NIES 204 ]
393405
- codes: [ NRC, NRCC ]
394406
country_code: CA
395407
name: Division of Biological Sciences, National Research Council of Canada

lib/strain-code/catalogue.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def catalogue(code)
2626
end
2727

2828
attr_accessor :codes, :country_code, :name, :name_en, :organization
29-
attr_accessor :url, :url_pattern
29+
attr_accessor :number_tr, :url, :url_pattern
3030

3131
def initialize(hash)
3232
hash.each { |k, v| self.send("#{k}=", v) unless k =~ /^_/ }

lib/strain-code/number.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ def number
1818
end
1919

2020
def url
21-
catalogue.url_pattern % accession if catalogue&.url_pattern
21+
return unless catalogue&.url_pattern && accession
22+
23+
acc = catalogue&.number_tr ? accession.tr(*catalogue.number_tr) : accession
24+
catalogue.url_pattern % acc
2225
end
2326

2427
def catalogue

lib/strain-code/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class StrainCode
2-
VERSION = '0.3.11'
2+
VERSION = '0.4.0'
33
VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
44
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
55
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:

0 commit comments

Comments
 (0)