Question: samtools sort: legacy usage
0
gravatar for c.e.chong
4 months ago by
c.e.chong10
c.e.chong10 wrote:

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!

ADD COMMENTlink modified 4 months ago by h.mon24k • written 4 months ago by c.e.chong10

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

ADD REPLYlink written 4 months ago by WouterDeCoster37k

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 REPLYlink written 4 months ago by c.e.chong10
2

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 REPLYlink written 4 months ago by WouterDeCoster37k

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

ADD REPLYlink written 4 months ago by c.e.chong10
1
gravatar for h.mon
4 months ago by
h.mon24k
Brazil
h.mon24k wrote:

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 COMMENTlink modified 4 months ago • written 4 months ago by h.mon24k

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 REPLYlink written 4 months ago by c.e.chong10
1

Try:

samtools sort -@ 12 -o in_sort.bam in.bam
ADD REPLYlink written 4 months ago by h.mon24k

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

ADD REPLYlink written 4 months ago by c.e.chong10

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 REPLYlink written 4 months ago by WouterDeCoster37k
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: 769 users visited in the last hour