Question: Extract Reads From All Chromosomes Except One.
0
gravatar for KCC
7.9 years ago by
KCC4.0k
Cambridge, MA
KCC4.0k wrote:

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 • 1.8k views
ADD COMMENTlink written 7.9 years ago by KCC4.0k
1
gravatar for Rlong
7.9 years ago by
Rlong340
US
Rlong340 wrote:
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 COMMENTlink modified 7.9 years ago • written 7.9 years ago by Rlong340

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 REPLYlink written 6.7 years ago by KCC4.0k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2116 users visited in the last hour