About shell script
0
0
Entering edit mode
3.9 years ago
r00628112 ▴ 10

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 • 1.0k views
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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!

ADD REPLY
0
Entering edit mode

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
ADD REPLY

Login before adding your answer.

Traffic: 2471 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6