Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xosxos opened this issue Nov 5, 2024 · 0 comments
Open

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

xosxos opened this issue Nov 5, 2024 · 0 comments

Comments

@xosxos
Copy link

xosxos commented Nov 5, 2024

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?

@xosxos xosxos changed the title rust-htslib panics on record.contig() call rust-htslib panics on bam record.contig() call Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant