You please imagine I have 16 separate folders named A1 to A16 inside each of them I have a file named aligned.sorted.bam
By these commands I want to convert aligned.sorted.bam
to aligned.sam
module load samtools/1.3.2
samtools view -h -o aligned.sam aligned.sorted.bam
Then by below commands convert aligned.sam
to counts.txt
module load htseq/0.6.1
htseq-count --stranded=no -q aligned.sam /local/software/DropSeq/STAR_Genomes/STAR_hg38_Genome/metadata/Homo_sapiens.GRCh38.dna.primary_assembly.gtf > counts.txt
Is there anyway having a script going through each folder and doing these commands step wise for me? I am too bad in linux
Thank you for any help
By @cas kindly help I wrote this script
#!/bin/sh
find /temp/hgig/fi1d18/bin/TruSeq300719-139385266/FASTQ_Generation_2019-08-03_04_28_02Z-190932857/335T/ -type f -name aligned.sorted.bam -print0 | \
xargs -0r -n 1 -P 8 /temp/hgig/fi1d18/bin/TruSeq300719-139385266/FASTQ_Generation_2019-08-03_04_28_02Z-190932857/script.sh
cd "$(/temp/hgig/fi1d18/bin/TruSeq300719-139385266/FASTQ_Generation_2019-08-03_04_28_02Z-190932857/335T/ "$1")"
module load samtools/1.3.2
samtools view -h -o aligned1.sam "$1"
module load htseq/0.6.1
htseq-count --stranded=no -q aligned1.sam /local/software/DropSeq/STAR_Genomes/STAR_hg38_Genome/metadata/Homo_sapiens.GRCh38.dna.primary_assembly.gtf > counts.txt
Then in terminal I typed
chmod +x script.sh
But no thing happened
Sorry by latest changes I made script.sh executable then I ran this command
[fi1d18@cyan01 FASTQ_Generation_2019-08-03_04_28_02Z-190932857]$ find 353T -type f -name aligned.sorted.bam -print0 | \ xargs -0r -n 1 -P 8 script.sh
-bash: xargs: command not found
[fi1d18@cyan01 FASTQ_Generation_2019-08-03_04_28_02Z-190932857]$ find T{}/ -type f -name aligned.sorted.bam -print0 | \ xargs -0r -n 1 -P 8 script.sh
-bash: xargs: command not found
find: `T{}/': No such file or directory
[fi1d18@cyan01 FASTQ_Generation_2019-08-03_04_28_02Z-190932857]$ find T{} -type f -name aligned.sorted.bam -print0 | \ xargs -0r -n 1 -P 8 script.sh
-bash: xargs: command not found
find: `T{}': No such file or directory
[fi1d18@cyan01 FASTQ_Generation_2019-08-03_04_28_02Z-190932857]$ find T -type f -name aligned.sorted.bam -print0 | \ xargs -0r -n 1 -P 8 script.sh
-bash: xargs: command not found
find: `T': No such file or directory
[fi1d18@cyan01 FASTQ_Generation_2019-08-03_04_28_02Z-190932857]$
[fi1d18@cyan01 FASTQ_Generation_2019-08-03_04_28_02Z-190932857]$ ls
305N 305T 310N 310T 324T 327T 335T 337N 337T 338T 344T 346T 349T 353B 353N 353T script.sh
[fi1d18@cyan01 FASTQ_Generation_2019-08-03_04_28_02Z-190932857]$
I removed \
[fi1d18@cyan01 FASTQ_Generation_2019-08-03_04_28_02Z-190932857]$ find T -type f -name aligned.sorted.bam -print0 | xargs -0r -n 1 -P 8 script.sh
find: `T': No such file or directory
[fi1d18@cyan01 FASTQ_Generation_2019-08-03_04_28_02Z-190932857]$ ls
305N 305T 310N 310T 324T 327T 335T 337N 337T 338T 344T 346T 349T 353B 353N 353T script.sh
[fi1d18@cyan01 FASTQ_Generation_2019-08-03_04_28_02Z-190932857]$
Based on the @cas's latest commends
[fi1d18@cyan01 FASTQ_Generation_2019-08-03_04_28_02Z-190932857]$ find . -type f -name aligned.sorted.bam -print0 | xargs -0r -n 1 -P 8 script.sh
xargs: script.sh: Text file busy
xargs: script.shxargs: : Text file busyscript.sh
: Text file busy
xargs: script.sh: Text file busy
xargs: script.sh: Text file busy
xargs: script.shxargs: : Text file busyscript.sh
: Text file busy
[fi1d18@cyan01 FASTQ_Generation_2019-08-03_04_28_02Z-190932857]$