Estimate Java memory requirements based on number of samples.

    A rough approach to selecting correct allocated memory for Cromwell.

def _estimate_runner_memory(json_file):
    """Estimate Java memory requirements based on number of samples.

    A rough approach to selecting correct allocated memory for Cromwell.
    """
    with open(json_file) as in_handle:
        sinfo = json.load(in_handle)
    num_parallel = 1
    for key in ["config__algorithm__variantcaller", "description"]:
        item_counts = []
        n = 0
        for val in (sinfo.get(key) or []):
            n += 1
            if val:
                if isinstance(val, (list, tuple)):
                    item_counts.append(len(val))
                else:
                    item_counts.append(1)
        print(key, n, item_counts)
        if n and item_counts:
            num_parallel = n * max(item_counts)
            break
    if num_parallel < 25:
        return "3g"
    if num_parallel < 150:
        return "6g"
    elif num_parallel < 500:
        return "12g"
    else:
        return "24g"