Entering edit mode
8.8 years ago
simo017
▴
10
I have the following sed command that change the chromosome name:
for file in /myoldpath/*.bam
do
filename=echo $file | cut -d "." -f 1
samtools view -H $file | sed -e 's/SN:([0-9XY])/SN:chr\1/' -e 's/SN:MT/SN:chrM/' | samtools reheader - $file > /mynewpath/${filename}_chr.bam
done
My quesion is how to insert the result in a new path while keeping the variable $filename as part of every new file name? it always insert the result in /myoldpath/ or literally "filename.chr.bam" in the /mynewpath/ am i missing something in the syntax of that part "$file > /mynewpath/${filename}_chr.bam"?
thank you in advance
Thank you @Goutham
Please use
ADD REPLY/ADD COMMENTwhen responding to existing posts to keep threads logically organized.Please
accept(use the check mark against the answer) if the solution works for you to provide closure to the thread.