This is a test version of Biostars. For the public version, visit https://www.biostars.org.
run picard on all bam files in directory

I am trying to run a bash loop on all bam files in a directory and having a bit of trouble. The bash so far as well as the individual picard command is below. Thank you :).

Bash loop so far

for f in /home/cmccabe/Desktop/NGS/pool_I_090215/*.bam ; do
  bname=`basename $f`
  pref=${bname%%.bam}
  java \
    -jar /home/cmccabe/Desktop/NGS/picard-tools-1.139/picard.jar \
    CalculateHsMetrics \
    BI=/home/cmccabe/Desktop/NGS/bed/sam_sorted_unix_5column_xgen_probes.bed \
    TI=/home/cmccabe/Desktop/NGS/bed/sam_sorted_unix_5column_xgen_targets.bed \
    I=/$f \
    O=/home/cmccabe/Desktop/NGS/pool_I_090215/${pref}_all_IDT.CalculateHSmetrics
done

If the bam files were run individually here is the command

java \
  -jar /home/cmccabe/Desktop/NGS/picard-tools-1.139/picard.jar \
  CalculateHsMetrics \
  BI=/home/cmccabe/Desktop/NGS/bed/sam_sorted_unix_5column_xgen_probes.bed \
  TI=/home/cmccabe/Desktop/NGS/bed/sam_sorted_unix_5column_xgen_targets.bed \
  I=/home/cmccabe/Desktop/NGS/pool_II_090115/IonXpress_015_150901_newheader.bam \
  O=/home/cmccabe/Desktop/NGS/pool_II_090115/IonXpress_015_150901_all_IDT.CalculateHSmetrics
bam ngs picard

What is the problem? What is the question?

What error message are you getting?

Are you sharing this as a useful tip, bioguy24?

1 answer

Some of the problems I see:

  • You're specifying parameters in an abbreviated fashion. TI should be TARGET_INTERVALS, for example.
  • The tool doesn't use BED format for the intervals files. It uses its own interval list format.
  • The output for each sample is being written to the same output file. That means you'll be overwriting it each time.

You should at minimum clearly state a question/problem and provide any error output that you obtain from the tool.

Log in to answer this question.