Extract Reads From All Chromosomes Except One.
1
0
Entering edit mode
12.4 years ago
KCC ★ 4.1k

I created a sam file by aligning reads, using bwa. I want to create a new sam file that contains all reads except ones that are on a particular chromosome or have an alternative alignment on that chromosome.

How can I do it?

sam • 2.7k views
ADD COMMENT
1
Entering edit mode
12.4 years ago
Rlong ▴ 340
cat yoursam.sam | awk '{ if($3 != YourExcludedChrom) print $0 }'

That should do it.

EDIT: However, the alternate alignments to the excluded chromosome will still be in there. Sorry.

ADD COMMENT
0
Entering edit mode

I ended up writing my own python script that filters lines in the SAM based on what chromosome they map to. So, your answer is best.

ADD REPLY

Login before adding your answer.

Traffic: 2307 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6