예제 #1
0
def enumeration(sbml_folder, target_file, seed_file, output_json, host_file):
    """Run miscoto enumeration on one target file

    Args:
        sbml_folder (str): sbml directory
        target_file (str): targets file
        seed_file (str): seeds file
        output_json (str): path to json output
        host_file (str): metabolic network file for host

    Returns:
        str: path to output json
    """
    results = miscoto.run_mincom(option="soup",
                                 bacteria_dir=sbml_folder,
                                 targets_file=target_file,
                                 seeds_file=seed_file,
                                 host_file=host_file,
                                 intersection=True,
                                 enumeration=True,
                                 union=True,
                                 optsol=True,
                                 output_json=output_json)

    # Give union of solutions
    union = results['union_bacteria']
    logger.info(
        '######### Keystone species: Union of minimal communities #########')
    logger.info(
        "# Bacteria occurring in at least one minimal community enabling the producibility of the target metabolites given as inputs"
    )
    logger.info("Keystone species = " + str(len(union)))
    logger.info("\n".join(union))
    # Give intersection of solutions
    intersection = results['inter_bacteria']
    logger.info(
        '######### Essential symbionts: Intersection of minimal communities #########'
    )
    logger.info(
        "# Bacteria occurring in ALL minimal community enabling the producibility of the target metabolites given as inputs"
    )
    logger.info("Essential symbionts = " + str(len(intersection)))
    logger.info("\n".join(intersection))
    # Give keystones, essential and alternative symbionts
    alternative_symbionts = list(set(union) - set(intersection))
    logger.info(
        '######### Alternative symbionts: Difference between Union and Intersection #########'
    )
    logger.info(
        "# Bacteria occurring in at least one minimal community but not all minimal community enabling the producibility of the target metabolites given as inputs"
    )
    logger.info("Alternative symbionts = " + str(len(alternative_symbionts)))
    logger.info("\n".join(alternative_symbionts))

    return output_json
예제 #2
0
def compute_mincom(instancefile, output_dir):
    """Run minimal community selection and analysis.
    
    Args:
        instancefile (str): filepath to instance file
        output_dir (str): directory with results
    
    Returns:
        dict: results of miscoto_mincom analysis
    """
    miscoto_dir = output_dir + "/community_analysis"
    if not utils.is_valid_dir(miscoto_dir):
        logger.critical("Impossible to access/create output directory")
        sys.exit(1)

    results_dic = run_mincom(option="soup",
                             lp_instance_file=instancefile,
                             optsol=True,
                             union=True,
                             intersection=True)
    return results_dic