Module: ChemScanner::Interpreter::SchemeBase

Included in:
ReactionDetection
Defined in:
lib/chem_scanner/interpreter/scheme_base.rb

Instance Method Summary collapse

Instance Method Details

#add_molecule_substitution_info(mid, info) ⇒ Object



53
54
55
56
# File 'lib/chem_scanner/interpreter/scheme_base.rb', line 53

def add_molecule_substitution_info(mid, info)
  cur_info = @mol_substitutes[mid] || []
  @mol_substitutes[mid] = cur_info.push(info)
end

#add_reaction_substitution_info(rid, info) ⇒ Object



58
59
60
61
# File 'lib/chem_scanner/interpreter/scheme_base.rb', line 58

def add_reaction_substitution_info(rid, info)
  cur_info = @reaction_substitutes[rid] || []
  @reaction_substitutes[rid] = cur_info.push(info)
end

#assemble_molecule_text(mol) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/chem_scanner/interpreter/scheme_base.rb', line 43

def assemble_molecule_text(mol)
  tarr = mol.text_ids.map { |id| @text_map[id] }.compact
  mol.text = tarr.map(&:non_bold_text).join(" ")

  bold_arr = tarr.map(&:bold_text).reject { |t| t.strip.empty? }
  return unless bold_arr.count == 1

  mol.label = bold_arr.first.gsub(/  +/, " ")
end

#auto_fit_arrow_polygonsObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/chem_scanner/interpreter/scheme_base.rb', line 28

def auto_fit_arrow_polygons
  @reactions.each do |reaction|
    arrow = @arrow_map[reaction.arrow_id]

    polygons = []
    reaction.reagent_ids.each do |id|
      obj = @mol_map.key?(id) ? @mol_map[id] : @text_map[id]
      polygons.push(obj.polygon)
    end

    # build "arrow area" based on molecules boundingbox
    arrow.build_polygons_on_polygons(polygons)
  end
end