This is a test version of Biostars. For the public version, visit https://www.biostars.org.
About shell script

Good afternoon everyone:

I saved the script for each sam file in a A.txt file as below:

java -jar /data/share/tools/gatk-4.1.7.0/gatk-package-4.1.7.0-local.jar SortSam -I DRR212437.sam -O DRR212437.sort.bam -SO coordinate --CREATE_INDEX TRUE
java -jar /data/share/tools/gatk-4.1.7.0/gatk-package-4.1.7.0-local.jar SortSam -I DRR212438.sam -O DRR212438.sort.bam -SO coordinate --CREATE_INDEX TRUE
java -jar /data/share/tools/gatk-4.1.7.0/gatk-package-4.1.7.0-local.jar SortSam -I DRR212439.sam -O DRR212439.sort.bam -SO coordinate --CREATE_INDEX TRUE

then I ran this shell command but failed:

sh  A.txt

When I copy each command to run, it can run as usual. What's the reason?

Because I used the same way to ran "bwa mem" command for each .fq file that is no this problem, I can get each sam file successfully.

Thank you very much

script alignment

That's not a script, it doesn't even have a shebang. This could work thou: cat A.txt | sh

You said sh A.txt failed, can you post error message?

Just show the gatk basic usage information, I think there must be something wrong in the comment.

This is not a Shell script. Do like this:

#!/bin/bash

set -eo pipefail

GATK="/data/share/tools/gatk-4.1.7.0/gatk-package-4.1.7.0-local.jar"

$GATK SortSam -I DRR212437.sam -O DRR212437.sort.bam -SO coordinate --CREATE_INDEX TRUE

Just save this as .sh file and run bash file.sh

I would suggest using a for loop into the script so you can iterate over all samples!

Thank you so much.

I really need automatic command for running all samples.

Is it correct loop?

 #!/bin/bash
   set -eo pipefail 

   GATK="/data/share/tools/gatk-4.1.7.0/gatk-package-4.1.7.0-local.jar"

   for i in {437..570}

   do
      GATK SortSam -I DRR212+${i}.sam -O DRR212+${i}.sort.bam -SO coordinate --CREATE_INDEX TRUE
done

0 answers

No answers yet.

Log in to answer this question.