It depends on the location of your reference files. Assuming reference and sample are located within one directory, you won't need associative arrays.
Example file structure:
├── a
│ ├── reference.fasta
│ └── sample.fasta
├── b
│ ├── reference.fasta
│ └── sample.fasta
└── c
├── reference.fasta
└── sample.fasta
Collect paths to samples and references in separate files
find . -type "f" -name "sample.fasta" | sort > samples.list
find . -type "f" -name "reference.fasta" | sort > references.list
Create association sample - reference
paste -d ',' references.list samples.list > file_association.csv
Create commands
while IFS=","
read -r col1 col2
do
x=$(dirname $col2)
echo "lastz $col1 $col2 --ambiguous=IUPAC --format=GENERAL > $x/output.fasta"
done < file_association.csv
or using GNU parallel
cat file_association.csv | parallel --dry-run --colsep ',' "lastz {1} {2} --ambiguous=IUPAC --format=GENERAL > {1//}/output.fasta"
Resulting commands
lastz ./a/reference.fasta ./a/sample.fasta --ambiguous=IUPAC --format=GENERAL > ./a/output.fasta
lastz ./b/reference.fasta ./b/sample.fasta --ambiguous=IUPAC --format=GENERAL > ./b/output.fasta
lastz ./c/reference.fasta ./c/sample.fasta --ambiguous=IUPAC --format=GENERAL > ./c/output.fasta
Based on your find command it appears that your files are all in one local directory. Is there a way to tell sample (and corresponding ref) apart by just file extension? If that is the case why not do