Question: there is an error after samtools index
0
gravatar for 543541656
6 months ago by
54354165620
54354165620 wrote:

Hi, there is an error occuring after the following command

[E::hts_idx_push] Unsorted positions on sequence #4: 27130750 followed by 27130362

samtools index: failed to create index for "1_sorted.bam"

and my samtools sort command is

samtools sort 1_raw.bam -n -m 2G -@ 4 -o 1_sorted.bam

[bam_sort_core] merging from 8 files and 4 in-memory blocks...

I want to know where is the problem,who can give we some advice on the error??

dna-seq • 293 views
ADD COMMENTlink modified 6 months ago by swbarnes28.9k • written 6 months ago by 54354165620
1

(remove the -n option); It is because the -n option is sorted by name.

 -n         Sort by read name

Index, requires the bam file sorted by Coordinates.

See the manual of samtools: http://www.htslib.org/doc/samtools-index.html

Index a coordinate-sorted BGZIP-compressed SAM, BAM or CRAM file for fast random access.

ADD REPLYlink written 6 months ago by wm490

thank you,I have solved the problem according to your requirements

ADD REPLYlink written 6 months ago by 54354165620
0
gravatar for swbarnes2
6 months ago by
swbarnes28.9k
United States
swbarnes28.9k wrote:

Is there a reason you are sitting by name? It looks like you can't index a bam so sorted.

ADD COMMENTlink written 6 months ago by swbarnes28.9k

no,I just copy someone else's code,because it is the first time to use that for me.

ADD REPLYlink written 6 months ago by 54354165620
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: 1438 users visited in the last hour