-
Notifications
You must be signed in to change notification settings - Fork 1
Incertae sedis placement #337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e089054
6c8d039
5fb3cb4
86c44cb
ca87607
3938050
33154e7
022ea28
23a50ca
e046558
849d9aa
e6f002b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,4 +29,3 @@ import "packs/network"; | |
| import "packs/styling"; | ||
| import "packs/copyable"; | ||
| import "channels/index.js"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,15 +112,17 @@ class QcWarning | |
| inconsistent_parent_rank: { | ||
| message: ->(_w, n) { | ||
| <<~MSG | ||
| The parent rank (#{n.parent.inferred_rank}) is inconsistent | ||
| The parent rank (#{n.placement.parent.inferred_rank}) is inconsistent | ||
| with the rank of this name (#{n.inferred_rank}) | ||
| MSG | ||
| }, | ||
| area: :nomenclature, | ||
| rules: %w[7a 7b], | ||
| scope: ->(_w, n) { n.rank? && n.parent&.rank? }, | ||
| scope: ->(_w, n) { | ||
| n.rank? && n.placement&.parent&.rank? | ||
| }, | ||
| failure: ->(_w, n) { | ||
| n.class.ranks.index(n.rank) != n.class.ranks.index(n.parent.rank) + 1 | ||
| !n.placement.allowed_parent_ranks.include?(n.placement.parent.rank) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In a previous version of this pull req I added a new quality check for the incertae sedis rank. WIth the new |
||
| } | ||
| }.merge(@@link_to_edit_parent), | ||
| # - Rules 7c and 7d are implied by the structure of the SeqCode Registry | ||
|
|
@@ -141,7 +143,10 @@ class QcWarning | |
| link_to: ->(_w, n) { [:edit_parent, n] }, | ||
| recommendations: %w[7], | ||
| scope: ->(_w, n) { n.rank? && !n.top_rank? }, | ||
| failure: ->(_w, n) { !n.incertae_sedis? && !n.parent.present? } | ||
| failure: ->(_w, n) { | ||
| parent = n.incertae_sedis? ? n.placement.parent : n.parent | ||
| !parent.present? | ||
| } | ||
| }, | ||
|
|
||
| # Section 3. Naming of Taxa | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,16 +5,12 @@ class Placement < ApplicationRecord | |
| ) | ||
| belongs_to(:publication, optional: true) | ||
| validates(:name, presence: true) | ||
| validates(:parent, presence: true, unless: :incertae_sedis?) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This removes the ability to have incertae sedis without a parent. There are almost no cases of that. Wouldn't at least a domain placement always be possible? |
||
| validates(:parent, presence: true) | ||
|
|
||
| has_rich_text(:incertae_sedis_text) | ||
| validates(:incertae_sedis_text, presence: true, if: :incertae_sedis?) | ||
| validates(:incertae_sedis, presence: true, allow_nil: true) | ||
| validates( | ||
| :incertae_sedis, absence: { | ||
| if: :parent, | ||
| message: 'cannot be declared if the parent taxon is set' | ||
| } | ||
| :incertae_sedis, inclusion: { in: [true, false] } | ||
| ) | ||
| validates(:preferred, uniqueness: { scope: :name_id, if: :preferred? }) | ||
|
|
||
|
|
@@ -23,7 +19,20 @@ class Placement < ApplicationRecord | |
| def incertae_sedis_html | ||
| return '' unless incertae_sedis? | ||
|
|
||
| incertae_sedis.gsub(/(incertae sedis)/i, '<i>\\1</i>').html_safe | ||
| ActionController::Base.helpers.safe_join( | ||
| ['<i>incertae sedis</i>'.html_safe, (" (#{parent.name})" if parent)].compact | ||
| ) | ||
| end | ||
|
|
||
| def allowed_parent_ranks(incertae_sedis: incertae_sedis?) | ||
| rank_index = name&.rank_index | ||
| return [] unless rank_index && rank_index.positive? | ||
|
|
||
| if incertae_sedis | ||
| Name.ranks.take(rank_index - 1) | ||
| else | ||
| [Name.ranks[rank_index - 1]] | ||
| end | ||
| end | ||
|
|
||
| def downwards? | ||
|
|
@@ -36,6 +45,6 @@ def downwards? | |
| private | ||
|
|
||
| def harmonize_name_parent | ||
| name.update(parent: parent) if preferred | ||
| name.update(parent: incertae_sedis? ? nil : parent) if preferred | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,9 +54,11 @@ def param_names | |
|
|
||
| # Deal with foreign keys | ||
| if j['parent'] && | ||
| j['parent'] =~ /^incertae sedis( \((Archaea|Bacteria)\))?/ | ||
| j['incertae_sedis'] = j['parent'] | ||
| j['parent'] = nil | ||
| match = j['parent'].match( | ||
| /^incertae sedis( \((Archaea|Bacteria)\))?/ | ||
| ) | ||
| j['incertae_sedis'] = true | ||
| j['parent'] = match[2] | ||
| end | ||
| j['parent'] &&= Name.new(name: j['parent']) | ||
| if j['nomenclatural_type_type'].to_s.downcase == 'name' && | ||
|
|
@@ -80,7 +82,7 @@ def ephemeral_names | |
| name_attributes = i.except('parent', 'incertae_sedis') | ||
| placement_attributes = { | ||
| parent: i['parent'], | ||
| incertae_sedis: i['incertae_sedis'], | ||
| incertae_sedis: i['incertae_sedis'] || false, | ||
| preferred: true | ||
| } | ||
| if i['incertae_sedis'].present? | ||
|
|
@@ -348,7 +350,6 @@ def batch_step_01(params, user) | |
| default_pars = { status: 0, created_by: user } | ||
| param_names.each do |par| | ||
| new_par = {} | ||
| placement_par = nil | ||
|
|
||
| # Parents | ||
| if par['parent'] | ||
|
|
@@ -357,16 +358,14 @@ def batch_step_01(params, user) | |
| parent = Name.new(default_pars.merge(name: par['parent'].name)) | ||
| parent.save! | ||
| end | ||
| placement_par = { | ||
| parent: parent, | ||
| incertae_sedis: nil | ||
| } | ||
| elsif par['incertae_sedis'] | ||
| placement_par = { | ||
| parent: nil, | ||
| incertae_sedis: par['incertae_sedis'], | ||
| incertae_sedis_text: par['description'] | ||
| } | ||
| name = Name.find_by_variants(par['name']) | ||
| placement = name.placements.find_or_initialize_by(parent: parent) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplication. I wanna tackle this in another PR as previously discussed. |
||
| name.placements.where(preferred: true).where.not(id: placement.id) | ||
| .find_each { |current| current.update!(preferred: false) } | ||
| placement.update!( | ||
| incertae_sedis: par['incertae_sedis'] || false, | ||
| incertae_sedis_text: par['description'], preferred: true | ||
| ) | ||
| end | ||
|
|
||
| # Nomenclatural types | ||
|
|
@@ -387,16 +386,7 @@ def batch_step_01(params, user) | |
| end | ||
| end | ||
|
|
||
| name = Name.find_by_variants(par['name']) | ||
| name.update!(new_par) | ||
| if placement_par | ||
| placement = name.placements.find_or_initialize_by( | ||
| parent: placement_par[:parent], | ||
| incertae_sedis: placement_par[:incertae_sedis] | ||
| ) | ||
| name.placements.where.not(id: placement.id).update_all(preferred: false) | ||
| placement.update!(placement_par.merge(preferred: true)) | ||
| end | ||
| Name.find_by_variants(par['name']).update!(new_par) | ||
| end | ||
|
|
||
| # If all is good, go to next step | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've combined these two params into a single param. So you just specify a list of ranks that are allowed. For known placements that list is just
["genus"]if name is a species etc.