Class: BatchLoad::Import::Descriptors::ModifyGeneDescriptorInterpreter
- Inherits:
-
BatchLoad::Import
- Object
- BatchLoad::Import
- BatchLoad::Import::Descriptors::ModifyGeneDescriptorInterpreter
- Defined in:
- lib/batch_load/import/descriptors/modify_gene_descriptor_interpreter.rb
Instance Attribute Summary
Attributes inherited from BatchLoad::Import
#create_attempted, #csv, #errors, #file, #file_errors, #import_level, #processed, #processed_rows, #project, #project_id, #successful_rows, #total_data_lines, #total_lines, #user, #user_header_map, #user_id
Instance Method Summary collapse
- #build ⇒ Boolean
- #build_descriptors ⇒ Integer
-
#initialize(**args) ⇒ ModifyGeneDescriptorInterpreter
constructor
A new instance of ModifyGeneDescriptorInterpreter.
Methods inherited from BatchLoad::Import
#all_objects, #create, #create_attempted?, #import_level_ok?, #line_strict_level_ok?, #processed?, #ready_to_create?, #save_order, #sorted_processed_rows, #strict_level_ok?, #total_records_created, #user_map, #valid?, #valid_objects, #warn_level_ok?
Constructor Details
#initialize(**args) ⇒ ModifyGeneDescriptorInterpreter
Returns a new instance of ModifyGeneDescriptorInterpreter.
5 6 7 8 |
# File 'lib/batch_load/import/descriptors/modify_gene_descriptor_interpreter.rb', line 5 def initialize(**args) @descriptors = {} super(**args) end |
Instance Method Details
#build ⇒ Boolean
66 67 68 69 70 71 |
# File 'lib/batch_load/import/descriptors/modify_gene_descriptor_interpreter.rb', line 66 def build if valid? build_descriptors @processed = true end end |
#build_descriptors ⇒ Integer
11 12 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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/batch_load/import/descriptors/modify_gene_descriptor_interpreter.rb', line 11 def build_descriptors @total_data_lines = 0 i = 0 # loop through rows csv.each do |row| i += 1 parse_result = BatchLoad::RowParse.new parse_result.objects[:descriptor] = [] @processed_rows[i] = parse_result begin # processing # Find gene descriptor gene_name = row['gene_name'] gene_descriptor = Descriptor::Gene.find_by(name: gene_name) next if gene_descriptor.blank? # Store gene attribute logic for each primer primers_logic = { "forward_primers": [], "reverse_primers": [] } # Find each forward/reverse primers and store their gene attribute logic ['forward_primers', 'reverse_primers'].each do |primer_type| primers = row[primer_type] next if primers.blank? sequence_relationship_type = 'SequenceRelationship::' + primer_type.singularize.camelize primers.split(', ').each do |primer_name| primer_sequence = Sequence.with_any_value_for(:name, primer_name).take next if primer_sequence.blank? gene_attribute = GeneAttribute.find_by(descriptor: gene_descriptor, sequence: primer_sequence, sequence_relationship_type: sequence_relationship_type) next if gene_attribute.blank? primers_logic[primer_type.to_sym].push(gene_attribute.to_logic_literal) end end gene_descriptor_logic = '' gene_descriptor_logic += '(' + primers_logic[:forward_primers].join(' OR ') + ')' gene_descriptor_logic += ' AND ' gene_descriptor_logic += '(' + primers_logic[:reverse_primers].join(' OR ') + ')' gene_descriptor.gene_attribute_logic = gene_descriptor_logic parse_result.objects[:descriptor].push(gene_descriptor) @total_data_lines += 1 # rescue end end @total_lines = i end |