Skip to content

Commit

Permalink
ensure FASTA files are present at locations mentioned
Browse files Browse the repository at this point in the history
  • Loading branch information
meren committed Sep 30, 2024
1 parent bb161f0 commit e8ddf05
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions anvio/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3028,6 +3028,22 @@ def create_fasta_dir_from_sequence_sources(genome_desc, fasta_txt=None):

if fasta_txt is not None:
fastas = get_TAB_delimited_file_as_dictionary(fasta_txt, expected_fields=['name', 'path'], only_expected_fields=True)

# make sure every entry in the fasta_txt has a path that exists
genomes_missing_fasta_files = [g for g, e in fastas.items() if not os.path.exists(e['path'])]

if len(genomes_missing_fasta_files):
if len(genomes_missing_fasta_files) == 1:
msg = (f"One of the genome entries in your fasta-txt file, namely '{genomes_missing_fasta_files[0]}' does "
f"not seem to have its FASTA file at the location it is mentioned in the file :/ ")
else:
msg = (f"Multiple genome entries in your fasta-txt file have a FASTA file path that don't match to an "
f"existing FASTA file :/ Here are the list of offenders: {', '.join(genomes_missing_fasta_files)}. ")

msg += "Please correct your fasta-txt, and try again."

raise ConfigError(f"{msg}")

for name in fastas.keys():
genome_names.add(name)
hash_for_output_file = hashlib.sha256(name.encode('utf-8')).hexdigest()
Expand Down

0 comments on commit e8ddf05

Please sign in to comment.