Class: FamilyReunion::NomatchOrganizer

Inherits:
Object
  • Object
show all
Defined in:
lib/family-reunion/nomatch_organizer.rb

Instance Method Summary collapse

Constructor Details

#initialize(family_reunion) ⇒ NomatchOrganizer

Returns a new instance of NomatchOrganizer.



4
5
6
7
# File 'lib/family-reunion/nomatch_organizer.rb', line 4

def initialize(family_reunion)
  @fr = family_reunion
  @nomatch_secondary_ids = nil
end

Instance Method Details

#get_nomach_secondary_idsObject



14
15
16
17
18
19
20
# File 'lib/family-reunion/nomatch_organizer.rb', line 14

def get_nomach_secondary_ids
  return @nomatch_secondary_ids if @nomatch_secondary_ids
  match_ids = @fr.merges.map { |key, val| val[:matches].keys }.flatten.uniq
  empty_nodes_ids =  @fr.secondary_node.data[:empty_nodes].map { |node| node[:id].to_s.to_sym }
  valid_names_ids = @fr.secondary_node.ids_hash.keys.map { |k| k }
  @nomatch_secondary_ids = valid_names_ids - match_ids
end

#mergeObject



9
10
11
12
# File 'lib/family-reunion/nomatch_organizer.rb', line 9

def merge
  FamilyReunion.logger_write(@fr.object_id, "Filling gaps with new taxa")
  organize_nonmatches(get_nomach_secondary_ids)
end

#organize_nonmatches(nomatch_secondary_ids) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/family-reunion/nomatch_organizer.rb', line 22

def organize_nonmatches(nomatch_secondary_ids)
  ids_hash = @fr.secondary_node.ids_hash
  paths_hash = @fr.primary_node.paths_hash
  nomatch_secondary_ids.each do |i|
    node = ids_hash[i]
    merge_node(node, paths_hash)
  end
end