Skip to content

crash exit when the custom database finds no hits (bug report) #121

@cpterfan

Description

@cpterfan

Hi,

I found a little bug when using a custom database for phold.
I was using the following script:

phold run \
  --input $IN_FILE \
  --output $OUT_DIR/${FILENAME::-4} \
  --database $DATABASE \
  --custom_db $RDRP_DB \
  --finetune \
  --foldseek_gpu \
  --threads 4 \
  --force

If there is no hit in the custom database, phold would exit with the following error (complete error log attached):

.
.
.
2026-02-11 09:48:32.947 | INFO     | phold.results.topfunction:get_topcustom_hits:559 - Processing Foldseek output
2026-02-11 09:48:32.949 | WARNING  | phold.results.topfunction:get_topcustom_hits:585 - Foldseek found no custom hits whatsoever - please check your custom database and input.
2026-02-11 09:48:32.949 | WARNING  | phold.results.topfunction:get_topcustom_hits:588 - Phold will continue using only the default databases.
Traceback (most recent call last):
  File "/home/viro/erfan.khamespanah/miniconda3/envs/phold_122/bin/phold", line 10, in <module>
    sys.exit(main())
             ~~~~^^
  File "/home/viro/erfan.khamespanah/miniconda3/envs/phold_122/lib/python3.13/site-packages/phold/__init__.py", line 1714, in main
    main_cli()
    ~~~~~~~~^^
  File "/home/viro/erfan.khamespanah/miniconda3/envs/phold_122/lib/python3.13/site-packages/click/core.py", line 1485, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/viro/erfan.khamespanah/miniconda3/envs/phold_122/lib/python3.13/site-packages/click/core.py", line 1406, in main
    rv = self.invoke(ctx)
  File "/home/viro/erfan.khamespanah/miniconda3/envs/phold_122/lib/python3.13/site-packages/click/core.py", line 1873, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/viro/erfan.khamespanah/miniconda3/envs/phold_122/lib/python3.13/site-packages/click/core.py", line 1269, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/viro/erfan.khamespanah/miniconda3/envs/phold_122/lib/python3.13/site-packages/click/core.py", line 824, in invoke
    return callback(*args, **kwargs)
  File "/home/viro/erfan.khamespanah/miniconda3/envs/phold_122/lib/python3.13/site-packages/click/decorators.py", line 34, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/viro/erfan.khamespanah/miniconda3/envs/phold_122/lib/python3.13/site-packages/phold/__init__.py", line 395, in run
    subcommand_compare(
    ~~~~~~~~~~~~~~~~~~^
        gb_dict,
        ^^^^^^^^
    ...<21 lines>...
        restart=restart
        ^^^^^^^^^^^^^^^
    )
    ^
  File "/home/viro/erfan.khamespanah/miniconda3/envs/phold_122/lib/python3.13/site-packages/phold/subcommands/compare.py", line 575, in subcommand_compare
    tophit_custom_df = get_topcustom_hits(
        result_tsv_custom, structures, proteins_flag
    )
  File "/home/viro/erfan.khamespanah/miniconda3/envs/phold_122/lib/python3.13/site-packages/phold/results/topfunction.py", line 596, in get_topcustom_hits
    foldseek_df[["contig_id", "cds_id"]] = foldseek_df["query"].str.split(
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/viro/erfan.khamespanah/miniconda3/envs/phold_122/lib/python3.13/site-packages/pandas/core/frame.py", line 4660, in __setitem__
    self._setitem_array(key, value)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/home/viro/erfan.khamespanah/miniconda3/envs/phold_122/lib/python3.13/site-packages/pandas/core/frame.py", line 4699, in _setitem_array
    check_key_length(self.columns, key, value)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/viro/erfan.khamespanah/miniconda3/envs/phold_122/lib/python3.13/site-packages/pandas/core/indexers/utils.py", line 392, in check_key_length
    raise ValueError("Columns must be same length as key")
ValueError: Columns must be same length as key

err_phold_33838186_4.log

Hope this error can be handled more gracefully in the upcoming updates 😃

Thank you so much for this tool.

Best regards,
Erfan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions