Entering edit mode
4.4 years ago
evelyn
▴
220
I am trying to run samtools
to create vcf
files for a list of sorted bam
files using:
INPUT_DIR=DIR_NAME
INPUT_FILE_ONE=$(ls -1 DIR_NAME/*.sorted.bam | sed -n ${RUN}p)
SAMPLE=$(basename ${INPUT_FILE_ONE} | sed 's/.sorted.bam//')
OUT_DIR=vcf
echo "bcftools mpileup -Ov -f $REF_DIR/ref.fa ${INPUT_DIR}/${SAMPLE}.sorted.bam | bcftools call -mv -o ${OUT_DIR}/${SAMPLE}.vcf"
But I am getting error: basename: missing operand
Check
echo ${INPUT_FILE_ONE}
, if that's what you expected the pipe to sed is not needed and.sorted.bam
can be second argument tobasename
echo ${INPUT_FILE_ONE}
gives what I need. Can you please provide theSAMPLE
line then. I still got an error.And you'll get some unsolicited advice on top: In case you'll be doing stuff like this more often and you're stuck with troubleshooting this line after the help you got, I strongly recommend you look into some introduction to bash. When asking and re-asking very basic things, you might get rather rude answers depending on the person and their mood (and I'm not excluding myself).
Please do not take offense in this - you'll save the time you invest very soon!
basename
can take a second argument for an extension to strip so you can do away with your sed command altogether.