def velvet(readsize, genomesize, numreads, K):
    """
    Calculate velvet memory requirement.
    <http://seqanswers.com/forums/showthread.php?t=2101>

    Ram required for velvetg = -109635 + 18977*ReadSize + 86326*GenomeSize +
    233353*NumReads - 51092*K

    Read size is in bases.
    Genome size is in millions of bases (Mb)
    Number of reads is in millions
    K is the kmer hash value used in velveth
    """
    ram = -109635 + 18977 * readsize + 86326 * genomesize + \
            233353 * numreads - 51092 * K
    print("ReadSize: {0}".format(readsize), file=sys.stderr)
    print("GenomeSize: {0}Mb".format(genomesize), file=sys.stderr)
    print("NumReads: {0}M".format(numreads), file=sys.stderr)
    print("K: {0}".format(K), file=sys.stderr)

    ram = human_size(ram * 1000, a_kilobyte_is_1024_bytes=True)
    print("RAM usage: {0} (MAXKMERLENGTH=31)".format(ram), file=sys.stderr)