#!/bin/bash

# Define the filenames to check
filenames=("-byacc-bench_region.tsv" "-byacc-full_region.tsv" "-mask.tsv" "-sequences.json" "-model_lengths.json")

# Iterate over all subdirectories
while IFS= read -r line; do
    assem=${line}_df38
    dir=./$assem
    # Check if it's a directory
    if [ -d $dir ]; then
        echo "Checking directory: $assem"
        
        all_files_exist=true
         # Check for any file starting with 'tmp'
        if ls $dir/tmp* 1> /dev/null 2>&1; then
            echo "$assem Build was incomplete"
        fi
        
        # Iterate over each filename
        for file in "${filenames[@]}"; do
            file_name=$dir/$assem$file
            if [ ! -f $file_name ]; then
                echo "Missing file: $file_name"
                all_files_exist=false
            fi
        done
        
        if [ "$all_files_exist" = true ]; then
            echo "All files exist in $dir"
        else
            echo "Not all files are present in $dir"
        fi
        
        echo
    fi
done  < "$1"