I have a folder with the following file content:
ls bams-lab/*.name-sorted.fixmate.sorted.dedup.sam
bams-lab/OZBenth2_.fastp.fq.gz.name-sorted.fixmate.sorted.dedup.sam
...
bams-lab/OZBenth7_.fastp.fq.gz.name-sorted.fixmate.sorted.dedup.sam
I tried to create a list of files with the below bash script
#!/bin/bash
# usage: sh merge_sam_pbs.sh /path/to/*.name-sorted.fixmate.sorted.dedup.sam
output=$(dirname $1)
samlist=$(for sam in $1; do echo "I=$sam "; done)
cat << EOF |cat #qsub
#!/bin/bash -l
#PBS -N merge
#PBS -l walltime=150:00:00
#PBS -j oe
#PBS -l mem=70G
#PBS -l ncpus=2
#PBS -M m.lorenc@qut.edu.au
cd \$PBS_O_WORKDIR
conda activate picard
echo $samlist
picard -Xmx10g MergeSamFiles \
$samlist \
O=${output}/merged.sorted.dedup.bam
EOF
but it only picks up one file
> sh merge_sam_pbs.sh bams-lab/*.name-sorted.fixmate.sorted.dedup.sam
#!/bin/bash -l
#PBS -N merge
#PBS -l walltime=150:00:00
#PBS -j oe
#PBS -l mem=70G
#PBS -l ncpus=2
#PBS -M m.lorenc@qut.edu.au
cd $PBS_O_WORKDIR
conda activate picard
echo I=bams-lab/OZBenth2_.fastp.fq.gz.name-sorted.fixmate.sorted.dedup.sam
picard -Xmx10g MergeSamFiles I=bams-lab/OZBenth2_.fastp.fq.gz.name-sorted.fixmate.sorted.dedup.sam O=bams-lab/merged.sorted.dedup.bam
What did I miss?