Skip to content

RG ID unique suffixes are not fixed width in samtools merge #2086

Description

@cjw85

I've filed this as a bug only because my understanding of what it appears to me that the intent was, but maybe its a feature request.

Are you using the latest version of samtools and HTSlib? If not, please specify.

From bioconda:

samtools 1.19.2
Using htslib 1.19.1

Please describe your environment.

Linux 5.15.0-88-generic

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

Running samtools merge without -p generates hexadecimal string suffices to RG IDs when they clash between files. From this line of code:

static int gen_unique_id(char *prefix, khash_t(cset) *existing_ids,
                         bool always_add_suffix, kstring_t *dest) {
                         
    ...
    ksprintf(dest, "%s-%0lX", prefix, lrand48());
    ...
}

It looks to me like the intention was to zero pad this such they are always the same length, but there's no field width after the 0 meaning that leading zeros aren't inserted.

I noticed this whilst trying to "deduplicate" the IDs in a BAM I have.

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