This is a test version of Biostars. For the public version, visit https://www.biostars.org.
awk syntax within GNU parallel

I have bedpe files where I want to remove interchromosome mappings for each bedpe file. I am doing this using GNU parallel.

Example code:

parallel -j 12  "awk \‘$1==$4\' {1} > {1.}_filt.bed" ::: $path/*resort.bed

Where column 1 is the chromosome read 1 maps to and column 4 is the chromosome read 2 maps to.

This code throws the following error:

/usr/bin/bash: /*resort_filt.bed: Permission denied

However, if I run awk ‘$1==$4' file.bed > file_filt.bed on a file per file basis, it works no problem.

I'm thinking this has to do the the awk syntax within GNU parallel, but can anyone point me in the right direction?

Thanks

EDIT (to add my comment below)

To avoid issues with the quoting, I have now edited the code to call on an awk function. As such:

awk_code() { awk '$1==$4' }
export -f awk_code
parallel -j 12 "awk_code {1} > {1.}_filt.bed" ::: $path/*resort.bed

This throws no error, but the resulting bed file is empty.

EDIT: SOLVED!

$path/*resort.bed needed quotes - "$path/"*resort.bed
parallel bed awk

Because $path is empty.

To avoid issues with the quoting, I have now edited the code to call on an awk function. As such:

awk_code() { awk '$1==$4' }

export -f awk_code

parallel -j 12 "awk_code {1} > {1.}_filt.bed" ::: $path/*resort.bed

This throws no error, but the resulting bed file is empty.

0 answers

No answers yet.

Log in to answer this question.