SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
sam to bam conversion error, no @SQ lines in the header, missing header? efoss Bioinformatics 17 12-03-2015 05:28 AM
strip header off sam header using bam cmccabe Bioinformatics 3 09-19-2015 06:01 AM
Bug? Do we need a header for a SAM? student-t Bioinformatics 0 04-08-2015 04:25 AM
GSNAP and SAM header JadeB Bioinformatics 8 10-17-2014 04:20 AM
.SAM to .BAM with SAM file header @PG emilyjia2000 Bioinformatics 13 06-14-2011 01:21 PM

Reply
 
Thread Tools
Old 12-05-2018, 11:30 AM   #1
sfh838t
Member
 
Location: Mountain Grove, MO, USA

Join Date: Apr 2014
Posts: 29
Default SAM header, difference between using sam tools or awk to filter ?

I have filtered SAM files to get only the aligned reads with samtools view -F4.
my output is a file in SAM format, the header is lost, but I can still convert the file to BAM and then use picardtools "addOrReplaceReadGroups" to add a header.

this time I have a list of read names in a txt file and I used awk to find the matching rows in the SAM file. of course the header is lost, and I cannot convert this file to BAM to add the header back so I can index the file and visualize the alignments.

I can open both files in a spreadsheet, they look and act exactly the same.
is there some kind of identifier that is lost when awk writes the new file? Or will I have to use the matching fastq reads and redo the alignment?

I am trying to find regions in a virus that has matching sequences in a plant genome. So I did: align all reads to virus genome, filter out aligned reads. align those virus reads to plant genome, filter again. Now I need to see where these reads align in the virus, and since they are already contained in the first alignment file I thought I could just separate them out......
sfh838t is offline   Reply With Quote
Old 12-06-2018, 04:46 AM   #2
GenoMax
Senior Member
 
Location: East Coast USA

Join Date: Feb 2008
Posts: 6,814
Default

You can grab the header from your bam file by doing
Code:
 samtools view -H your.bam > header.txt
That can then be added back to your filtered sam.
GenoMax is offline   Reply With Quote
Old 12-06-2018, 04:55 AM   #3
GenoMax
Senior Member
 
Location: East Coast USA

Join Date: Feb 2008
Posts: 6,814
Default

You could also try to do this analysis in one step. Use bbsplit.sh from BBMap with both genomes. Look for reads that map to both genomes. Those would presumably be the reads you are interested in.
GenoMax is offline   Reply With Quote
Old 12-07-2018, 05:47 AM   #4
sfh838t
Member
 
Location: Mountain Grove, MO, USA

Join Date: Apr 2014
Posts: 29
Default

Thank you GenoMax.
the header suggestion almost worked, in one case, not so much in the other because it is too long I suspect.
and thanks for the BBsplit suggestion as well.It obviously does alignment along the way, but does not mention anything about the aligner and since I work with very short reads, <30 nt, that can be an issue.
either way, what I really needed to see was the alignments, so I ended up using excel and making histograms from the SAM files.
sfh838t is offline   Reply With Quote
Reply

Tags
awk, sam header

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 06:39 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO