Skip to content

Conversation

@pvanheus
Copy link
Contributor

@pvanheus pvanheus commented Sep 4, 2025

FOR CONTRIBUTOR:

  • I have read the CONTRIBUTING.md document and this tool is appropriate for the tools-iuc repo.
  • License permits unrestricted use (educational + commercial)
  • This PR adds a new tool or tool collection
  • This PR updates an existing tool or tool collection
  • This PR does something else (explain below)

@pvanheus
Copy link
Contributor Author

pvanheus commented Sep 4, 2025

This both updates the kraken2 tool to version 2.1.6 and adds support for custom databases. The custom databases are provided by directory types and because zip files without a common prefix get unpacked to a directory prefixed by the name of the original dataset (see the galaxy code), it uses some shell code to find the complete path to the custom database.

</param>
</when>
<when value="history">
<param type="data" name="custom_database" label="Kraken2 database" format="directory" help="A kraken2 is a directory containing the files hash.k2d, opts.k2d and taxo.k2d"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • How big are those typically?
  • Should we subclass directory for that?
  • We should also add a tool that crates the K2 databases, or?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gigabyte scale. E.g. the Mycobacterium genus databases from Hall is 7.6 GB (https://zenodo.org/records/8343322). And yes, ideally we need a datatype and tool for creating Kraken2 databases, but there are already several Kraken2 databases available online that I am using for e.g. my M. tuberculosis analyses. I'm happy to work on PRs for the Kraken2 database datatype and the tool that creates them, but I don't think that that work should block this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be of use for many users?

How about just adding this to the data manager?

We are just updating the dm anyway #6980

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DM is very useful... the use case here is in Galaxy's Workflow Landings API, which is oriented around inputs, not DMs. And also, once there is a kraken2-build tool, custom databases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvdbeek when are data manager bundles expected. Would this help here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Directory datasets are a much better idea

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the use case here is in Galaxy's Workflow Landings API

Would this then mean that the user uploads multiple GB "just" for a single workflow run? I have not yet used Galaxy's Workflow Landings API - how is this supposed to be used?

#if $kraken2_database.database_source == "builtin"
--db '${kraken2_database.builtin_database.fields.path}'
#elif $kraken2_database.database_source == "history"
--db "\$DB_DIR"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should wait for a proper fix galaxyproject/galaxy#20857 and use

Suggested change
--db "\$DB_DIR"
--db '$kraken2_database.custom_database.extra_files_path'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we need a fix for that bug, but for now this works and a fix for the Galaxy bug will likely take some times (months) to be available in a Galaxy release.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope that this will be considered a bug fix and goes in the current release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reference your bugfix in a comment in the latest version of the code

@bernt-matthias bernt-matthias mentioned this pull request Sep 4, 2025
5 tasks
<param name="confidence" value=".2"/>
<conditional name="kraken2_database">
<param name="database_source" value="history" />
<param name="custom_database" ftype="zip" value="test_db.zip" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you unzip this, then use

Suggested change
<param name="custom_database" ftype="zip" value="test_db.zip" />
<param name="custom_database" class="Directory" ftype="kraken2_database" value="path_to_directory" />

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(kraken2_database or similar would subclass the directory datatype)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a test for the Directory provided directly and provided via a zip. This revealed a bug in my previous version of the code so that is now updated.

@pvanheus
Copy link
Contributor Author

pvanheus commented Sep 6, 2025

Some notes on the future kraken2 custom database builder tool:

The kraken2 db building process involves three steps:

  1. Download the NCBI taxonomy (kraken2-build --download-taxonomy or k2 download-taxonomy) to the database directory. This downloads some 7GB of data from ftp.ncbi.nlm.nih.gov/pub/taxonomy, uncompressing to 54GB
  2. Either or both of:
  3. Download library sequences files (kraken2-build --standard / kraken2-build --special / kraken2-build --download-library or k2 download-library) to the DB directory
  4. Add your own FASTA sequence data (kraken2-build --add-to-library or k2 add-to-library)
  5. Build the database (kraken2-build --build or k2 build)
  6. Clean up (remove temporary files)

This gives flexibility in how databases are built, and therefore it makes sense to have tools for (1), and some combination of (2), (3) and (4), balancing the need to not continually re-download the taxonomy files with the need to not pollute the history with intermediate products.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants