Entering edit mode
2.0 years ago
clemaster
•
0
I am trying to do a bedtools intersect. Anyone see what is wrong with my bash code here?
#!/bin/bash
dir=$(pwd)
query=$dir/ga4k_beds
pgs=$dir/pgs_beds
for file in $query/*; do
bedtools intersect -wa -wb -a $file -b $pgs/* -c -C -sorted -filenames
done > $(basename $file .ext).txt
My "query" directory contains many files which need to each be iteratively queried against many files in "pgs" directory using the package "bedtools" and command "intersect", which allows an asterisk for file -b
to cycle through multiple files. I am not sure if the loop is causing issues with the command or if bedtools intersect with "*" usage is not clear enough -- couldn't find examples.
bash returns:
command not found 7: /*. Exiting.e to open file /Users/..
You should use 2 for loops one for each directory. Additionally, maybe you need to use
$(ls $query/*.bed)
same for other directory.Thanks, your insight helped tremendously!
I was able to get everything working with:
Now I just need to figure out the output. It's concatenating the first file only, no matter what loop I pipe the output from (inner or outer).
Because, in each loop you are override it with
>
use>>
instead to concat.