//"Rat"
useDB('eqtl_stockholm_eae_logplier', $qtldb);
$loci2stable_ids_ex2 = loci2stable_ids($loci_ex2, $qtldb);
$unique_ens_ids_ex2 = get_unique_vals_from_2d_array($loci2stable_ids_ex2[0]);
// HOMOLOGY => do it on the fewer
$n_loci_ex1 = sizeof($unique_ens_ids_ex1);
$n_loci_ex2 = sizeof($unique_ens_ids_ex2);
$traits12traits2 = array();
if ($n_loci_ex1 < $n_loci_ex2) {
    $homology_ex1 = get_homologue_ens_ids($compara, $unique_ens_ids_ex1, $genome_db_ids[1]);
    //intersection
    foreach ($homology_ex1 as $unique_id_ex1 => $corr_homologue_ens_ids_ex1) {
        $traits12traits2[$unique_id_ex1] = array_intersect($corr_homologue_ens_ids_ex1, $unique_ens_ids_ex2);
    }
} else {
    $homology_ex2 = get_homologue_ens_ids($compara, $unique_ens_ids_ex2, $genome_db_ids[0]);
    //intersection
    foreach ($unique_ens_ids_ex1 as $id_ex1) {
        $traits12traits2[$id_ex1] = array();
    }
    foreach ($homology_ex2 as $unique_id_ex2 => $corr_homologue_ens_ids_ex2) {
        $intersect = array_intersect($corr_homologue_ens_ids_ex2, $unique_ens_ids_ex1);
        foreach ($intersect as $id_ex1) {
            $traits12traits2[$id_ex1][] = $unique_id_ex2;
        }
    }
}
//warn($traits12traits2);
// display -----------------------
include 'utils/write_all_table.php';
$cols = 227;
// HOMOLOGY => do it on the fewer genes
$n_ens_ids_ex1 = sizeof($unique_ens_ids_ex1);
$n_ens_ids_ex2 = sizeof($unique_ens_ids_ex2);
$traits12traits2 = array();
if ($n_ens_ids_ex1 < $n_ens_ids_ex2) {
    // homology on experiment 1
    $homology_ex1 = get_homologue_ens_ids($compara, $unique_ens_ids_ex1, $experiment2['ensembl_species']);
    //intersection
    foreach ($homology_ex1 as $unique_id_ex1 => $corr_homologue_ens_ids_ex2) {
        $intersect = array_intersect(array_keys($corr_homologue_ens_ids_ex2), $unique_ens_ids_ex2);
        foreach ($intersect as $id_ex2) {
            $traits12traits2[$unique_id_ex1][$id_ex2] = $corr_homologue_ens_ids_ex2[$id_ex2];
        }
    }
} else {
    $homology_ex2 = get_homologue_ens_ids($compara, $unique_ens_ids_ex2, $experiment1['ensembl_species']);
    //intersection
    foreach ($unique_ens_ids_ex1 as $id_ex1) {
        $traits12traits2[$id_ex1] = array();
    }
    foreach ($homology_ex2 as $unique_id_ex2 => $corr_homologue_ens_ids_ex1) {
        $intersect = array_intersect(array_keys($corr_homologue_ens_ids_ex1), $unique_ens_ids_ex1);
        foreach ($intersect as $id_ex1) {
            $traits12traits2[$id_ex1][$unique_id_ex2] = $corr_homologue_ens_ids_ex1[$id_ex1];
        }
    }
}
function deleteNonHomos(&$loci2stable_ids_ex, $is_homo)
{
    foreach ($loci2stable_ids_ex[0] as $locus => $traits) {
        foreach ($traits as $numkey => $trait) {