def calc_bin_cov(scaffolds, cov):
    """
    calculate bin coverage
    """
    bases = sum([cov[i][0] for i in scaffolds if i in cov])
    length = sum([cov[i][1] for i in scaffolds if i in cov])
    if length == 0:
        return 0
    return float(float(bases)/float(length))