Skip to content

Add DNA Foundation Models - #1965

Draft
aerdasaliko wants to merge 9 commits into
bgruening:masterfrom
aerdasaliko:master
Draft

Add DNA Foundation Models#1965
aerdasaliko wants to merge 9 commits into
bgruening:masterfrom
aerdasaliko:master

Conversation

@aerdasaliko

Copy link
Copy Markdown

This PR adds a new Galaxy tool, DNA Foundation Models, integrating the DNABERT-2 foundation model into Galaxy.

The tool supports two main execution modes:

  • Embedding mode: generates sequence embeddings from FASTA input
  • Fine-tuning mode: trains or adapts models using tabular datasets, with support for both full fine-tuning and LoRA-based parameter-efficient tuning

In embedding mode, the tool processes a FASTA file by batching sequences through the model to generate embeddings. Pooling is configurable (CLS, mean, or max), and outputs are written as a tabular file. Optionally, attention visualizations can be enabled, producing additional outputs via BertViz and related utilities.

In fine-tuning mode, the tool takes tabular datasets (train/dev/test) in (sequence, label) format and passes training parameters directly to the underlying training script. It exposes the main Trainer configuration options, such as batch size, learning rate, number of epochs, evaluation steps, and logging frequency.

Two training strategies are supported:

  • Full fine-tuning
  • LoRA-based fine-tuning (optionally enabled, with configurable rank, alpha, dropout, and target modules)

Training artifacts (evaluation metrics, predictions, trainer state) are returned as outputs. Optionally, the trained model is returned as a .tar.gz archive.

Notes

The original DNABERT-2 model is based on a MosaicBERT architecture that relies on a version of Flash Attention not compatible with newer PyTorch releases. This tool instead uses model weights loaded through an updated MosaicBERT implementation to ensure compatibility.

The model can be retrieved using the following script:
model-retrieval.py

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)

There are two labels that allow to ignore specific (false positive) tool linter errors:

  • skip-version-check: Use it if only a subset of the tools has been updated in a suite.
  • skip-url-check: Use it if github CI sees 403 errors, but the URLs work.

@aerdasaliko
aerdasaliko marked this pull request as draft August 24, 2026 17:47
@anuprulez

Copy link
Copy Markdown
Contributor

thanks @aerdasaliko for the work!

#
#
# Classification models
local-dnabert2-model-1 DNABERT-2-117M fill-mask text dnabert2 1 "path-to-model" No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
local-dnabert2-model-1 DNABERT-2-117M fill-mask text dnabert2 1 "path-to-model"
DNABERT-2-117M DNABERT-2-117M feature-extraction dna-sequence dnabert2 1 "path-to-model"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems none of the pipeline_tag values from HF is suitable for DNABERT-2 model.

@@ -0,0 +1,402 @@
<tool id="dna_foundation_models" name="DNA Foundation Models" version="0.1.0+galaxy0" profile="21.05">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
<tool id="dna_foundation_models" name="DNA Foundation Models" version="0.1.0+galaxy0" profile="21.05">
<tool id="dna_foundation_models" name="DNA Foundation Models" version="0.1.0+galaxy0" profile="24.2">

<param name="lr" value="5e-5"/>
<param name="weight_decay" value="0.01"/>
<param name="epochs" value="1"/>
<param name="save_steps" value="50"/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

save_steps is not defined in the tool's UI


</tests>

<help>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

help section is not formatted .. planemo lint *.xml gives errors.

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.

2 participants