Class: GenomerPluginValidate::Validator::BadProductField
- Inherits:
-
Genomer::Plugin
- Object
- Genomer::Plugin
- GenomerPluginValidate::Validator::BadProductField
show all
- Includes:
- GenomerPluginValidate::Validator
- Defined in:
- lib/genomer-plugin-validate/validator/bad_product_field.rb
Constant Summary
collapse
- ERROR =
"Bad product field for '%s:' "
Instance Method Summary
collapse
#annotations_by_attribute, load, validators
Instance Method Details
#all_caps_products ⇒ Object
39
40
41
42
43
|
# File 'lib/genomer-plugin-validate/validator/bad_product_field.rb', line 39
def all_caps_products
products_matching(/^([A-Z\s-]+)$/).
map(&:first).
map{|i| (ERROR + "all caps product fields are not allowed.") % i}
end
|
#domain_related_like_ending_products ⇒ Object
29
30
31
32
|
# File 'lib/genomer-plugin-validate/validator/bad_product_field.rb', line 29
def domain_related_like_ending_products
products_matching(/([Dd]omain|[Rr]elated|[Ll]ike).?$/).
map{|i| (ERROR + "products ending with '%s' are not allowed.") % i}
end
|
#hypothetical_products ⇒ Object
24
25
26
27
|
# File 'lib/genomer-plugin-validate/validator/bad_product_field.rb', line 24
def hypothetical_products
products_matching(/^([Hh]ypothetical)(?! protein)/).
map{|i| (ERROR + "start with 'putative' instead of '%s.'") % i}
end
|
#nterm_products ⇒ Object
34
35
36
37
|
# File 'lib/genomer-plugin-validate/validator/bad_product_field.rb', line 34
def nterm_products
products_matching(/(?!\B)([Nn][-\s][Tt]erm(inal)?)/).
map{|i| (ERROR + "'N-terminal' or variations are not allowed.") % i}
end
|
#products_matching(re) ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/genomer-plugin-validate/validator/bad_product_field.rb', line 15
def products_matching(re)
annotations_by_attribute("product").
map{|(product,entries)| entries.map{|i| [i.id,product]}}.
flatten(1).
map{|(id,product)| [id, re.match(product)]}.
select{|(_,match)| match}.
map{|(id,match)| [id,match.to_a[1].downcase]}
end
|
#run ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/genomer-plugin-validate/validator/bad_product_field.rb', line 6
def run
[
hypothetical_products,
domain_related_like_ending_products,
nterm_products,
all_caps_products
].flatten
end
|