SEQanswers

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

Reply
 
Thread Tools
Old 11-04-2013, 09:13 PM   #1
AnushaC
Member
 
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

#!/bin/bash
#PBS -l nodes=2pn=2
for files in *.sra
do
OUT=(${files%.sra}.bam)
ref=($"/raid/references-and-indexes/hg19/bwa/hg19.fa")
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
done

I tried different combination for view like -bS
-Shu
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 ,
Anusha.Ch
AnushaC is offline   Reply With Quote
Old 11-05-2013, 03:02 AM   #2
gringer
David Eccles (gringer)
 
Location: Wellington, New Zealand

Join Date: May 2011
Posts: 838
Default

Quote:
Originally Posted by AnushaC View Post
Code:
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):
Code:
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:
Code:
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
Reply

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