jts / sga

de novo sequence assembler using string graphs
http://genome.cshlp.org/content/22/3/549
237 stars 82 forks source link

bug fixed for samtools sort #149

Closed A-Tsai closed 6 years ago

A-Tsai commented 6 years ago

In my environment, I use apt to install samtools and get the help description of samtools sort as follows:

test@sga1:/home/test/sga$ samtools sort Usage: samtools sort [options] Options: -n sort by read name -f use as full file name instead of prefix -o final output to stdout -l INT compression level, from 0 to 9 [-1] -@ INT number of sorting and compression threads [1] -m INT max memory per thread; suffix K/M/G recognized [768M]

the parameter -o of samtools sort is for stdout rather than for user-defined output filename. It will cause failure when calling sga-bam2de.pl. Since many version of samtool are available in the world, it will be better to simplify the general usage of samtools.

mmokrejs commented 6 years ago

Old samtools-0.1.x series doe snot understand --version:

$ samtools --version
[main] unrecognized command '--version'
$ samtools sort

Usage:   samtools sort [options] <in.bam> <out.prefix>

Options: -n        sort by read name
         -f        use <out.prefix> as full file name instead of prefix
         -o        final output to stdout
         -l INT    compression level, from 0 to 9 [-1]
         -@ INT    number of sorting and compression threads [1]
         -m INT    max memory per thread; suffix K/M/G recognized [768M]

Newer samtools:

$ samtools --version
samtools 1.5
Using htslib 1.5
Copyright (C) 2017 Genome Research Ltd.
$ samtools sort
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
  -t TAG     Sort by value of TAG. Uses position as secondary index (or read name if -n is set)
  -o FILE    Write final output to FILE rather than standard output
...

The patch should test for version of samtools to decide which syntax to use. However, I think the patch is nevertheless wrong. Either you want to use shell redirect or you use -o $outfilename.

A-Tsai commented 6 years ago

Thank @mmokrejs . Yes, my patch does only work on the old version of samtools. I think the best way to solve this problem is to declare the related tools and their version on README.md.