Skip to content

Commit c8f4a68

Browse files
committed
Effective publication checks in names
1 parent cedfe3b commit c8f4a68

5 files changed

Lines changed: 38 additions & 33 deletions

File tree

app/models/check.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Check < ApplicationRecord
22
belongs_to(:name)
3-
belongs_to(:user)
3+
belongs_to(:user, optional: true)
44

55
def fail?
66
!pass?

app/models/name/quality_checks.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,12 @@ class QcWarning
520520
rule_notes: %w[26#1],
521521
can_endorse: false
522522
}.merge(@@link_to_edit_parent),
523-
# - Rule 26 Note 2 [TODO: Report as check and not as register note]
523+
# - Rule 26 Note 2
524+
effective_publication_missing_accession: {
525+
message: 'The effective publication does not include the SeqCode ' \
526+
'Registry Accession',
527+
rule_notes: %w[26#2],
528+
},
524529
# - Rule 26 Note 3 is enforced outside of the SeqCode Registry
525530
# - Recommendation 26 [Checklist-N]
526531
missing_description_in_publication: {
@@ -621,6 +626,11 @@ class QcWarning
621626
# - Rule 50.3 covered in § Rule 50.1
622627

623628
# APPENDIX I
629+
name_missing_in_effective_publication: {
630+
message:
631+
'The reported effective publication does not mention this name',
632+
rules: %w[appendix-i]
633+
},
624634
low_genome_sequencing_depth: {
625635
message:
626636
'The sequencing depth of the type genome should be 10X or greater',

app/models/register/status.rb

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -281,57 +281,47 @@ def automated_validation
281281
# persistent
282282
def check_pdf_files
283283
has_acc = false
284-
bnames = Hash[names.map { |n| [n.base_name, false] }]
285-
cnames = Hash[names.map { |n| [n.base_name, n.corrigendum_from] }]
284+
inames = Hash[names.map { |n| [n, false] }]
286285
[publication_pdf, supplementary_pdf].each do |as|
287-
break if has_acc && bnames.values.all?
286+
break if has_acc && inames.values.all?
288287
next unless as.attached?
289288

290289
as.open do |file|
291290
render = PDF::Reader.new(file.path)
292291
render.pages.each do |page|
293292
txt = page.text
294293
has_acc = true if txt.index(accession)
295-
bnames.each_key do |bn|
296-
if txt.index(bn) || (cnames[bn] && txt.index(cnames[bn]))
297-
bnames[bn] = true
298-
end
294+
inames.each_key do |n|
295+
bn = n.base_name
296+
cn = n.corrigendum_from
297+
inames[n] = true if txt.index(bn) || (cn && txt.index(cn))
299298
end
300-
break if has_acc && bnames.values.all?
299+
break if has_acc && inames.values.all?
301300
end
302301
end
303302
end
304303

305304
if has_acc
306305
add_note('The effective publication includes the SeqCode accession')
307306
else
308-
add_note(
309-
'The effective publication does not include the accession ' \
310-
'(SeqCode, Rule 26, Note 2)'
311-
)
307+
names.each do |n|
308+
Check.find_or_create_by(
309+
name: n, kind: :effective_publication_missing_accession, pass: false
310+
)
311+
end
312312
end
313313

314-
if bnames.values.all?
314+
if inames.values.all?
315315
add_note('The effective publication mentions all names in the list')
316-
elsif bnames.values.any?
317-
if bnames.values.count(&:!) > 5
318-
add_note(
319-
'The effective publication mentions' \
320-
" #{bnames.values.count(&:itself)} out of" \
321-
" #{bnames.count} names in the list"
322-
)
323-
else
324-
add_note(
325-
'The effective publication mentions some names in the list,' \
326-
" but not: #{bnames.select { |_, v| !v }.keys.join(', ')}"
316+
else
317+
inames.each do |n, v|
318+
next if v
319+
Check.find_or_create_by(
320+
name: n, kind: :name_missing_in_effective_publication, pass: false
327321
)
328322
end
329-
else
330-
add_note(
331-
'The effective publication does not mention any names in the list'
332-
)
333323
end
334324

335-
has_acc && bnames.values.all?
325+
has_acc && inames.values.all?
336326
end
337327
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class MakeChecksUserOptional < ActiveRecord::Migration[6.1]
2+
def change
3+
change_column_null(:checks, :user_id, true)
4+
end
5+
end

db/schema.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2025_08_21_140809) do
13+
ActiveRecord::Schema.define(version: 2025_09_02_220521) do
1414

1515
create_table "action_text_rich_texts", force: :cascade do |t|
1616
t.string "name", null: false
@@ -60,7 +60,7 @@
6060

6161
create_table "checks", force: :cascade do |t|
6262
t.integer "name_id", null: false
63-
t.integer "user_id", null: false
63+
t.integer "user_id"
6464
t.text "kind", null: false
6565
t.boolean "pass"
6666
t.datetime "updated_at", precision: 6, null: false

0 commit comments

Comments
 (0)