Skip to content

rust-htslib panics on bam record.contig() call #446

Open
@xosxos

Description

@xosxos

Hey, thank you for this great library. When working with unmapped reads, a call on bam record.contig() panics. I suppose it's due to the crate internally setting the tid of unmapped reads to -1? This is a bit problematic, as the user has no way of handling the internal panic and just has to avoid calling .contig() on unmapped reads. The code responsible is starting from line 1192 in src/bam/record.rs.

    fn contig(&self) -> &str {
        let tid = self.tid();
        if tid < 0 {
            panic!("invalid tid, must be at least zero");
        }
    }

It's understandable that returning a Result here would be inconvenient, but maybe it would be possible to return "*" or something like "unmapped" instead?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions