This is a test version of Biostars. For the public version, visit https://www.biostars.org.
using parallel on samtools view

I cannot get this to work. > seems to be the problem. but I can't figure out how to fix it.

bam=bam_paths.txt

id=samples_ids.txt

parallel --xapply -j 5 'samtools view -b -f 4 {1} ">" ${outdir}/{2}.unmapped.bam' :::: $bam :::: $id

Error:

[W::sam_read1] Parse error at line 1
Failed to open BAM file LP60088.unmapped.bam

I have also tried:

parallel --xapply -j 5 samtools view -b -f 4 {1} ">" ${outdir}/{2}.unmapped.bam :::: $bam :::: $id

and

parallel --xapply -j 5 'samtools view -b -f 4 {1} |tee ${outdir}/{2}.unmapped.bam' :::: $bam :::: $id

All these gave me the same error. Can someone help please?

samtools parallel

what is the output of

xargs -L1 -a bam_paths.txt  ls

a list of paths to the bam files.
/working/sample/aligned_read_group/q/3e3d3282xxxx.bam /working/sample/aligned_read_group/d/f8dj39dd3xxxx.bam
...etc

and the id.txt is a list of sample names.
D01
D02
...etc

ok so that was not an error in your apths.txt file.

And LP60088.unmapped.bam is a valid bam file from your input list having at least one read?

LP60088.unmapped.bam is an output

Which causes the error. Either you try to read that file despite the fact it isn't there or you don't have the permissions to write the file at the given location.

Have you tried using samtools output option -o instead of > ?

Yes I have. got the same error.

0 answers

No answers yet.

Log in to answer this question.