Help ChewBBACA: using collection folders and NormalizeFasta to avoid "ValueError: This FASTA file contains comments "

I am working through a training module (Step-by-step Tutorial - chewBBACA 3.5.4 documentation) using datasets provided.

Whenever I input cgMLSTschema95.txt file as genes-list to do “Allele calling with additional genomes”, I get the following error

Traceback (most recent call last):
  File "/home/lincolnlab/galaxy-psql/galaxy/database/dependencies/_conda/envs/mulled-v1-953604d8ffe01a3006a320c9236bfe49f47ed2f05717b8b6e06900286f9451f1/bin/chewBBACA.py", line 11, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/lincolnlab/galaxy-psql/galaxy/database/dependencies/_conda/envs/mulled-v1-953604d8ffe01a3006a320c9236bfe49f47ed2f05717b8b6e06900286f9451f1/lib/python3.11/site-packages/CHEWBBACA/chewBBACA.py", line 1543, in main
    functions_info[process][1]()
  File "/home/lincolnlab/galaxy-psql/galaxy/database/dependencies/_conda/envs/mulled-v1-953604d8ffe01a3006a320c9236bfe49f47ed2f05717b8b6e06900286f9451f1/lib/python3.11/site-packages/CHEWBBACA/utils/process_datetime.py", line 146, in wrapper
    func(*args, **kwargs)
  File "/home/lincolnlab/galaxy-psql/galaxy/database/dependencies/_conda/envs/mulled-v1-953604d8ffe01a3006a320c9236bfe49f47ed2f05717b8b6e06900286f9451f1/lib/python3.11/site-packages/CHEWBBACA/chewBBACA.py", line 492, in run_allele_call
    loci_list = pv.validate_loci_list(args.genes_list, loci_list,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lincolnlab/galaxy-psql/galaxy/database/dependencies/_conda/envs/mulled-v1-953604d8ffe01a3006a320c9236bfe49f47ed2f05717b8b6e06900286f9451f1/lib/python3.11/site-packages/CHEWBBACA/utils/parameters_validation.py", line 1199, in validate_loci_list
    if fao.validate_fasta(input_path) is True:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lincolnlab/galaxy-psql/galaxy/database/dependencies/_conda/envs/mulled-v1-953604d8ffe01a3006a320c9236bfe49f47ed2f05717b8b6e06900286f9451f1/lib/python3.11/site-packages/CHEWBBACA/utils/fasta_operations.py", line 238, in validate_fasta
    records = list(sequence_generator(file_path))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lincolnlab/galaxy-psql/galaxy/database/dependencies/_conda/envs/mulled-v1-953604d8ffe01a3006a320c9236bfe49f47ed2f05717b8b6e06900286f9451f1/lib/python3.11/site-packages/CHEWBBACA/utils/fasta_operations.py", line 44, in sequence_generator
    records = SeqIO.parse(input_file, 'fasta')
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lincolnlab/galaxy-psql/galaxy/database/dependencies/_conda/envs/mulled-v1-953604d8ffe01a3006a320c9236bfe49f47ed2f05717b8b6e06900286f9451f1/lib/python3.11/site-packages/Bio/SeqIO/__init__.py", line 670, in parse
    return iterator_generator(handle)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lincolnlab/galaxy-psql/galaxy/database/dependencies/_conda/envs/mulled-v1-953604d8ffe01a3006a320c9236bfe49f47ed2f05717b8b6e06900286f9451f1/lib/python3.11/site-packages/Bio/SeqIO/FastaIO.py", line 202, in __init__
    raise ValueError(
ValueError: This FASTA file contains comments at the beginning of the file, which are not
allowed by the 'fasta' parser.

To parse this file, you have three options:

(1) Modify your FASTA file to remove such comments at the beginning of the
file.

(2) Use SeqIO.parse with the 'fasta-pearson' format instead of 'fasta'. This
format is consistent with the FASTA format defined by William Pearson's FASTA
aligner software. This format allows for comments before the first sequence;
lines starting with the ';' character anywhere in the file are also regarded
as comment lines and are ignored.

(3) Use the 'fasta-blast' format. This format regards any lines "starting with
'!', '#', or ';' as comment lines. The 'fasta-blast' format may be safer than
the 'fasta-pearson' format, as it explicitly indicates which lines are comments.

This also got this error when I was using different fasta files, which I’ve checked and do not contain any comment. Is this something I’m doing wrong?

Thanks,

Michelle

Hi @msuh

Would you like to share the history with the error then let us know which dataset has the problem? You can also provide a link to the tutorial for extra context.

Right now, this does appear to be an input file format problem and we can help to double check and to solve other problems that may be leading to a false error.

Or, you can try a correction. The usual way to get around messages about description content in fasta files is to run the tool NormalizeFasta being sure to toggle the option Truncate sequence names at first whitespace to Yes. → FAQ: Working with very large fasta datasets.

Keep in mind that this correction would for the fasta input to the tool, not the extra file. The tool is trying to “match up” content between input files, and that is when the description content got in the way (without the extra file this didn’t matter).

Please give this a try and let us know how it goes! I’ll watch for a share link back too. :slight_smile:

I’ve shared the history with you @jennaj , it’s dataset #1443and in this history that has the problem. I’ve also tried running the tool chewBBACA AlleleCall using less (10) datasets but still had the same error. The link to the tutorial is provided below.

I will try the correction in the meantime. Thank you!

Hi @msuh

Great! Let’s figure this out. I’ve helped with adjustments for this one a few times. And if the issue is on the server, we can get it reported and fixed. But I think this is format still so yes please try it!

For the sharing, how did you share? Which server? I’m going to send you a direct message with the email address to share with or you can just post back the share link since that will allow us to bring in other administrators as needed (and with your permission of course!).

More soon!

Update – I found it! Reviewing right now. More soon (again!).

Hi @msuh

Yes, the problem does seem to be the fasta format. I also have some other advice and a copy of your history with some manipulations you can review as examples.

  • history share link admin redacted for privacy, see direct message

Suggested changes

  1. Place your FASTA files into dataset collections.

    This will make it so much easier to select datasets on tool forms. Having hundreds of individual files is already slowing down how performant this history is. For your use case, I really don’t think collections are optional.

    After you download the tutorial ZIP file (which you likely still have on your computer), upload each set of FASTA files directly into a list collection.

    You will then have just two FASTA collections to select on tool forms. I also suggest adding a # tag to the top level of each collection. Click the :memo:, add something like #complete or #draft, then save. This will make it much easier to distinguish the outputs associated with each collection.

    • :film_strip: https://youtu.be/6ZU9hFjnRDo?si=5Zrk_pWifLMcsyIg — find more at @galaxyproject by searching :magnifying_glass_tilted_left: collection
    • Load one set of files and build the collection using Select all. Then load the second set and use Select all again. The first set will already be hidden in its collection, so you can easily distinguish the newly uploaded files.
    • :graduation_cap: FAQ: Creating a dataset collection with autobuild — with more collection training here: GTN Materials Search
    • A simple list collection for each set will be fine. The other files can remain individual datasets.
    • You already have some collections in this history as outputs. Collections work in a similar way with the nested view. All elements in a simple list collection have the same datatype format. Depending on the tool, Galaxy may process the entire collection together or run the tool separately on each element.
    • The tool knows which behavior is appropriate and declares this on the tool form directly below the dataset selection area.
  2. Run NormalizeFasta on both collections.

    I’ll link the FASTA FAQ again:

    FAQ: Working with very large fasta datasets

    Run the tool twice, once for each collection. The YouTube video above shows how to select a collection as the input.

    These will be batch runs: Galaxy will run NormalizeFasta individually on each FASTA file in the collection.


This should solve the immediate problem.

You should also strongly consider starting over in a new history. If you don’t want to upload the other non-FASTA files again, you can copy those datasets into the new history: FAQ: Copy a dataset between histories

However, I would not copy or reuse any of the files that have already been processed in Galaxy. Given the problems we’ve been investigating, I would expect that to introduce the same issues again.

I wrote a bit more about collections than you may need, but I think your question is a good one and the process is worth describing for anyone working with batches of data who isn’t comfortable with collections yet. If you have more than about three files with the same datatype, a collection is almost always worth using. With more than about ten, it becomes very close to required.

Please give this a try! I know you were working in the original history, but I think it is already barely usable in its current state. Adding another 700+ loose datasets will only make that worse, and the collection-building/filtering process will become increasingly difficult.

Instead, load the data again into a clean history in an organized way. I think this will actually make your overall run through the tutorial much faster.

Thanks! :man_scientist: