Bug Fix: Preserve full FASTA ID in alignment directory parsing to prevent truncation errors #485
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
When running inference with
run_pretrained_openfold.py
and using precomputed alignments, theparse_fasta
function is partially extracting the FASTA tag/ID from the original ID used to generate the alignments output folder. It removes special characters, such as hyphens (-) or periods (.), which are often used in FASTA IDs.This causes the inference to fail, as the partially extracted ID does not match the alignments folder.
For example, if you have a FASTA file like this:
Then, after running the
precompute_alignments.py
script, the following alignments are generated (as expected):However, when you run the
run_pretrained_openfold.py
script with the--use_precomputed_alignments
flag, you will encounter the following error:Fix
The error occurs because of the truncation performed by
parse_fasta
, causing it to look for "my" instead of the expected "my-fasta-sequence". I have updated theparse_fasta
function to fix this issue.Previously, the part of the code that split the IDs using the regex
(re.split('\W|\|', t))
was cutting off parts of the ID. For the workflow using precomputed alignments to function correctly, the full ID must be preserved so that it matches the folder.Changes:
>
is treated as the ID.