Reputation: 8828
#!/bin/bash
for i in /home/xxx/sge_jobs_output/split_rCEU_results/*.rCEU.bed
do
intersectBed -a /home/xxx/sge_jobs_output/split_rCEU_results/$i.rCEU.bed -b /home/xxx/sge_jobs_output/split_NA12878_results/$i.NA12878.bed -f 0.90 -r > $i.overlap_90.bed
done
However I got the errors like:
Error: can't determine file type of '/home/xug/sge_jobs_output/split_NA12878_results//home/xug/sge_jobs_output/split_rCEU_results/chr4.rCEU.bed.NA12878.bed': No such file or directory
Seems the computer mixes the two .bed files together, and I don't know why. thx
Upvotes: 1
Views: 178
Reputation: 12489
Your i
has the format /home/xxx/sge_jobs_output/split_rCEU_results/whatever.rCEU.bed
, and you insert it to the file name, which leads to the duplication. It's probably simplest to switch to the directory and use basename
, like this:
pushd /home/xxx/sge_jobs_output/split_rCEU_results
for i in *.rCEU.bed
do
intersectBed -a $i -b ../../sge_jobs_output/split_NA12878_results/`basename $i .rCEU.bed`.NA12878.bed -f 0.90 -r > `basename $i .NA12878.bed`.overlap_90.bed
done
popd
Notice the use of basename
, with which you can replace the extension of a file: If you have a file called filename.foo.bar
, basename filename.foo.bar .foo.bar
returns just filename
.
Upvotes: 4