def dict_pwys_to_file(dict_pwy, output):
    """
    Create csv file from dict_pwy. dict_pwy is obtained with extract_pwys()

    Parameters
    ----------
    dict_pwy: dict
        dict, k=pathway_id, v=dict: k in [total_rxn, rxn_from_list, ratio
        ex: {pwy-x:{'total_rxn':[a,b,c], rxn_from_list:[a], ratio:1/3}}
    output: str
        path to output file

    """
    with open(output, 'w') as f:
        header = ['pathway_id', 'total_rxn', 'rxn_from_list', 'ratio']
        f.write('\t'.join(header) + '\n')
        for pwy_id, pwy_data in dict_pwy.items():
            total_rxn = pwy_data['total_rxn']
            rxn_from_list = pwy_data['rxn_from_list']
            ratio = pwy_data['ratio']
            line = [pwy_id, ';'.join(total_rxn), ';'.join(rxn_from_list),
                str(ratio)]
            f.write('\t'.join(line) + '\n')
