lib/seek/parser_mapper.rb
def duesseldorf_bode_mapping

      concentration_regex = /(\d*,?\.?\d*).*/
      gene_modification_regex = /([\w\d]+)([\/+-]+)/

      {
              :name => "duesseldorf_bode",
              :data_row_offset => 1,


              :samples_mapping => {
                  :samples_sheet_name => "Tabelle2",
                  :add_specimens => true,
                  :add_treatments => true,
                  :add_samples => true,

                  :probing_column => :"specimens.title",

                  :"organisms.title" => mapping_entry("species"),

                  :"strains.title" => mapping_entry("strain"),

                  :"specimens.sex" => mapping_entry("sex"),
                  :"specimens.title" => mapping_entry("Animal Nr."),
                  :"specimens.lab_internal_number" => mapping_entry("Animal Nr."),
                  :"specimens.age" => mapping_entry("Age (Weeks)"),
                  :"specimens.age_unit" => mapping_entry("FIXED", proc {"week"}),
                  :"specimens.comments" => mapping_entry("Specials", proc {|data| data == "-" ? "" : data }),
                  :"specimens.genotype.title" => mapping_entry("Genotype", proc do |data|
                       if data =~ gene_modification_regex
                         $1
                       else
                         "none"
                       end
                  end),
                  :"specimens.genotype.modification" => mapping_entry("Genotype", proc do |data|
                      if data =~ gene_modification_regex
                        $2
                      else
                        ""
                      end
                  end),

                  :"treatment.treatment_protocol" => mapping_entry("FIXED", proc {""}),
                  :"treatment.type" => mapping_entry("FIXED", proc {"concentration"}),
                  :"treatment.comments" => mapping_entry("FIXED", proc {""}),
                  :"treatment.substance" => mapping_entry("FIXED", proc {"LPS"}),
                  :"treatment.concentration" => mapping_entry("LPS (µg/g KG)", proc do |data|
                    if data =~ concentration_regex
                      $1.gsub(/,/, ".")
                    else
                      ""
                    end
                  end),
                  :"treatment.unit" => mapping_entry("FIXED", proc {"µg/g KG"}),
                  :"treatment.incubation_time" => mapping_entry("Incubation period x Std."),
                  :"treatment.incubation_time_unit" => mapping_entry("FIXED", proc {"hour"}),


                  :"samples.comments" => mapping_entry("FIXED", proc {""}),
                  :"samples.title" => mapping_entry("Animal Nr.", proc { |data| data + "_liver"}),
                  :"samples.sample_type" => mapping_entry("FIXED", proc {"liver"}),
                  :"samples.donation_date" => mapping_entry("Donation Date"),
                  :"samples.organism_part"  => mapping_entry("FIXED", proc {"organ"}),

                  :"tissue_and_cell_types.title" => mapping_entry("FIXED", proc {"Liver"}),

                  :"sop.title" => mapping_entry("FIXED", proc {""}),
                  :"institution.title" => mapping_entry("FIXED", proc {""})
              },


              :assay_mapping => {

                  :assay_sheet_name => "Tabelle2",
                  :parsing_direction => "vertical",
                  :probing_column => :"creator.last_name",

                  :"investigation.title" => mapping_entry("FIXED", proc { nil }),
                  :"assay_type.title" => mapping_entry("FIXED", proc { nil }),
                  :"study.title" => mapping_entry("FIXED", proc { nil }),

                  :"creator.email" => mapping_entry("FIXED", proc { "" }),
                  :"creator.last_name" => mapping_entry("experimentator", proc do |data|
                    if data.split(/\s+/)
                      data.split(/\s+/).last
                    end
                  end),
                  :"creator.first_name" => mapping_entry("experimentator", proc do |data|
                    if data.split(/\s+/)
                      data.split(/\s+/).first
                    end
                  end)

              }

      }

    end
# mapping for duesseldorf excel sheet
# example file: due_bode_Tierbestandsliste G96 parsing format.xls
mapping for duesseldorf excel sheet
example file: due_bode_Tierbestandsliste G96 parsing format.xls
mapping for duesseldorf excel sheet example file : due_bode_Tierbestandsliste G96 parsing format . xls
def duesseldorf_bode_mapping
      concentration_regex = /(\d*,?\.?\d*).*/
      gene_modification_regex = /([\w\d]+)([\/+-]+)/
      {
              :name => "duesseldorf_bode",
              :data_row_offset => 1,
              :samples_mapping => {
                  :samples_sheet_name => "Tabelle2",
                  :add_specimens => true,
                  :add_treatments => true,
                  :add_samples => true,
                  :probing_column => :"specimens.title",
                  :"organisms.title" => mapping_entry("species"),
                  :"strains.title" => mapping_entry("strain"),
                  :"specimens.sex" => mapping_entry("sex"),
                  :"specimens.title" => mapping_entry("Animal Nr."),
                  :"specimens.lab_internal_number" => mapping_entry("Animal Nr."),
                  :"specimens.age" => mapping_entry("Age (Weeks)"),
                  :"specimens.age_unit" => mapping_entry("FIXED", proc {"week"}),
                  :"specimens.comments" => mapping_entry("Specials", proc {|data| data == "-" ? "" : data }),
                  :"specimens.genotype.title" => mapping_entry("Genotype", proc do |data|
                       if data =~ gene_modification_regex
                         $1
                       else
                         "none"
                       end
                  end),
                  :"specimens.genotype.modification" => mapping_entry("Genotype", proc do |data|
                      if data =~ gene_modification_regex
                        $2
                      else
                        ""
                      end
                  end),
                  :"treatment.treatment_protocol" => mapping_entry("FIXED", proc {""}),
                  :"treatment.type" => mapping_entry("FIXED", proc {"concentration"}),
                  :"treatment.comments" => mapping_entry("FIXED", proc {""}),
                  :"treatment.substance" => mapping_entry("FIXED", proc {"LPS"}),
                  :"treatment.concentration" => mapping_entry("LPS (µg/g KG)", proc do |data|
                    if data =~ concentration_regex
                      $1.gsub(/,/, ".")
                    else
                      ""
                    end
                  end),
                  :"treatment.unit" => mapping_entry("FIXED", proc {"µg/g KG"}),
                  :"treatment.incubation_time" => mapping_entry("Incubation period x Std."),
                  :"treatment.incubation_time_unit" => mapping_entry("FIXED", proc {"hour"}),
                  :"samples.comments" => mapping_entry("FIXED", proc {""}),
                  :"samples.title" => mapping_entry("Animal Nr.", proc { |data| data + "_liver"}),
                  :"samples.sample_type" => mapping_entry("FIXED", proc {"liver"}),
                  :"samples.donation_date" => mapping_entry("Donation Date"),
                  :"samples.organism_part"  => mapping_entry("FIXED", proc {"organ"}),
                  :"tissue_and_cell_types.title" => mapping_entry("FIXED", proc {"Liver"}),
                  :"sop.title" => mapping_entry("FIXED", proc {""}),
                  :"institution.title" => mapping_entry("FIXED", proc {""})
              },
              :assay_mapping => {
                  :assay_sheet_name => "Tabelle2",
                  :parsing_direction => "vertical",
                  :probing_column => :"creator.last_name",
                  :"investigation.title" => mapping_entry("FIXED", proc { nil }),
                  :"assay_type.title" => mapping_entry("FIXED", proc { nil }),
                  :"study.title" => mapping_entry("FIXED", proc { nil }),
                  :"creator.email" => mapping_entry("FIXED", proc { "" }),
                  :"creator.last_name" => mapping_entry("experimentator", proc do |data|
                    if data.split(/\s+/)
                      data.split(/\s+/).last
                    end
                  end),
                  :"creator.first_name" => mapping_entry("experimentator", proc do |data|
                    if data.split(/\s+/)
                      data.split(/\s+/).first
                    end
                  end)
              }
      }
    end
def duesseldorf_bode_mapping concentration_regex = / ( \d *,? \. ? \d *).* / gene_modification_regex = / ([ \w \d ]+)([ \/ +-]+) / { :name => "duesseldorf_bode" , :data_row_offset => 1 , :samples_mapping => { :samples_sheet_name => "Tabelle2" , :add_specimens => true , :add_treatments => true , :add_samples => true , :probing_column => :" specimens.title " , :" organisms.title " => mapping_entry ( "species" ) , :" strains.title " => mapping_entry ( "strain" ) , :" specimens.sex " => mapping_entry ( "sex" ) , :" specimens.title " => mapping_entry ( "Animal Nr." ) , :" specimens.lab_internal_number " => mapping_entry ( "Animal Nr." ) , :" specimens.age " => mapping_entry ( "Age (Weeks)" ) , :" specimens.age_unit " => mapping_entry ( "FIXED" , proc { "week" } ) , :" specimens.comments " => mapping_entry ( "Specials" , proc { | data | data == "-" ? "" : data } ) , :" specimens.genotype.title " => mapping_entry ( "Genotype" , proc do | data | if data =~ gene_modification_regex $1 else "none" end end ) , :" specimens.genotype.modification " => mapping_entry ( "Genotype" , proc do | data | if data =~ gene_modification_regex $2 else "" end end ) , :" treatment.treatment_protocol " => mapping_entry ( "FIXED" , proc { "" } ) , :" treatment.type " => mapping_entry ( "FIXED" , proc { "concentration" } ) , :" treatment.comments " => mapping_entry ( "FIXED" , proc { "" } ) , :" treatment.substance " => mapping_entry ( "FIXED" , proc { "LPS" } ) , :" treatment.concentration " => mapping_entry ( "LPS (µg/g KG)", roc  o  d ata| if data =~ concentration_regex $1 . gsub ( / , / , "." ) else "" end end ) , :" treatment.unit " => mapping_entry ( "FIXED" , proc { "µg/g KG"} ) , :" treatment.incubation_time " => mapping_entry ( "Incubation period x Std." ) , :" treatment.incubation_time_unit " => mapping_entry ( "FIXED" , proc { "hour" } ) , :" samples.comments " => mapping_entry ( "FIXED" , proc { "" } ) , :" samples.title " => mapping_entry ( "Animal Nr." , proc { | data | data + "_liver" } ) , :" samples.sample_type " => mapping_entry ( "FIXED" , proc { "liver" } ) , :" samples.donation_date " => mapping_entry ( "Donation Date" ) , :" samples.organism_part " => mapping_entry ( "FIXED" , proc { "organ" } ) , :" tissue_and_cell_types.title " => mapping_entry ( "FIXED" , proc { "Liver" } ) , :" sop.title " => mapping_entry ( "FIXED" , proc { "" } ) , :" institution.title " => mapping_entry ( "FIXED" , proc { "" } ) } , :assay_mapping => { :assay_sheet_name => "Tabelle2" , :parsing_direction => "vertical" , :probing_column => :" creator.last_name " , :" investigation.title " => mapping_entry ( "FIXED" , proc { nil } ) , :" assay_type.title " => mapping_entry ( "FIXED" , proc { nil } ) , :" study.title " => mapping_entry ( "FIXED" , proc { nil } ) , :" creator.email " => mapping_entry ( "FIXED" , proc { "" } ) , :" creator.last_name " => mapping_entry ( "experimentator" , proc do | data | if data . split ( / \s + / ) data . split ( / \s + / ) . last end end ) , :" creator.first_name " => mapping_entry ( "experimentator" , proc do | data | if data . split ( / \s + / ) data . split ( / \s + / ) . first end end ) } } end
mapping for duesseldorf excel sheet
example file: due_bode_Tierbestandsliste G96 parsing format.xls
mapping for duesseldorf excel sheet example file : due_bode_Tierbestandsliste G96 parsing format . xls