def merge_chunk_data(output_file="<STR_LIT>", *files):
chunks = dict()<EOL>for chunk_file in files:<EOL><INDENT>with open(chunk_file) as chunk_file_handle:<EOL><INDENT>for line in chunk_file_handle:<EOL><INDENT>chunk_id, chunk_name, hit, size, cov = line.split("<STR_LIT:\t>")<EOL>try:<EOL><INDENT>chunks[chunk_id]["<STR_LIT>"] += hit<EOL>chunks[chunk_id]["<STR_LIT>"] += cov<EOL><DEDENT>except KeyError:<EOL><INDENT>chunks[chunk_id] = {<EOL>"<STR_LIT:name>": chunk_name,<EOL>"<STR_LIT>": hit,<EOL>"<STR_LIT:size>": size,<EOL>"<STR_LIT>": cov,<EOL>}<EOL><DEDENT><DEDENT><DEDENT><DEDENT>sorted_chunks = sorted(chunks)<EOL>with open(output_file, "<STR_LIT:w>") as output_handle:<EOL><INDENT>for chunk_id in sorted_chunks:<EOL><INDENT>my_chunk = chunks[chunk_id]<EOL>name, hit, size, cov = (<EOL>my_chunk["<STR_LIT:name>"],<EOL>my_chunk["<STR_LIT>"],<EOL>my_chunk["<STR_LIT:size>"],<EOL>my_chunk["<STR_LIT>"],<EOL>)<EOL>my_line = "<STR_LIT>".format(<EOL>chunk_id, name, hit, size, cov<EOL>)<EOL>output_handle.write(my_line)<EOL><DEDENT><DEDENT>
Merge chunk data from different networks

    Similarly to merge_network, this merges any number of chunk data files.

    Parameters
    ---------
    output_file : file, str, or pathlib.Path, optional
        The output file to write the merged chunk data files into. Default is
        merged_idx_contig_hit_size_cov.txt
    `*files` : file, str or pathlib.Path
        The chunk data files to merge.