def get_rpkm_score(hit, function_fraction, total_readcount, length_cutoff):
    """Calculates RPKM score of a single hit (number of reads per million
        reads per kilobase of reference gene)

    Args:
        hit (:obj:DiamondHit): DIAMOND hit
        function_fraction (float): fraction of the score assigned to a function
        total_readcount (int): total number of reads in the sample
        length_cutoff(int): minimal length of acceptable alignment (in amino acids)

    Returns:
        ret_val (float): RPKM score of the hit
    """
    ret_val = None
    if (hit.s_len - length_cutoff) > 0:
        ret_val = function_fraction*1000000000.0/((hit.s_len - length_cutoff)*3*total_readcount)
    else:
        ret_val = function_fraction*1000000000.0/(3*total_readcount)
    return ret_val