Question: Help with Samtools
0
gravatar for oma219
24 months ago by
oma21930
oma21930 wrote:

Hi,

I am trying to sort my paired-end data so all the read pairs are adjacent and I'm trying to use the sort function of samtools but I'm getting errors? Does samtools sort not work with .sam files?

samtools sort -n DICDvenus1_STARAligned.out.sam DICDvenus1_SortedReads.sam [bam_header_read] EOF marker is absent. The input is probably truncated. [bam_header_read] invalid BAM binary header (this is not a BAM file). Segmentation fault (core dumped)

samtools sort -n -o sam DICDvenus1_STARAligned.out.sam DICDvenus1_SortedReads.sam open: No such file or directory [bam_sort_core] fail to open file sam

rna-seq software error • 741 views
ADD COMMENTlink modified 24 months ago by mforde841.2k • written 24 months ago by oma21930
1
gravatar for Derek Guan
24 months ago by
Derek Guan20
Harbin Institute of Technology, Harbin, China
Derek Guan20 wrote:

samtools sort doesn't support sam files now, you may use the following command to transfer SAM to BAM:

samtools view -b DICDvenus1_SortedReads.sam > DICDvenus1_SortedReads.bam

Then you could use DICDvenus1_SortedReads.bam to run "samtools sort"

ADD COMMENTlink modified 24 months ago • written 24 months ago by Derek Guan20
1
gravatar for mforde84
24 months ago by
mforde841.2k
mforde841.2k wrote:

I think this should work so long as the sam file has headers:

samtools view -Sb file.sam | samtools sort -n - file.sort

ADD COMMENTlink modified 24 months ago • written 24 months ago by mforde841.2k
0
gravatar for Brian Bushnell
24 months ago by
Walnut Creek, USA
Brian Bushnell16k wrote:

Not a samtools answer, but BBMap has a program which will do it, "sortbyname.sh". Usage:

sortbyname.sh in=DICDvenus1_STARAligned.out.sam out=DICDvenus1_SortedReads.sam

I'm sure there's a way to do it with samtools, but I don't know what it is offhand.

Edit: In light of Derek's answer, no, it's not possible, which makes the name "samtools" seem weird.

P.S. And incidentally, sortbyname supports sam, fasta, fastq, and also (if samtools is installed) bam files. It also has various other sorting modes.

ADD COMMENTlink modified 24 months ago • written 24 months ago by Brian Bushnell16k

Do you know if the repair utility of featureCounts is another way to sort the reads?

ADD REPLYlink written 24 months ago by oma21930

It wouldn't surprise me, but I have not used that program.

ADD REPLYlink written 24 months ago by Brian Bushnell16k
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: 1693 users visited in the last hour