The lastz command will look like:

    lastz reference.fasta sample.fasta --ambiguous=IUPAC --format=GENERAL > output.fasta

I need to run lastz once for every sample file, because each sample file has to be compared to its own individual reference (I have one reference for each sample).

I'm using find to get all of my 'sample' files, and will do the same for the reference files. 

    find . -type f -name 'sample.fasta' -not -path "*/temp/*"

The question is, how do I associate each sample file with each reference file, taking as input the output of the find command? Or is there a better way?



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](https://www.gnu.org/software/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



