lib/rbbt/tsv/change_id.rb in rbbt-util-5.41.1 vs lib/rbbt/tsv/change_id.rb in rbbt-util-5.42.0
- old
+ new
@@ -6,13 +6,13 @@
def self.change_key(tsv, format, options = {}, &block)
options = Misc.add_defaults options, :persist => false, :identifiers => tsv.identifiers
identifiers, persist_input = Misc.process_options options, :identifiers, :persist_input
- identifiers = Organism.identifiers(tsv.namespace) if identifiers.nil? and tsv.namespace
+ identifiers = Organism.identifiers(tsv.namespace) if identifiers.nil? && tsv.namespace &&
+ defined?(Organism) && Organism.identifiers(tsv.namespace).exists?
-
if ! tsv.fields.include?(format)
new = {}
tsv.each do |k,v|
if v === String or v === Array
new[k] = v.dup
@@ -56,10 +56,13 @@
def self.swap_id(tsv, field, format, options = {}, &block)
options = Misc.add_defaults options, :persist => false, :identifiers => tsv.identifiers, :compact => true
identifiers, persist_input, compact = Misc.process_options options, :identifiers, :persist, :compact
identifiers = tsv.identifier_files.first if identifiers.nil?
- identifiers = Organism.identifiers(tsv.namespace) if defined?(Organism) && identifiers.nil? && tsv.namespace && Organism.identifiers(tsv.namespace).exists?
+
+ identifiers = Organism.identifiers(tsv.namespace) if identifiers.nil? && tsv.namespace &&
+ defined?(Organism) && Organism.identifiers(tsv.namespace).exists?
+
identifiers.namespace ||= tsv.namespace
fields = (identifiers and identifiers.all_fields.include?(field))? [field] : nil
#index = identifiers.index :target => format, :fields => fields, :persist => persist_input, :order => true