kcm
kcm

Reputation: 200

How to pass a list of files to parallel command and execute downstream command such as samtools?

I have a list of files which I want to sort and index ,i listed all those files in a text file.

/run/media/punit/data1/GSE74246/tophat_output/CMP_SRR2753096/CMP_6792.bam
run/media/punit/data1/GSE74246/tophat_output/CMP_SRR2753104/CMP_7256.bam

The above one is just a list of my data which i want to sort and index.

Now i want to use this command

 ls *.bam | parallel "samtools view -b -S {} | samtools sort - {.}; samtools index {.}.bam"

Meanwhile I have also files with

.bam
extension such as unmapped.bam which i dont want to sort and index

How can i exclude those "unmapped.bam" but since i dont have those unmapped.bam in my list but still i wonder if i use parallel then would it take those sort and index...

Upvotes: 1

Views: 345

Answers (1)

John Zwinck
John Zwinck

Reputation: 249133

ls *.bam | grep -v unmapped | parallel ...

Upvotes: 2

Related Questions