-
Notifications
You must be signed in to change notification settings - Fork 81
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
Problem creating new BAM records (SAM=Segfault,BAM=silent failure) #339
Comments
Hello! Can you please try to explicitly unset contig and position right before writing the out_record.set_tid(-1);
out_record.set_pos(-1);
out_record.set_mpos(-1);
out_record.set_mtid(-1);
// Perhaps also
out_record.set_unmapped(); Does the error still occur? |
@jch-13 thanks, I tried that already before - but unfortunately does not fix the situation.
My suspicion is currently either the CIGAR or the header somehow.
But it does not fix the issue neither. For the header I am wondering is it mandatory to set maybe |
I can't reproduce it here (the code is working just fine when I add the lines above), so the culprit might indeed be the header of the input BAM file. |
Thanks, the following fixed it:
Which I did not try and which you suggested later in the edit. This was not on my radar at all as I am working with single reads and not paired ones. I would though currently hesitate to close the ticket as I think that this would maybe need a fix in the |
Ah yes, sorry, I should have made the edit more clear. And I think you are right; this is more of a work-around than a proper fix. I wonder if Line 117 in a21aff2
*htslib::bam_init1() .
Edit: No, it turns out that this does not help. This seems to be |
Personally I would advocate that the default of generating a new record should be a valid un-mapped single read first, with no pair defined. That would be safe, meaning one could generate a default new header with a default new record and it would generate a valid BAM file. |
Looking at the headers over at https://github.com/samtools/htslib/blob/9045785cef02e7cd97b0b4caecbdcaf6217a986a/htslib/sam.h#L1007-L1036, it seems |
Hello @jch-13 , sorry for the late reply. |
* bam::Record:new should return a valid record, see #339
I believe that this issue is resolved by having merged PR |
Hi
I am currently trying to create uBAM (unmapped BAM) files and running into problems creating non-mapped entries from
any kind of given sequence (e.g. FASTA, FASTQ,...).
Essentially I can create a new BAM default record and BAM::Writer will write it but then I get either:
To understand better, lets take a BAM input and generate a BAM output file
This compiles but fails then with a
Segmentation fault (core dumped)
for Sam.If I write the original record instead of the new empty one everything works fine.
I guess there is some combination of feature or rather missing feature which breaks it but I cant find which one.
The text was updated successfully, but these errors were encountered: