gsnap not producing sam files with header
0
0
Entering edit mode
3.8 years ago
Ada ▴ 10

How can I get gsnap to produce sam files with header? I am having difficulty with current dataset.

assembly • 1.1k views
ADD COMMENT
0
Entering edit mode

To get help you need to provide command line you are using. current dataset conveys no information either.

ADD REPLY
0
Entering edit mode
ref=(/dir_001/*.fna.gz)

for f in "${ref[@]}";

do

gmap_build -d genome -D /dir_001 $f

gsnap -D /dir_001 -d genome /R1_001.fastq  /R2_001.fastq -A sam >> "$f.sam"

samtools view -S -b "$f.sam" > "$f.bam";

samtools sort "$f.bam" -o "$f.sorted.bam";

samtools flagstat "$f.sorted.bam" >>  "$f.txt"

done
ADD REPLY
0
Entering edit mode

The code breaks at samtools flagstat, stating header cannot be found.

ADD REPLY
1
Entering edit mode

Looks like you forgot to include header when converting SAM to BAM using samtools view.

-h    Include the header in the output.
ADD REPLY
0
Entering edit mode

I made the correction and received this:

[main_samview] fail to read the header from test1.sam file

So it looks like the error is coming from the mapping to output .SAM file command.

The correction of -h to the SAM to BAM file conversion states that their is also failure for reading header in .BAM file.

What can I do to rectify this?

ADD REPLY
0
Entering edit mode

What do you get when you try to look at header of one of the files?

samtools -H onefile.sam

Or is there no header at all?

ADD REPLY
0
Entering edit mode

There is no header at all

ADD REPLY
0
Entering edit mode

Are you sure the logic of your loop is sound? It looks like you are building a new reference (looping through files) and then trying to align the same fastq files to that index with iteration of the loop.

If you simply try

gmap_build -d genome -D /dir_001 one_fna.fz
gsnap -D /dir_001 -d genome /R1_001.fastq  /R2_001.fastq -A sam > one_fna.sam

does it work properly? If it does then you need to debug your loop. Not sure why you are using >> if you are creating a new SAM files each time.

ADD REPLY
0
Entering edit mode

I am going to debug and follow up

ADD REPLY
0
Entering edit mode

My files were in .fna.gz and that seemed to be the problem in producing SAM file with header.

Converted to .fna and works fine now.

ADD REPLY

Login before adding your answer.

Traffic: 2136 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