#!/bin/bash

cat "$1" | sort | uniq | awk '
{
  gsub(/\\/, "\\\\");
  gsub("\x27", "\\\x27");
  gsub("\"", "\\\"");
  gsub("%", "\\%");
  
  printf "INSERT IGNORE INTO `gene_name` (`geneId`, `source`) VALUES (%s, \x27GeneBank\x27);\n", $1;
  
  for (i = 2; i <= NF; i++) {
    printf "INSERT IGNORE INTO `gene_name_value` (`geneId`, `geneSource`, `name`) VALUES (%s, \x27GeneBank\x27, \x27%s\x27);\n", $1, $i;
  }
}';