Combine coverage cnns calculated for individual inputs into single file.

    Optionally moves over pre-calculated coverage samples from a background file.

def _combine_coverages(items, work_dir, input_backs=None):
    """Combine coverage cnns calculated for individual inputs into single file.

    Optionally moves over pre-calculated coverage samples from a background file.
    """
    out_file = os.path.join(work_dir, "sample_coverages.txt")
    if not utils.file_exists(out_file):
        with file_transaction(items[0], out_file) as tx_out_file:
            with open(tx_out_file, 'w') as out_f:
                for data in items:
                    cov_file = tz.get_in(["depth", "bins", "seq2c"], data)
                    with open(cov_file) as cov_f:
                        out_f.write(cov_f.read())
                if input_backs:
                    for input_back in input_backs:
                        with open(input_back) as in_handle:
                            for line in in_handle:
                                if len(line.split()) >= 4:
                                    out_f.write(line)
    return out_file