Class: Import::Sequences::GenbankInterpreter

Inherits:
BatchLoad::Import
  • Object
show all
Includes:
BatchLoad::Helpers::Sequences
Defined in:
lib/batch_file_load/import/sequences/genbank_interpreter.rb,
lib/batch_load/import/sequences/genbank_interpreter.rb

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ GenbankInterpreter

Returns a new instance of GenbankInterpreter.

Parameters:

  • args (Hash)


6
7
8
# File 'lib/batch_file_load/import/sequences/genbank_interpreter.rb', line 6

def initialize(**args)
  super(**args)
end

Instance Method Details

#buildBoolean

Returns:

  • (Boolean)


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/batch_file_load/import/sequences/genbank_interpreter.rb', line 32

def build
  return if !valid?
  @processed = true

  @filenames.each_with_index do |filename, file_index|
    objects_in_file = {}
    objects_in_file[:sequence] = []
    objects_in_file[:origin_relationship] = []

    sequence = create_sequence(filename, @file_contents[file_index])
    objects_in_file[:sequence].push(sequence)

    origin_relationship = create_origin_relationship(filename, sequence)
    objects_in_file[:origin_relationship].push(origin_relationship) if origin_relationship

    @processed_files[:names].push(filename)
    @processed_files[:objects].push(objects_in_file)
  end
end

#build_sequencesInteger

TODO: update this

Returns:

  • (Integer)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/batch_load/import/sequences/genbank_interpreter.rb', line 13

def build_sequences
  @total_data_lines = 0
  i = 0
  # loop through rows
  csv.each do |row|
    i += 1

    parse_result = BatchLoad::RowParse.new
    parse_result.objects[:sequence] = []
    parse_result.objects[:origin_relationship] = []

    @processed_rows[i] = parse_result

    begin # processing
      # use a BatchLoad::ColumnResolver or other method to match row data to TW
      #  ...

      sequence = create_sequence(row['filename'], row['file_content'])
      parse_result.objects[:sequence].push(sequence)

      origin_relationship = create_origin_relationship(row['filename'], sequence)
      parse_result.objects[:origin_relationship].push(origin_relationship) if origin_relationship
      @total_data_lines += 1 if sequence.present?
    #rescue
       # ....
    end
  end

  @total_lines = i
end