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

Qusestion: why CIGAR output write result different with CigarString? #402

Open
wjwei-handsome opened this issue Jul 23, 2023 · 0 comments
Open

Comments

@wjwei-handsome
Copy link

wjwei-handsome commented Jul 23, 2023

Hi!

I'm trying to write a bam file using bam::Writer, but when i have set cigar, I found that the bam output's cigar is different with the CigarString I determined:

Here is my CigarString, I print the first Cigar println!("cigar0{:?}", cigar[0]);, it shows:

cigar0HardClip(289573083)

But when I check my bam file, this record shows:

21137627H

And then I simulate a fake bam record like this:

fn main() {
    let mut bamheader = rust_htslib::bam::header::Header::new();
    let mut bamheader_sample_rec = rust_htslib::bam::header::HeaderRecord::new(b"SQ");
    let bamheader_sample_rec = bamheader_sample_rec.push_tag(b"SN", "chr1").push_tag(b"LN", 1000);
    bamheader.push_record(&bamheader_sample_rec);
    let mut std_wtr = BamWriter::from_stdout(&bamheader, Format::Sam).unwrap();
    let mut bamrec = BamRecord::default();
    bamrec.set_pos(1);
    bamrec.set_tid(0);
    bamrec.set_flags(0);
    let seq = b"ATGC";
    let quals = vec![255 as u8; 4];
    let fake_cigar_vec = vec![Cigar::HardClip(289573083)];
    let fake_cigar = CigarString(fake_cigar_vec);
    bamrec.set(b"qname", Some(&fake_cigar), seq, &quals);
    bamrec.set_mapq(255);
    bamrec.set_mpos(0);
    bamrec.set_mtid(-1);
    std_wtr.write(&bamrec).unwrap();
}

And the above code will output this:

@sq SN:chr1 LN:1000
qname 0 chr1 2 255 21137627H * 1 0 ATGC *

So I’m confused about this, why did 289573083 convert to 21137627 ? I want to hear yours advices .

Thanks!

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