VIB-PSB / ksrates

ksrates is a tool to position whole-genome duplications relative to speciation events using substitution-rate-adjusted mixed paralog-ortholog Ks distributions.
https://ksrates.readthedocs.io
GNU General Public License v3.0
15 stars 9 forks source link

Warning: Dubious indirect gene relationship - closest genes get same color in alignment #45

Closed sjfleck closed 1 year ago

sjfleck commented 1 year ago

I'm currently trying to solve this error:

ERROR   i-ADHoRe execution failed with standard error output:
Warning: Dubious indirect gene relationship between evm.model.HiC_scaffold_10.80 and evm.model.HiC_scaffold_10.99, closest genes get same color in alignment
Warning: Dubious indirect gene relationship between evm.model.HiC_scaffold_10.99 and evm.model.HiC_scaffold_10.80, closest genes get same color in alignment
Warning: Dubious indirect gene relationship between evm.model.HiC_scaffold_10.119 and evm.model.HiC_scaffold_10.65, closest genes get same color in alignment
ERROR   Exiting.

Any recommendation on how to fix this? Thanks

Cecilia-Sensalari commented 1 year ago

Hi sjfleck! Thanks for reporting this. The lines above are generated by i-ADHoRe. Even though they are considered a warning, i-ADHoRe handles them in its code as an error and thus ksrates does the same, stopping the workflow. I believe however that the warnings above are not really a reason to exit, especially if they are only a few lines. I previously made a workaround to avoid that ksrates exists at that point, but it's not the most elegant solution and I haven't implemented it yet. I'll show it here below, and I could implement it in the next days. Basically, if the i-ADHoRe error message starts with "warning" it is tolerated, else ksrates exits.

In module fc_wgd.py, function _run_iadhore, I would add a few lines to tolerate such situation (see long comment in function below). The lines generating the message in i-ADHoRe are by the way here.

Thanks a lot, let me know should you have any feedback. Cecilia

def _run_iadhore(config_file):
    """
    Modified from wgd/colinearity.py

    Run i-ADHoRe for a given config file.
    :param config_file: path to i-ADHoRe configuration file
    """
    command = ['i-adhore', config_file]
    logging.info(' '.join(command))
    try:
        sp = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8', check=True)
        out = sp.stdout.strip()
        err = sp.stderr.strip()
        if out:
            logging.info("i-ADHoRe output:\n" + out)
        if err:
            # i-ADHoRe can fail without a proper exit/return code, but just with an error on stderr
            logging.error("i-ADHoRe execution failed with standard error output:\n" + err)

            # Some i-ADHoRe error output is an actual fatal error and the pipeline must be interrupted,
            # but there is at least one i-ADHoRe message that is passed as error output ("cerr" in source code)
            # that is only a warning (it starts with "Warning:"): this kind of cerr is not supposed 
            # to interrupt ksrates pipeline! To take this into account, the following if-clause allows any
            # i-ADHoRe error output message starting with "Warning" to be tolerated.
            if not err.lower().startswith("warning"):
                logging.error("Exiting.")
                sys.exit(1)
    except subprocess.CalledProcessError as e:
        logging.error(f"i-ADHoRe execution failed with return code: {e.returncode}")
        if e.stderr:
            logging.error("i-ADHoRe standard error output:\n" + e.stderr.strip())
        logging.error("Exiting.")
        sys.exit(e.returncode)

    return
sjfleck commented 1 year ago

This worked! thanks!