Question: problem with piping samtools sort
0
gravatar for pr.khavari
18 months ago by
pr.khavari0
Iran, Tehran, University of tehran
pr.khavari0 wrote:

Hi everyone, I wanna prepare my alignment bam file for cufflinks running. I 've used samtools sort for converting sam to bam, next I gonna to run my script for sorting it, but it don't work. Do you have any recommendation or suggestion for correction of that? thanks so much for help me.

my scripts is here:

./samtools view -@ 4 /media/marziyeh/56F72A78084DABD5/RNA-seqdata/output_bowtie2_alignment_ref/sample33.sam > sample33.bam`

`

 ./samtools sort -n -l 9 -@ 4 -m 3G /media/marziyeh/56F72A78084DABD5/RNA-seqdata/viewed_samtools/sample32_sortedin22.bam >> /media/marziyeh/56F72A78084DABD5/RNA-seqdata/sorted.sample/sample.32

or another script as well as same result;

 cd /media/marziyeh/56F72A78084DABD5/RNA-seqdata/viewed_samtools/;/home/marziyeh/Software/samtools-1.6/samtools sort -n -l 9 -@ 4 -m 3G -o /media/marziyeh/56F72A78084DABD5/RNA-seqdata/sorted.sample/sample32_sorted.bam -O bam -n -T /media/marziyeh/56F72A78084DABD5/RNA-seqdata/sorted_file -@ 4 /media/marziyeh/56F72A78084DABD5/RNA-seqdata/viewed_samtools/sample32_sortedin22.bam

Error is here: [E::sam_parse1] missing SAM header [W::sam_read1] Parse error at line 1 samtools sort: truncated file. Aborting

rna-seq assembly genome • 1.0k views
ADD COMMENTlink modified 18 months ago by Samarth Kulshrestha170 • written 18 months ago by pr.khavari0
1
gravatar for Samarth Kulshrestha
18 months ago by
India
Samarth Kulshrestha170 wrote:

Yor error message hints that your generated output BAM is without header section. Please check for header section using command below

samtools view -H yourfile.bam

Above command should print Header only (No alignment section)

ADD COMMENTlink modified 18 months ago • written 18 months ago by Samarth Kulshrestha170

thanks, I'm run your suggestion now with this command line; ./samtools view -H /media/marziyeh/56F72A78084DABD5/RNA-seqdata/viewed_samtools/sample32_sortedin22.bam but gives anything.

ADD REPLYlink modified 18 months ago • written 18 months ago by pr.khavari0

To include header section to your output BAM run samtools command:

  • samtools -bhS yourfile.sam > yourfile.bam

Here parameter indicates that

  • b: your output will be in BAM format
  • h: print header for the SAM output
  • S: input is SAM

After performing this step, sort yourfile.bam using samtools sort command

Hope this works Best

ADD REPLYlink modified 18 months ago • written 18 months ago by Samarth Kulshrestha170
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1955 users visited in the last hour