sokrypton / sokrypton/ColabFold

Bug parsing custom MSAs containing only paired sequences

Open
#770 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
2.9k
Forks
747
PR merge metrics
No merged PRs in 30d

Description

I think I've tracked down a bug in ColabFold, which I can reproduce on the AlphaFold2_mmseqs2 notebook as well as in colabfold_batch (v1.5.5) running on our HPC cluster.

Basically I prepared my own MSA file in a3m format for predicting a heterodimer. I followed the same format as #76 , except that I only had paired sequences, with no additional unpaired sequences in the alignment (i.e. each sequence line consisted of two CDS from the same species concatenated together). When I uploaded this to the notebook or ran it through colabfold_batch, I encountered the following error:

Could not generate input features XXXXX_2a2d4_0.custom: MSA 0 must contain at least one sequence.
Traceback (most recent call last):
  File "/content/colabfold/batch.py", line 1311, in run
    = generate_input_feature(query_seqs_unique, query_seqs_cardinality, unpaired_msa, paired_msa,
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/content/colabfold/batch.py", line 837, in generate_input_feature
    feature_dict = build_monomer_feature(
                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/content/colabfold/batch.py", line 717, in build_monomer_feature
    **pipeline.make_msa_features([msa]),
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/content/alphafold/data/pipeline.py", line 64, in make_msa_features
    raise ValueError(f'MSA {msa_index} must contain at least one sequence.')
ValueError: MSA 0 must contain at least one sequence.

After doing some digging in the source code I was able to reproduce the bug in a minimal codebase, and I think the issue is this conditional (line 832 in current codebase) in generate_input_feature:

            # get unpaired msa
            if unpaired_msa is None:
                input_msa = f">{101 + sequence_index}\n{sequence}"
            else:
                input_msa = unpaired_msa[sequence_index]

At this point, after passing my a3m file through unserialize_msa, the unpaired_msa variable contains a list of two empty strings (['','']), since there were no unpaired sequences associated with either monomer of the heterodimer. However, this expression does not evaluate to None, so then an empty string is assigned to input_msa, causing a problem later on down the line.

Possible solutions

Fix the conditional

I can get the code to parse properly if I change if unpaired_msa is None: to if unpaired_msa[sequence_index] == '':, which now successfully triggers the intended fallback option. I think this is a good solution because otherwise the only way to run the code properly is to make sure that there is at least one unpaired sequence in the input alignment.

Fix the documentation

More broadly, I have spent a lot of fruitless cycles trying to understand the exact specification for formatting a custom multimer MSA given the sparse instructions in #76 , which I believe are the only concrete instructions available. Specifically, I assumed that unpaired sequences in the alignment (as in the example) were optional, but with the code as written you MUST have unpaired sequences in the alignment. A more explicit description of the required format for custom MSAs would be really valuable. I am open to helping draft that, though it may be a bit on the backburner for me.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in colabfold/batch.py at generate_input_feature around the conditional on line 832, and review how unserialize_msa represents paired-only custom a3m input. Reproduce the failure with a custom MSA containing only paired sequences in the AlphaFold2_mmseqs2 notebook or colabfold_batch; done means the input parses without the empty-MSA error.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python
Domain
bioinformatics
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.