Skip to content

samtools cat fails to accept -@ option #2160

Description

@pickettbd

Are you using the latest version of samtools and HTSlib?

Yes (both v1.21).

Please describe your environment.

  • OS (uname -sr): Linux 4.18.0-553.30.1.el8_10.x86_64
  • machine architecture (uname -m): x86_64
  • compiler (gcc --version): gcc (GCC) 11.3.0

Please specify the steps taken to generate the issue, the command you are running and the relevant output.

Running samtools cat with option -@n (replacing n with some INT number of threads, in my case 2) yields the following error:

cat: invalid option -- '@'
cat: invalid option -- '2'

followed by the usage/help message. Note that the usage message does not mention the -@ option, however, the man page does (man samtools-cat):

       -@, --threads INT
               Number of input/output compression threads to use in addition to main thread [0].

Using samtools cat --threads 2 does not display the same error message, but it does fail to concatenate the files. This causes any subsequent command in a pipeline to see no input on its stdin. As a simple example, piping the output to samtools view yields the following (perfectly reasonable) error (samtools cat --threads 2 -b bams.list | samtools view):

[main_samview] fail to read the header from "-".

Notably, using --output-fmt-option nthreads=2 does not yield any errors and I do see output (though I tested with only a quick pipe to head, so I don't technically know if the full file would have worked).

Note that a similar issue was reported in 2020: #1336. It was addressed with pull request #1337, though these changes appear not to persist in v1.21.

If samtools cat is able to make use of additional threads, then some changes need to be made to the getopt argument parsing and possibly other places to pass the correct things to subsequent functions. If it is not able to make use of additional threads, then the manual page should be modified to at least remove -@, --threads and possibly also add a note that additional threads cannot be utilized here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions