Go Back   SEQanswers > Bioinformatics > Bioinformatics

Similar Threads
Thread Thread Starter Forum Replies Last Post
BWA sam and Samtools sam->bam conversion problem maasha Bioinformatics 6 06-05-2013 08:39 AM
Sam / Bam to Ace conversion empyrean Bioinformatics 4 05-13-2013 05:32 AM
BAM -> SAM conversion error jwhite Bioinformatics 16 02-13-2013 06:32 AM
sam 2 bam conversion error DavyK Bioinformatics 2 01-14-2013 07:13 PM
Issue with Sam-Bam conversion samtools - how to remove last line of Sam file? TabeaK Bioinformatics 3 11-19-2012 11:05 AM

Thread Tools
Old 11-04-2013, 09:13 PM   #1
Location: San Diego

Join Date: Sep 2013
Posts: 78
Default Sam to Bam Conversion Failing ****

Hi All ,
Can any one please clarify why samtools view is failing .
I am writing shell script like this

#PBS -l nodes=2pn=2
for files in *.sra
fq=$(fastq-dump $files)
# Main code

bwa aln -t 8 $ref $fq|bwa samse $ref - $fq -|samtools view -bSh - /raid/development/anusha/python_test/shelltest/fetalbrain_bam/$OUT

I tried different combination for view like -bS
by using the option -o still is failing
the code is working pretty fine till point of samtools view
I am getting following error many times and creating empty bam files
bwa_seq_open] fail to open file 'Written' : No such file or directory
[fread] Unexpected end of file
[samopen] no @SQ lines in the header.
[main_samview] random alignment retrieval only works for indexed BAM files.

[bam_header_read] EOF marker is absent. The input is probably truncated.

I am not understanding why this is failing

Thanks in advance ,
AnushaC is offline   Reply With Quote
Old 11-05-2013, 03:02 AM   #2
David Eccles (gringer)
Location: Wellington, New Zealand

Join Date: May 2011
Posts: 838

Originally Posted by AnushaC View Post
samtools view -bSh -  /raid/development/anusha/python_test/shelltest/fetalbrain_bam/$OUT
Assuming BWA is producing a properly-formatted SAM file as output (which I'm doubtful of, given the error messages), it looks like you're not specifying the input/output files correctly. Samtools view takes a single non-option parameter (the input file name, or '-' for standard input), and the output (default to standard out) can be redirected to a different file using the '-o' parameter.

So, there are two ways to output to a file (instead of standard out):
samtools view [options] <input> -o <output> # redirect using samtools 
samtools view [options] <input> > <output> # redirect using the shell
Subsituting in the bits from your code for these two options:
samtools view -bSh  - -o /raid/development/anusha/python_test/shelltest/fetalbrain_bam/$OUT # note two dashes separated by a space
samtools view -bSh  - > /raid/development/anusha/python_test/shelltest/fetalbrain_bam/$OUT
Of course, that all assumes your other options are correct. If you're sending output to a binary BAM file (option -b), then you don't need to include the SAM header (option -h), because you can't have a BAM file without a header.
gringer is offline   Reply With Quote

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 04:59 AM.

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