   end
 
   def menu_species do
-    {:ok, rows} = DB.query("SELECT speciesid,name,menuname FROM Species")
-    for r <- rows, do: ( {id,name,fullname} = r; [id,name,fullname] )
+    query = from species in Species,
+      select: {species."SpeciesId", species."Name", species."MenuName"}
+    # {:ok, rows} = DB.query("SELECT speciesid,name,menuname FROM Species")
+    # for r <- rows, do: ( {id,name,fullname} = r; [id,name,fullname] )
+    Repo.all(query) |> Enum.map(&(Tuple.to_list(&1)))
   end
 
   def menu_groups(species) do

         chr: chr,
         "Mb": mb,
         symbol: symbol
      })
  end

  def marker_info(species,marker) do
      query = """
SELECT Geno.Chr, Geno.Mb, Species.Id,Geno.source FROM Geno, Species
WHERE Species.Name = '#{species}'
AND Geno.Name = '#{marker}'
     """
    {:ok, rows} = DB.query(query)
    for r <- rows, do: ( {chr_name,chr_len,species_id,source} = r;
      %{
        species: species,
        species_id: species_id,

      end

    limit = stop2 - start2 + 1
#     query = """
# SELECT distinct ProbeSet.Name,
#   ProbeSetXRef.Mean, ProbeSetXRef.LRS,
#   ProbeSetXRef.PVALUE, ProbeSetXRef.additive, ProbeSetXRef.locus, ProbeSet.Chr_num,
#   ProbeSet.Mb, ProbeSet.Symbol,
#   ProbeSet.name_num
# FROM ProbeSetXRef, ProbeSet
# WHERE ProbeSet.Id = ProbeSetXRef.ProbeSetId
#   and ProbeSetXRef.ProbeSetFreezeId = #{dataset_id}
#   ORDER BY ProbeSet.symbol ASC LIMIT #{limit}
#     """
#     {:ok, rows} = DB.query(query)
    # for r <- rows, do: ( {name,mean,lrs,pvalue,additive,locus,chr,mb,symbol,name_num} = r ;
    #   %{ name: name,
    #      name_id: name_num,
    #      mean: mean,
    #      "MAX_LRS": lrs,
    #      "p_value": pvalue,
    #      additive: additive,
    #      locus: locus,
    #      chr: chr,
    #      "Mb": mb,
    #      symbol: symbol
    #   })

    query = from probeset in ProbeSet,
      join: probesetxref in ProbeSetXRef,
      on: probeset.id == probesetxref."ProbeSetId",
      where: probesetxref."ProbeSetFreezeId" == ^dataset_id,
      select: {probeset."Name", probesetxref.mean, probesetxref."LRS",
               probesetxref.pValue, probesetxref.additive, probesetxref."Locus",
               probeset.chr_num, probeset."Mb", probeset."Symbol", probeset.name_num},
      distinct: true,
      order_by: probeset."symbol",
      limit: ^limit

    from_tuple_to_structure = fn(query_result) ->
      {name,mean,lrs,pvalue,additive,locus,chr,mb,symbol,name_num} = query_result
      %{ name: name,
         name_id: name_num,
         mean: mean,
