This is a test version of Biostars. For the public version, visit https://www.biostars.org.
error in getting sorted bam

Hey friends,

I have a filename_highquality.bam, by this syntax I want to change it to sorted bam but I got error, what I did wrong please?

$SAM/samtools sort eg1_highquality.bam > eg1_highquality_sorted.bam

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]

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
[izadi@lbox161 izadi]$ $SAM/samtools sort eg1_highquality.bam > eg1_highquality_sorted.bam
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]

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
[izadi@lbox161 izadi]$
sam bam ribo-seq bowtie2

2 answers

Try:

$SAM/samtools sort eg1_highquality.bam eg1_highquality_sorted

Thanks, it worked, long time I was working with

Just use the standard (in your output legacy use) samtools sort command:

samtools sort eg1_highquality.bam  eg1_highquality_sorted

It'll create a file called eg1_highquality_sorted.bam

thank you also

Log in to answer this question.