View Single Post
Old 03-30-2017, 08:01 PM   #24
keo
Junior Member
 
Location: Mexico City

Join Date: Jan 2012
Posts: 8
Default

Hi all,
This worked for me, but I don't know if it is a general solution. If you set the -k paramenter in Bowtie2 to >=2, you should have at least twice the name of the read in your SAM file. You can use that to remove reads that appear >1 times in the file my_filename.sam. This way you don't have to undertand how Bowtie sets tags and flags.
Quote:
prefix="my_filename"
tail -n +$(expr $(grep "^@" "$prefix.sam" | wc -l | cut -f 1 -d " ") + 1) "$prefix.sam" | sort | cut -f 1 | uniq -cd | cut -d " " -f 8 > "$prefix.toremove"
grep -vwF -f "$prefix.toremove" "$prefix.sam" > "$prefix.unique.sam"
rm "$prefix.toremove"
Comments appreciated.

Last edited by keo; 03-30-2017 at 08:18 PM.
keo is offline   Reply With Quote