I have a loop that first downloads a file using a url link then processes it with samtools. For each file in input.txt there is one *.cram and one *.crai file which have the same name except the ending. Both these files need to be downloaded before samtools can be run. I wonder how to download both the *.cram and one *.crai using mapfile before proceeding to the samtools step.
test.txt
gs://hmf-cram-1231313-drup01010104/file1_dedup.realigned.cram
gs://hmf-cram-1231313-drup01010104/file1_dedup.realigned.crai
gs://hmf-cram-1234235353-drup01242424/file1_dedup.realigned.cram
gs://hmf-cram-1234235353-drup01242424/file1_dedup.realigned.crai
script
#!/bin/bash
mapfile -s 1 -t files < test.txt
echo "${files[@]}"
for FILE in ${files[@]}; do
gsutil -u absolute-bison-xxxx cp $FILE gs://bucket_1
samtools view -@5 -O bam -f 4 ${FILE##*/}.cram > /home/user/${FILE##*/}.unmapped.bam
rm *.cram
rm *.crai;
done