Skip to content

Commit 08e7cb0

Browse files
committed
Use StrainCode to parse strain numbers
1 parent 03dd6b9 commit 08e7cb0

5 files changed

Lines changed: 16 additions & 128 deletions

File tree

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ gem 'serrano', '~> 1.0'
3737
# loaded (see https://github.com/heartcombo/simple_form/issues/1824)
3838
gem 'simple_form', '~> 5.2.0'
3939
gem 'sqlite3'
40+
gem 'strain-code', '~> 0.3'
4041
# Turbolinks makes navigating your web application faster.
4142
# Read more: https://github.com/turbolinks/turbolinks
4243
gem 'turbolinks', '~> 5'

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ GEM
350350
mini_portile2 (~> 2.8.0)
351351
sqlite3 (1.7.3-x86_64-darwin)
352352
sqlite3 (1.7.3-x86_64-linux)
353+
strain-code (0.3.3)
353354
thor (1.3.2)
354355
tilt (2.4.0)
355356
time (0.4.1)
@@ -439,6 +440,7 @@ DEPENDENCIES
439440
spring
440441
spring-watcher-listen (~> 2.0.0)
441442
sqlite3
443+
strain-code (~> 0.3)
442444
turbolinks (~> 5)
443445
tzinfo-data
444446
uglifier (>= 1.3.0)

app/assets/stylesheets/custom.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ trix-editor {
8383
}
8484
}
8585

86+
.tooltip-text {
87+
text-decoration: underline dotted theme-color(secondary);
88+
}
89+
8690
/* Header Bar */
8791
.bg-dark-ce, .bg-vdark-ce {
8892
a {

app/helpers/strains_helper.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ def strain_numbers_html(numbers, opts = {})
3030
ext = opts[:ext] ? '<sup class="fas fa-external-link-alt "> </sup>' : ''
3131

3232
numbers.map do |str|
33-
if str.is_a? Hash
34-
'<a href="%s" target="_blank">%s %s</a>' % [
35-
str[:url], sanitize(str[:accession]), ext
33+
if str.is_a?(StrainCode::Number) && str.url.present?
34+
'<a href="%s" title="%s" target="_blank">%s %s</a>' % [
35+
str.url, sanitize(str.catalogue&.name), sanitize(str.number), ext
36+
]
37+
elsif str.is_a?(StrainCode::Number) && str.catalogue&.name.present?
38+
'<span class="tooltip-text" title="%s">%s</span>' % [
39+
sanitize(str.catalogue.name), sanitize(str.number)
3640
]
3741
else
3842
str

app/models/strain.rb

Lines changed: 2 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -12,139 +12,16 @@ class Strain < ApplicationRecord
1212
include HasExternalResources
1313
include Strain::ExternalResources
1414

15-
class << self
16-
##
17-
# Hash of culture collection prefixes and URL rule.
18-
# See also: https://ftp.ncbi.nih.gov/pub/taxonomy/Ccode_dump.txt
19-
# See also: https://jcm.brc.riken.jp/en/abbr_e
20-
def culture_collections
21-
{
22-
ATCC: 'https://www.atcc.org/products/%s',
23-
DSM: 'https://www.dsmz.de/collection/catalogue/details/culture/DSM-%s',
24-
IFO: 'https://www.nite.go.jp/nbrc/catalogue/' \
25-
'NBRCCatalogueDetailServlet?ID=IFO&CAT=%s',
26-
JCM: 'https://www.jcm.riken.jp/cgi-bin/jcm/jcm_number?JCM=%s',
27-
KCTC: 'https://kctc.kribb.re.kr/collection/view?sn=%s',
28-
NBRC: 'https://www.nite.go.jp/nbrc/catalogue/' \
29-
'NBRCCatalogueDetailServlet?ID=IFO&CAT=%s',
30-
NCTC: 'https://www.culturecollections.org.uk/products/bacteria/' \
31-
'detail.jsp?collection=nctc&refId=NCTC+%s',
32-
33-
# Bioresource Collection and Research Center
34-
# [TW: Food Industry Research and Development Insitute]
35-
BCRC: 'https://catalog.bcrc.firdi.org.tw/BcrcContent?bid=%s',
36-
# Collection of Aquatic Important Microorganisms
37-
# [MX: CIAD, Centro de Investigación en Alimentación y Desarrollo]
38-
CAIM: 'https://www.ciad.mx/caim/busqueda.php?' \
39-
'searchtype=caim&criterio=%s',
40-
# Culture Collection of Autotrophic Organisms
41-
# [CZ: Czech Academy of Sciences]
42-
CCALA: 'https://ccala.butbn.cas.cz/strain/%s',
43-
# Czech Collection of Microorganisms
44-
# [CZ: Masaryk University]
45-
CCM: 'https://www.sci.muni.cz/ccm/bakterie/camb/%s',
46-
# China General Microbiological Culture Collection Center
47-
# [CN: National Science and Technology Infrastructure]
48-
# -- From NCBI Taxonomy (not working):
49-
# -- 'http://www.cgmcc.net/english/cata.php?stn=CGMCC%%20%s'
50-
CGMCC: 'https://cgmcc.net/english/search?stn=%s',
51-
# NCMA, National Center for Marine Algae and Microbiota,
52-
# formerly Culture Collection for Marine Phytoplankton
53-
# [US: Bigelow Laboratory for Ocean Sciences]
54-
CCMP: 'https://ncma.bigelow.org/CCMP%s',
55-
# Culture Collection University of Gothenburg
56-
# [SE: University of Gothenburg]
57-
CCUG: 'https://www.ccug.se/strain?id=%s',
58-
# China Center of Industrial Culture Collection
59-
# [CN: China National Research Institute of Food & Fermentation
60-
# Industries]
61-
CICC: 'http://www.china-cicc.org/search/?classtype=1&keyword=%s',
62-
# Collection de l'Institut Pasteur
63-
# (Collection of the Institut Pasteur)
64-
# [FR: Institut Pasteur]
65-
CIP: 'https://catalogue-crbip.pasteur.fr/' \
66-
'fiche_catalogue.xhtml?crbip=CIP%%20%s',
67-
# BCCM, Belgian Coordinated Collections of Microorganisms /
68-
# Institute of Tropical Medicine Antwerp Mycobacteria Collection
69-
# [BE: Belgian Science Policy (BELSPO)]
70-
ITM: 'https://bccm.belspo.be/catalogues/bm-details?' \
71-
'accession_number=ITM%%20%s',
72-
# Jena Microbial Resource Collection
73-
# [DE: Friedrich Schiller University Jena]
74-
JMRC: 'http://www.jmrc.uni-jena.de/data.php?fsu=%s',
75-
# Korean Agricultural Culture Collection
76-
# [KR: National Academy of Agricultural Science]
77-
KACC: 'https://genebank.rda.go.kr/eng/mic/cat/MicrobeSearch.do' \
78-
'?sSearchWith=no&sTxt1=%s',
79-
# BCCM, Belgian Coordinated Collections of Microorganisms /
80-
# Bacteria Collection Laboratorium voor Microbiologie Universiteit Gent
81-
# (Bacteria Collection Laboratory of Microbiology, University of Ghent)
82-
# [BE: Belgian Science Policy (BELSPO)]
83-
LMG: 'https://bccm.belspo.be/catalogues/lmg-strain-details?NUM=%s',
84-
# Marine Culture Collection of China
85-
# [CN: Third Institute of Oceanography]
86-
MCCC: 'https://mccc.org.cn/detailRecord3.asp?bcbh=%s',
87-
# North East Pacific Culture Collection
88-
# [CA: The University of British Columbia]
89-
NEPCC: 'https://db.botany.ubc.ca/cccm/mfa/%s',
90-
# National Institute for Environmental Studies Collection
91-
# [JP: National Institute for Environmental Studies]
92-
NIES: 'https://mcc.nies.go.jp/numberSearch.do?strainNumber=%s',
93-
# Agricultural Research Service Culture Collection,
94-
# formerly Northern Regional Research Laboratory
95-
# [US: National Center for Agricultural Utilization Research]
96-
NRRL: 'https://nrrl.ncaur.usda.gov/cgi-bin/usda/prokaryote/' \
97-
'report.html?nrrlcodes=%s',
98-
# Pasteur Cultures of Cyanobacteria
99-
# [FR: Institut Pasteur]
100-
PCC: 'https://catalogue-crbip.pasteur.fr/' \
101-
'fiche_catalogue.xhtml?crbip=PCC%%20%s',
102-
# Sammlung von Algenkulturen
103-
# (Culture Collection of Algae)
104-
# [DE: University of Göttingen]
105-
SAG: 'https://sagdb.uni-goettingen.de/detailedList.php?str_number=%s',
106-
# Thailand Bioresource Research Center
107-
# [TH: Thailand Bioresource Research Center]
108-
TBRC: 'https://tbrcnetwork.org/microb_detail.php?code=TBRC_%s',
109-
# BCCM, Belgian Coordinated Collections of Microorganisms /
110-
# University of of Liège Cyanobacteria Collection
111-
# [BE: Belgian Science Policy (BELSPO)]
112-
ULC: 'https://bccm.belspo.be/catalogues/bm-details?' \
113-
'accession_number=ULC%%20%s',
114-
# ВСЕРОССИЙСКАЯ КОЛЛЕКЦИЯ МИКРООРГАНИЗМОВ
115-
# (All-Russian Collection of Microorganisms)
116-
# [RU: Pushchino Scientific Center for Biological Research of the
117-
# Russian Academy of Sciences]
118-
VKM: 'http://www.vkm.ru/strains.php?vkm=%s'
119-
}
120-
end
121-
end
122-
12315
def numbers
12416
numbers_string.split(' = ')
12517
end
12618

12719
def numbers_parsed
128-
numbers.map do |str|
129-
parts = str.split(/[ :-]+/, 2)
130-
coll = parts.count == 2 ? parts[0].upcase.to_sym : nil
131-
132-
if url_base = self.class.culture_collections[coll]
133-
{
134-
collection: coll,
135-
accession: parts.join(' '),
136-
url: url_base % parts[1]
137-
}
138-
else
139-
str
140-
end
141-
end
20+
@numbers_parsed ||= StrainCode.parse(numbers_string)
14221
end
14322

14423
def collections
145-
numbers_parsed
146-
.map { |i| i.is_a?(Hash) ? i[:collection] : nil }
147-
.compact.uniq
24+
numbers_parsed.map(&:catalogue).compact.uniq
14825
end
14926

15027
def type_of_type

0 commit comments

Comments
 (0)