lib/seek/parser_mapper.rb
def dortmund_hengstler_mapping

      age_regex = /(\d+-?\d*)\s*(day|week|month|year)s?/i
      treatment_regex = /(\d*\.?\d*)\s*(\w+\/\w+)\s*([\w\.\s,']*),?\s+([\w\.]*)/
      incubation_time_regex = /(\d+\.?\d*)(\w{1})/




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


          :samples_mapping => {

              :samples_sheet_name => "Tabelle1",
              :add_specimens => true,
              :add_treatments => true,
              :add_samples => true,

              :probing_column => :"specimens.title",


              :"organisms.title" => mapping_entry("FIXED", proc {"Mus musculus"}),

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


              :"specimens.institution_id" => mapping_entry("Responsible Lab"),
              :"specimens.title" => mapping_entry("Lab internal number", proc { |data| data.chomp(".0")}),
              :"specimens.lab_internal_number" => mapping_entry("Lab internal number", proc { |data| data.chomp(".0")}),
              :"specimens.sex" => mapping_entry("FIXED", proc {"unknown"}),
              :"specimens.age" => mapping_entry("Age", proc do |data|
                  if data =~ age_regex
                    $1 ? $1 : ""
                  else
                    ""
                  end
              end),
              :"specimens.age_unit" => mapping_entry("Age", proc do |data|
                  if data =~ age_regex
                    $2 ? $2 : ""
                  else
                    ""
                  end
              end),




              :"specimens.donation_date" => mapping_entry("date of experiment"),
              :"specimens.comments" => mapping_entry("FIXED", proc {""}),
              :"specimens.genotype.title" => mapping_entry("FIXED", proc {"none"}),
              :"specimens.genotype.modification" => mapping_entry("FIXED", proc{""}),

              :"treatment.concentration" => mapping_entry("Treatment", proc do |data|
                if data =~ treatment_regex
                  $1 ? $1 : ""
                else
                  ""
                end
              end),
              :"treatment.unit" => mapping_entry("Treatment", proc do |data|
                if data =~ treatment_regex
                  $2 ? $2 : ""
                else
                  ""
                end
              end),
              :"treatment.substance" => mapping_entry("Treatment", proc do |data|
                if data =~ treatment_regex
                  if $3
                    substance = $3
                    if substance.end_with?(',')
                      substance.chop
                    else
                      substance
                    end
                  else
                    ""
                  end
                else
                  ""
                end
              end),
              :"treatment.treatment_protocol" => mapping_entry("Treatment", proc do |data|
                if data =~ treatment_regex
                  $4 ? $4 : ""
                else
                  ""
                end
              end),
              :"treatment.type" => mapping_entry("FIXED", proc {"concentration"}),
              :"treatment.comments" => mapping_entry("FIXED", proc {""}),
              :"treatment.incubation_time" => mapping_entry("Explantation", proc do |data|
                  if data =~ incubation_time_regex
                    $1
                  else
                    ""
                  end
              end),

              :"treatment.incubation_time_unit" => mapping_entry("Explantation", proc do |data|
                if data =~ incubation_time_regex
                  case $2
                    when "d" then "day"
                    when "h" then "hour"
                    when "w" then "week"
                    else ""
                  end
                else
                  ""
                end
              end),

              :"samples.comments" => mapping_entry("Comments"),
              :"samples.title" => mapping_entry("Tissue specimen no.", proc { |data| data.chomp(".0")}),
              :"samples.sample_type" => mapping_entry("FIXED", proc {""}),
              :"samples.donation_date" => mapping_entry("date of experiment"),
              :"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 => "Tabelle1",
              :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.gsub(data.split(/\s+/).last, "").chop
                end
              end)

          }




      }

    end
# mapping for dortmund excel sheets (I)
# example file: do_hengstler_Sample Data Hengstler_corrected.xls
mapping for dortmund excel sheets (I)
example file: do_hengstler_Sample Data Hengstler_corrected.xls
mapping for dortmund excel sheets ( I ) example file : do_hengstler_Sample Data Hengstler_corrected . xls
def dortmund_hengstler_mapping
      age_regex = /(\d+-?\d*)\s*(day|week|month|year)s?/i
      treatment_regex = /(\d*\.?\d*)\s*(\w+\/\w+)\s*([\w\.\s,']*),?\s+([\w\.]*)/
      incubation_time_regex = /(\d+\.?\d*)(\w{1})/
      {
          :name => "dortmund_hengstler",
          :data_row_offset => 1,
          :samples_mapping => {
              :samples_sheet_name => "Tabelle1",
              :add_specimens => true,
              :add_treatments => true,
              :add_samples => true,
              :probing_column => :"specimens.title",
              :"organisms.title" => mapping_entry("FIXED", proc {"Mus musculus"}),
              :"strains.title" => mapping_entry("Mouse strain"),
              :"specimens.institution_id" => mapping_entry("Responsible Lab"),
              :"specimens.title" => mapping_entry("Lab internal number", proc { |data| data.chomp(".0")}),
              :"specimens.lab_internal_number" => mapping_entry("Lab internal number", proc { |data| data.chomp(".0")}),
              :"specimens.sex" => mapping_entry("FIXED", proc {"unknown"}),
              :"specimens.age" => mapping_entry("Age", proc do |data|
                  if data =~ age_regex
                    $1 ? $1 : ""
                  else
                    ""
                  end
              end),
              :"specimens.age_unit" => mapping_entry("Age", proc do |data|
                  if data =~ age_regex
                    $2 ? $2 : ""
                  else
                    ""
                  end
              end),
              :"specimens.donation_date" => mapping_entry("date of experiment"),
              :"specimens.comments" => mapping_entry("FIXED", proc {""}),
              :"specimens.genotype.title" => mapping_entry("FIXED", proc {"none"}),
              :"specimens.genotype.modification" => mapping_entry("FIXED", proc{""}),
              :"treatment.concentration" => mapping_entry("Treatment", proc do |data|
                if data =~ treatment_regex
                  $1 ? $1 : ""
                else
                  ""
                end
              end),
              :"treatment.unit" => mapping_entry("Treatment", proc do |data|
                if data =~ treatment_regex
                  $2 ? $2 : ""
                else
                  ""
                end
              end),
              :"treatment.substance" => mapping_entry("Treatment", proc do |data|
                if data =~ treatment_regex
                  if $3
                    substance = $3
                    if substance.end_with?(',')
                      substance.chop
                    else
                      substance
                    end
                  else
                    ""
                  end
                else
                  ""
                end
              end),
              :"treatment.treatment_protocol" => mapping_entry("Treatment", proc do |data|
                if data =~ treatment_regex
                  $4 ? $4 : ""
                else
                  ""
                end
              end),
              :"treatment.type" => mapping_entry("FIXED", proc {"concentration"}),
              :"treatment.comments" => mapping_entry("FIXED", proc {""}),
              :"treatment.incubation_time" => mapping_entry("Explantation", proc do |data|
                  if data =~ incubation_time_regex
                    $1
                  else
                    ""
                  end
              end),
              :"treatment.incubation_time_unit" => mapping_entry("Explantation", proc do |data|
                if data =~ incubation_time_regex
                  case $2
                    when "d" then "day"
                    when "h" then "hour"
                    when "w" then "week"
                    else ""
                  end
                else
                  ""
                end
              end),
              :"samples.comments" => mapping_entry("Comments"),
              :"samples.title" => mapping_entry("Tissue specimen no.", proc { |data| data.chomp(".0")}),
              :"samples.sample_type" => mapping_entry("FIXED", proc {""}),
              :"samples.donation_date" => mapping_entry("date of experiment"),
              :"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 => "Tabelle1",
              :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.gsub(data.split(/\s+/).last, "").chop
                end
              end)
          }
      }
    end
def dortmund_hengstler_mapping age_regex = / ( \d +-? \d *) \s *(day|week|month|year)s? /i treatment_regex = / ( \d * \. ? \d *) \s *( \w + \/ \w +) \s *([ \w \. \s ,']*),? \s +([ \w \. ]*) / incubation_time_regex = / ( \d + \. ? \d *)( \w {1}) / { :name => "dortmund_hengstler" , :data_row_offset => 1 , :samples_mapping => { :samples_sheet_name => "Tabelle1" , :add_specimens => true , :add_treatments => true , :add_samples => true , :probing_column => :" specimens.title " , :" organisms.title " => mapping_entry ( "FIXED" , proc { "Mus musculus" } ) , :" strains.title " => mapping_entry ( "Mouse strain" ) , :" specimens.institution_id " => mapping_entry ( "Responsible Lab" ) , :" specimens.title " => mapping_entry ( "Lab internal number" , proc { | data | data . chomp ( ".0" ) } ) , :" specimens.lab_internal_number " => mapping_entry ( "Lab internal number" , proc { | data | data . chomp ( ".0" ) } ) , :" specimens.sex " => mapping_entry ( "FIXED" , proc { "unknown" } ) , :" specimens.age " => mapping_entry ( "Age" , proc do | data | if data =~ age_regex $1 ? $1 : "" else "" end end ) , :" specimens.age_unit " => mapping_entry ( "Age" , proc do | data | if data =~ age_regex $2 ? $2 : "" else "" end end ) , :" specimens.donation_date " => mapping_entry ( "date of experiment" ) , :" specimens.comments " => mapping_entry ( "FIXED" , proc { "" } ) , :" specimens.genotype.title " => mapping_entry ( "FIXED" , proc { "none" } ) , :" specimens.genotype.modification " => mapping_entry ( "FIXED" , proc { "" } ) , :" treatment.concentration " => mapping_entry ( "Treatment" , proc do | data | if data =~ treatment_regex $1 ? $1 : "" else "" end end ) , :" treatment.unit " => mapping_entry ( "Treatment" , proc do | data | if data =~ treatment_regex $2 ? $2 : "" else "" end end ) , :" treatment.substance " => mapping_entry ( "Treatment" , proc do | data | if data =~ treatment_regex if $3 substance = $3 if substance . end_with? ( ',' ) substance . chop else substance end else "" end else "" end end ) , :" treatment.treatment_protocol " => mapping_entry ( "Treatment" , proc do | data | if data =~ treatment_regex $4 ? $4 : "" else "" end end ) , :" treatment.type " => mapping_entry ( "FIXED" , proc { "concentration" } ) , :" treatment.comments " => mapping_entry ( "FIXED" , proc { "" } ) , :" treatment.incubation_time " => mapping_entry ( "Explantation" , proc do | data | if data =~ incubation_time_regex $1 else "" end end ) , :" treatment.incubation_time_unit " => mapping_entry ( "Explantation" , proc do | data | if data =~ incubation_time_regex case $2 when "d" then "day" when "h" then "hour" when "w" then "week" else "" end else "" end end ) , :" samples.comments " => mapping_entry ( "Comments" ) , :" samples.title " => mapping_entry ( "Tissue specimen no." , proc { | data | data . chomp ( ".0" ) } ) , :" samples.sample_type " => mapping_entry ( "FIXED" , proc { "" } ) , :" samples.donation_date " => mapping_entry ( "date of experiment" ) , :" 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 => "Tabelle1" , :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 . gsub ( data . split ( / \s + / ) . last , "" ) . chop end end ) } } end
mapping for dortmund excel sheets (I)
example file: do_hengstler_Sample Data Hengstler_corrected.xls
mapping for dortmund excel sheets ( I ) example file : do_hengstler_Sample Data Hengstler_corrected . xls