/**
 * Given two sets of gene identifiers (genes expressed), this function returns a map containing the common genes
 * between the two sets and their corresponding expression levels.
 *
 * @param species1 Set of gene identifiers expressed in species 1.
 * @param species2 Set of gene identifiers expressed in species 2.
 * @param geneExpression Map containing gene identifiers as keys and their expression levels as values.
 * @return Map containing common genes between species 1 and 2 as keys, and their expression levels as values.
 */
fun findCommonGenes(species1: Set<String>, species2: Set<String>, geneExpression: Map<String, Double>): Map<String, Double> {

    val commonGenesExpression = mutableMapOf<String, Double>()
    for (gene in species1.intersect(species2)) {
        if (gene in geneExpression) {
            commonGenesExpression[gene] = geneExpression[gene]!!
        }
    }
    return commonGenesExpression
}

// Given gene sets and expression levels
val species1Genes = setOf("gene1", "gene2", "gene3", "gene4", "gene5")
val species2Genes = setOf("gene2", "gene4", "gene6", "gene8", "gene10")
val geneExpressionLevels = mapOf("gene1" to 10.5, "gene2" to 8.0)
/**
 * Given two sets of gene identifiers (genes expressed), this function returns a map containing the common genes
 * between the two sets and their corresponding expression levels.
 *
 * @param species1 Set of gene identifiers expressed in species 1.
 * @param species2 Set of gene identifiers expressed in species 2.
 * @param geneExpression Map containing gene identifiers as keys and their expression levels as values.
 * @return Map containing common genes between species 1 and 2 as keys, and their expression levels as values.
 */
fun findCommonGenes(species1: Set<String>, species2: Set<String>, geneExpression: Map<String, Double>): Map<String, Double> {
/**
 * Given two sets of gene identifiers (genes expressed), this function returns a map containing the common genes
 * between the two sets and their corresponding expression levels.
 *
 * @param species1 Set of gene identifiers expressed in species 1.
 * @param species2 Set of gene identifiers expressed in species 2.
 * @param geneExpression Map containing gene identifiers as keys and their expression levels as values.
 * @return Map containing common genes between species 1 and 2 as keys, and their expression levels as values.
 */
fun findCommonGenes(species1: Set<String>, species2: Set<String>, geneExpression: Map<String, Double>): Map<String, Double> {

    val commonGenesExpression = mutableMapOf<String, Double>()
    for (gene in species1.intersect(species2)) {
        if (gene in geneExpression) {
            commonGenesExpression[gene] = geneExpression[gene]!!
        }
    }
    return commonGenesExpression
}

// Given gene sets and expression levels
val species1Genes = setOf("gene1", "gene2", "gene3", "gene4", "gene5")
val species2Genes = setOf("gene2", "gene4", "gene6", "gene8", "gene10")
val geneExpressionLevels = mapOf("gene1" to 10.5, "gene2" to 8.0)