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 07:39 AM
BWA sampe problem patel Bioinformatics 9 10-24-2011 05:11 AM
bwa sampe problem sszelinger Bioinformatics 3 06-15-2011 05:34 AM
samtools-0.1.12a and bwa-0.5.9rc1 installing problem on fedora14 ketan_bnf Bioinformatics 2 01-14-2011 06:39 PM
BWA - samtools problem genelab Bioinformatics 2 07-02-2010 11:13 PM

Reply
 
Thread Tools
Old 08-05-2009, 01:02 AM   #1
joa_ds
Member
 
Location: belgium

Join Date: Dec 2008
Posts: 52
Default BWA - Samtools problem

Hello everyone

There are some topics concerning BWA and Samtools, but i still haven't found the solution to my problem...

Ok, here is what i do

1. I run BWA aln and I get a .sai file
2. I run BWA samse and I get a .sam file

So far so good.

But now i am having troubles using the 'pileup function'

As far as i understand i should use ./samtools -f ref.fna testing.sam

but it is giving me errors.

I am probably just using a wrong command or maybe i should convert the .sam file to a .bam file? I have tried this using:
samtools view -bt ref.fna -o out.bam testing.sam:sam_header_read2: Assertion `fp' failed.
samtools view -b ref.fna -o out.bam testing.sam:segmentation error

Anyone has the exact commando for me to got from BWA to 'pileup results' in samtools?

thx

Last edited by joa_ds; 08-05-2009 at 01:05 AM.
joa_ds is offline   Reply With Quote
Old 08-05-2009, 08:00 AM   #2
nilshomer
Nils Homer
 
nilshomer's Avatar
 
Location: Boston, MA, USA

Join Date: Nov 2008
Posts: 1,285
Default

Quote:
Originally Posted by joa_ds View Post
Hello everyone

There are some topics concerning BWA and Samtools, but i still haven't found the solution to my problem...

Ok, here is what i do

1. I run BWA aln and I get a .sai file
2. I run BWA samse and I get a .sam file

So far so good.

But now i am having troubles using the 'pileup function'

As far as i understand i should use ./samtools -f ref.fna testing.sam

but it is giving me errors.

I am probably just using a wrong command or maybe i should convert the .sam file to a .bam file? I have tried this using:
samtools view -bt ref.fna -o out.bam testing.sam:sam_header_read2: Assertion `fp' failed.
samtools view -b ref.fna -o out.bam testing.sam:segmentation error

Anyone has the exact commando for me to got from BWA to 'pileup results' in samtools?

thx
If you have a "sam" file, then you must use the "-S" flag (for the input is SAM) with "samtools view". "samtools view" expects a ".bam" file, so you could also convert it to a BAM file.
nilshomer is offline   Reply With Quote
Old 08-06-2009, 08:19 AM   #3
totalnew
Member
 
Location: Canada

Join Date: Apr 2009
Posts: 46
Default

Try these two commands:

>samtools pileup -cf ref.fa testing.bam
or
>samtools pileup -cf ref.fa -t ref.fa.fai testing.sam

They are actually the same, but you would have to get bam file first which will require the indexed reference sequence (use faidx option to get it).
totalnew is offline   Reply With Quote
Old 08-06-2009, 08:26 AM   #4
totalnew
Member
 
Location: Canada

Join Date: Apr 2009
Posts: 46
Default

For samtools view ..., I don't see any sense you need to use it, since I normally use it to convert bam file back to sam file.
totalnew is offline   Reply With Quote
Old 08-09-2009, 05:34 PM   #5
yasu
Member
 
Location: Japan

Join Date: Jul 2009
Posts: 10
Default

I have a quick question. How can I use 'samtools view' for converting bam file to sam file? I tried some times but I failed to do it...
yasu is offline   Reply With Quote
Old 08-09-2009, 08:46 PM   #6
nilshomer
Nils Homer
 
nilshomer's Avatar
 
Location: Boston, MA, USA

Join Date: Nov 2008
Posts: 1,285
Default

Quote:
Originally Posted by yasu View Post
I have a quick question. How can I use 'samtools view' for converting bam file to sam file? I tried some times but I failed to do it...
You can, but include the header ("-h").
nilshomer is offline   Reply With Quote
Old 08-10-2009, 07:04 AM   #7
joa_ds
Member
 
Location: belgium

Join Date: Dec 2008
Posts: 52
Default

hi there again...

The reasons I am trying BWA (still hasn't worked... ) is because I am analyzing illumina data for counting variant frequencies for a pool of several patients.

So far so good, BowTie gives 15%, Maq gives 40% and Sanger validation gives 0% for a certain variant. We have around 1000 variants, so this is kinda annoying.

I am doing a very simple thing: I align the reads using BowTie and i just parse the output file and count the variant frequencies. Some other people used MAQ and in the lab they verified using Sanger.

Before I spend another 10h trying to figure out why this BWA thing ain't working, is it worth trying to determine variant frequencies in a pool? And if so, what is the best strategy to do so.

And on the BWA/samtools thingie. I tryed using the -S flag but i keep getting "Segmentation fault"

I must be doing something totally wrong here...


Step 0:
/data/illumina/bwa-0.4.9/bwa index -a is Final

Step 1:
/data/illumina/bwa-0.4.9/bwa aln -t 12 Final Risk_no_haplos.txt > Risk_no_haplos.sai

Step 2:
/data/illumina/bwa-0.4.9/bwa samse Final Risk_no_haplos.sai Risk_no_haplos.txt > Risk_no_haplos.sam

Step 3:
../../samtools-0.1.5c_x86_64-linux/samtools view -S -h Risk_no_haplos.sam \
is giving
missing header? Abort!

../../samtools-0.1.5c_x86_64-linux/samtools pileup -S -cf Final Risk_no_haplos.sam
is giving
[samopen] no @SQ lines in the header.
[sam_read1] missing header? Abort!


aargh

EDIT: Woohoo, finally figured it out... Apparently i had to use faidx before i could use pileup straight away... The question remains if using BWA is a wise thing for the presented problem...

Last edited by joa_ds; 08-10-2009 at 07:10 AM. Reason: Woops
joa_ds is offline   Reply With Quote
Old 08-10-2009, 08:06 AM   #8
totalnew
Member
 
Location: Canada

Join Date: Apr 2009
Posts: 46
Default

Quote:
Originally Posted by yasu View Post
I have a quick question. How can I use 'samtools view' for converting bam file to sam file? I tried some times but I failed to do it...
That is way simple, try this linux command

samtools view test.bam > test.sam
totalnew is offline   Reply With Quote
Old 08-10-2009, 08:18 AM   #9
totalnew
Member
 
Location: Canada

Join Date: Apr 2009
Posts: 46
Default

Quote:
Originally Posted by joa_ds View Post
hi there again...


Step 3:
../../samtools-0.1.5c_x86_64-linux/samtools view -S -h Risk_no_haplos.sam \
is giving
missing header? Abort!

../../samtools-0.1.5c_x86_64-linux/samtools pileup -S -cf Final Risk_no_haplos.sam
is giving
[samopen] no @SQ lines in the header.
[sam_read1] missing header? Abort!


aargh

EDIT: Woohoo, finally figured it out... Apparently i had to use faidx before i could use pileup straight away... The question remains if using BWA is a wise thing for the presented problem...
Apparently, you shouldn't use samtools view sam file, that is for bam file. To pileup, you would either make bam file or get indexed reference sequence (.fai).

Last edited by totalnew; 08-10-2009 at 08:27 AM.
totalnew is offline   Reply With Quote
Old 10-08-2009, 01:00 PM   #10
kraigrs
Junior Member
 
Location: Michigan

Join Date: Oct 2009
Posts: 3
Default

When I attempt to align mated paired-end sequence reads and output the file
in SAM format, I receive a segmentation fault. If I try the same thing
without the -S/--sam option, it works fine. Here is what I am getting:

EEB-WITT5:Bowtie wittkopp-lab$ ./bowtie -q -k 1 --sam --best
--solexa1.3-quals dmel-all-CDS-r5.21 -1
./mel_sim_data/Hybrids/s_2_1_sequence.txt -2
./mel_sim_data/Hybrids/s_2_2_sequence.txt > s_2_sequence.sam

Segmentation fault

Any help in this matter would be greatly appreciated! Again, I would like
this output to be in SAM format. I tried converting the bowtie output to
SAM but the bowtie2sam.pl script from SAMtools doesn't do that for me.
kraigrs is offline   Reply With Quote
Old 10-20-2009, 05:01 AM   #11
xuer
Member
 
Location: germany

Join Date: Sep 2008
Posts: 17
Default

I tried to use sort command :
samtools sort aln.sam aln.sam.sorted
i also got
Segmentation fault
is there anybody had this probelm before?
xuer is offline   Reply With Quote
Old 10-20-2009, 09:07 AM   #12
totalnew
Member
 
Location: Canada

Join Date: Apr 2009
Posts: 46
Default

Quote:
Originally Posted by xuer View Post
I tried to use sort command :
samtools sort aln.sam aln.sam.sorted
i also got
Segmentation fault
is there anybody had this probelm before?

You should sort bam file, try this

samtools sort -n aln.bam sorted

then mv the sorted.bam file to whatever name you want.
totalnew is offline   Reply With Quote
Old 11-08-2009, 04:35 PM   #13
Victory
Member
 
Location: Pennsylvania

Join Date: Nov 2009
Posts: 13
Default Install SAM tool

Are there anyone know how to install SAM tool? I read in the SAM document and it didn't say anything about that. Thank you.
Victory is offline   Reply With Quote
Old 11-08-2009, 04:55 PM   #14
nilshomer
Nils Homer
 
nilshomer's Avatar
 
Location: Boston, MA, USA

Join Date: Nov 2008
Posts: 1,285
Default

Quote:
Originally Posted by Victory View Post
Are there anyone know how to install SAM tool? I read in the SAM document and it didn't say anything about that. Thank you.
Download it from http://samtools.sourceforge.net/. Copy the binaries to your typical install directory (which depends on your system).
nilshomer is offline   Reply With Quote
Old 11-08-2009, 06:14 PM   #15
Victory
Member
 
Location: Pennsylvania

Join Date: Nov 2009
Posts: 13
Default

Thank you. I use SUN cluster computer. I have already copy whole folder of SAM version 0.1.6 to my working directory. However, it still doesn't work. I'm not sure which one is the install directory.
Victory is offline   Reply With Quote
Old 11-08-2009, 06:17 PM   #16
nilshomer
Nils Homer
 
nilshomer's Avatar
 
Location: Boston, MA, USA

Join Date: Nov 2008
Posts: 1,285
Default

Quote:
Originally Posted by Victory View Post
Thank you. I use SUN cluster computer. I have already copy whole folder of SAM version 0.1.6 to my working directory. However, it still doesn't work. I'm not sure which one is the install directory.
Please be more verbose. What commands are you executing to install samtools after copying the SAM folder. You may have to get your cluster administrator to install samtools cluster-wide. I typically have a local install directory that is included in my PATH environmental variable.
nilshomer is offline   Reply With Quote
Old 11-08-2009, 06:27 PM   #17
Victory
Member
 
Location: Pennsylvania

Join Date: Nov 2009
Posts: 13
Default

I use the import command to make BAM file.
samtools import <in.ref_list> <in.sam> <out.bam>
Do I have to use specific command to install the SAM program or just put the program folder on the directory?
Victory is offline   Reply With Quote
Old 11-08-2009, 06:44 PM   #18
nilshomer
Nils Homer
 
nilshomer's Avatar
 
Location: Boston, MA, USA

Join Date: Nov 2008
Posts: 1,285
Default

Quote:
Originally Posted by Victory View Post
I use the import command to make BAM file.
samtools import <in.ref_list> <in.sam> <out.bam>
Do I have to use specific command to install the SAM program or just put the program folder on the directory?
You have to copy the binary to an directory where *other* binaries are installed (like /usr/local/bin). You have to make sure that your PATH environment variable includes the above path. Then you can just "samtools" instead of the "/home/<ETC>/samtools"
nilshomer is offline   Reply With Quote
Old 11-08-2009, 06:55 PM   #19
Victory
Member
 
Location: Pennsylvania

Join Date: Nov 2009
Posts: 13
Default

Thank you. I will try that.
Victory 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:14 AM.


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