Esempio n. 1
0
def get_benchmark_template(config: Dict, software: Software, **kwargs) -> str:
    """
    Creates a name template of .tsv output files produced by specific software.
    """
    rule_name = kwargs.get("rule_name",
                           "rule_name keyword argument must be provided")
    assert rule_name

    template_args = kwargs.copy()
    template_args.pop("rule_name")

    heuristic = kwargs.get("heuristic", None)
    if heuristic:
        template_args.pop("heuristic")

    # Skip the first character assuming to keep the name convention as
    # {pruning}_arg1{arg1}_arg2{arg2}, not p{pruning}_arg1{arg1}...
    filename_template = join_kwargs(**template_args)[1:]

    software_name = software.name.lower()
    if software == PlacementSoftware.EPANG:
        valid_heuristics = ("h1", "h2", "h3", "h4")
        assert heuristic and heuristic in valid_heuristics, f"{heuristic} is not a valid heuristic."
        software_name = software.name.lower() + f"-{heuristic}"

    return os.path.join(
        cfg.get_work_dir(config), "benchmarks", filename_template + "_" +
        software_name + "-" + rule_name + "_benchmark.tsv")
Esempio n. 2
0
def get_ar_output_templates(config: Dict, arsoft: str) -> List[str]:
    """
    Returns a list of resulting files of the ancestral reconstruction stage.
    """

    # FIXME: Make a software class for every AR software, and make output directories
    # for every AR software
    output_dir = os.path.join(cfg.get_work_dir(config), "RAPPAS", "{pruning}",
                              "red{red}_ar" + arsoft.upper(), "AR")

    if arsoft == "PHYML":
        output_filenames = [
            "extended_align.phylip_phyml_ancestral_seq.txt",
            "extended_align.phylip_phyml_ancestral_tree.txt",
            "extended_align.phylip_phyml_stats.txt",
            "extended_align.phylip_phyml_tree.txt"
        ]
    elif arsoft == "RAXMLNG":
        output_filenames = [
            "extended_align.phylip.raxml.log",
            "extended_align.phylip.raxml.ancestralTree",
            "extended_align.phylip.raxml.ancestralProbs",
            "extended_align.phylip.raxml.startTree",
            "extended_align.phylip.raxml.ancestralStates",
            "extended_align.phylip.raxml.rba"
        ]
    elif arsoft == "PAML":
        output_filenames = ["rst"]
    else:
        raise RuntimeError(f"Unknown ancestral reconstruction soft: {arsoft}")

    return [
        os.path.join(output_dir, filename) for filename in output_filenames
    ]
Esempio n. 3
0
def get_experiment_log_dir_template(config: Dict, software: Software) -> str:
    """
    Returns a name template of a log directory path for an experiment.
    One experiment is conducted by given software with fixed specific
    software parameters and a fixed input set (i.e. phylogenetic tree and alignment).
    """
    _check_software(software)
    software_name = software.value
    return os.path.join(cfg.get_work_dir(config), "logs", software_name,
                        "{pruning}")
Esempio n. 4
0
def get_software_dir(
        config: Dict, software: Union[PlacementSoftware,
                                      AlignmentSoftware]) -> str:
    """
    Returns a working directory for given software.
    """
    _check_software(software)

    work_dir = cfg.get_work_dir(config)
    return os.path.join(work_dir, software.value.upper())