def gene2phen(parameters, gene, geneType):
    """
    phen = gene2phen(parameters, gene, geneType)

    Turns the genes into a phenotype value.

    gene:
        integer
    geneType:
        string
    phen:
        value

    >>> geneType = 'repn' # choose the reproduction genes type
    >>> # they have 20 alleles each, with a maximum phenological value of 1, and a minimum of -1
    >>> parameters = {'genetics': {geneType: {'noLoci': 20, 'maxPhen': 1, 'minPhen': -1, 'isInt': False} } }
    >>> gene = 0 # therefore if I take the 0th gene, which has all 0 and no 1 alleles
    >>> gene2phen(parameters, gene, geneType) # then its phenological value will be negative 1
    -1.0
    >>> parameters = { 'sexes': ( 'm', 'f' ), 'genetics': { 'repn': {'noLoci': 20, 'maxPhen': 2,  'minPhen': -2,  'isInt': False, 'pMut': 0.001} }, 'habitats': { 'L': {'rMax': 10, 'phenOpt': -1, 'sd': 1.1}, 'H': {'rMax': 10, 'phenOpt':  1, 'sd': 1.1}, }, 'competition': { 'L': 1, 'H': 10, } }
    >>> parameters = {'genetics': {geneType: {'noLoci': 20, 'maxPhen': 2, 'minPhen': -2, 'isInt': False} } }
    >>> gene2phen(parameters, 31, 'repn')
    -1.0
    """

    maxPhen = parameters['genetics'][geneType]['maxPhen']
    minPhen = parameters['genetics'][geneType]['minPhen']
    noLoci = parameters['genetics'][geneType]['noLoci']

    if parameters['genetics'][geneType]['isInt']:
        phenotype = round(minPhen + (bin(gene).count('1') / noLoci) * ( maxPhen - minPhen ))
    else:
        phenotype = minPhen + (bin(gene).count('1') / noLoci) * ( maxPhen - minPhen )

    return phenotype