samtools sort: legacy usage
1
0
Entering edit mode
5.5 years ago
c.e.chong ▴ 60

Hi,

I am trying to run the command samtools sort -@ 12 in.bam -O bam in_sorted using samtools version 1.1.

However this gives me the error:

Legacy usage: samtools sort [options...] <in.bam> <out.prefix>
Options: 

  -f         Use <out.prefix> as full final filename rather than prefix
  -o         Write final output to stdout rather than <out.prefix>.bam
  -l,m,n,@   Similar to corresponding options above

Usage: samtools sort [options...] [in.bam]

Options:

  -l INT     Set compression level, from 0 (uncompressed) to 9 (best)
  -m INT     Set maximum memory per thread; suffix K/M/G recognized [768M]
  -n         Sort by read name
  -o FILE    Write final output to FILE rather than standard output
  -O FORMAT  Write output as FORMAT ('sam'/'bam'/'cram')   (either -O or
  -T PREFIX  Write temporary files to PREFIX.nnnn.bam       -T is required)
  -@ INT     Set number of sorting and compression threads [1]

Should I not use -O and -@ with this version of samtools to specify that I want to use 12 threads and my output to be a bam file?

Thank you in advance for your help!

samtools metagenomics genome sort • 2.6k views
ADD COMMENT
0
Entering edit mode

Is there a good-enough reason to do this? Shouldn't you rather use the most up to date version and that syntax?

ADD REPLY
0
Entering edit mode

I am trying to use the most up to date version of the syntax. My understanding was that the options -@ and -O are the new versions, not the legacy version?

ADD REPLY
2
Entering edit mode

I don't know when -@ was introduced, but you no longer need -O. samtools finds the file format based on the extension specified by -o.

So you can do samtools sort -@12 -o sorted_alignment.bam myalignment.bam

ADD REPLY
0
Entering edit mode

I tried this and it worked. Thank you for your help!!

ADD REPLY
1
Entering edit mode
5.5 years ago
h.mon 35k

edit:

As you are using SAMtools 1.1, you should use the "current" command line, not the "legacy":

samtools sort -@ 12 -o in_sort.bam in.bam

end of edit:

If you want to follow the "legacy" usage, you can't put an option between in.bam and out.prefix, so your command line should be:

samtools sort -@ 12 -O bam in.bam in_sorted
ADD COMMENT
0
Entering edit mode

Hi,

Thank you for your help!

I tried this, but I still got the same error?

I assumed I was not using the "legacy usage" as both -@ and -O are included in the given options of the new version?

ADD REPLY
1
Entering edit mode

Try:

samtools sort -@ 12 -o in_sort.bam in.bam
ADD REPLY
0
Entering edit mode

I tried this and it worked. Thank you for your help!!

ADD REPLY
0
Entering edit mode

If an answer was helpful you should upvote it, if the answer resolved your question you should mark it as accepted.
Upvote|Bookmark|Accept

ADD REPLY

Login before adding your answer.

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