Question: basename: missing operand
gravatar for evelyn
3 months ago by
evelyn30 wrote:

I am trying to run samtools to create vcf files for a list of sorted bam files using:

INPUT_FILE_ONE=$(ls -1 DIR_NAME/*.sorted.bam | sed -n ${RUN}p)
SAMPLE=$(basename ${INPUT_FILE_ONE} | sed 's/.sorted.bam//')


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

snp • 272 views
ADD COMMENTlink written 3 months ago by evelyn30

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 to basename

ADD REPLYlink modified 3 months ago • written 3 months ago by Carambakaracho1.8k

echo ${INPUT_FILE_ONE} gives what I need. Can you please provide the SAMPLE line then. I still got an error.

ADD REPLYlink written 3 months ago by evelyn30
basename --help
SAMPLE=$(basename ${INPUT_FILE_ONE} .sorted.bam)

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!

ADD REPLYlink written 12 weeks ago by Carambakaracho1.8k

basename can take a second argument for an extension to strip so you can do away with your sed command altogether.

ADD REPLYlink written 3 months ago by Joe14k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 816 users visited in the last hour