problem with piping samtools sort
1
0
Entering edit mode
6.5 years ago
pr.khavari • 0

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 rna-seq genome • 3.6k views
ADD COMMENT
1
Entering edit mode
6.5 years ago

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 COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY

Login before adding your answer.

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