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

[FIX] Write BAM header on sam_file deconstruction if not written before #3081

Merged
merged 4 commits into from
Oct 31, 2022

Conversation

smehringer
Copy link
Member

@smehringer smehringer commented Oct 26, 2022

Resolves #2497

Now, just opening a seqan3::sam_file_output, e.g. :

seqan3::sam_file_output fout{"test.sam"};

will trigger writing a minimal header on deconstruction.

This also has the implication that

{
   seqan3::sam_file_output fout{"test.bam"}; 
} // Error: BAM file cannot write header

will always raise an exception because without reference information no header can be written.
Reference information must be provided, e.g. via

seqan3::sam_file_output fout{"test.bam", ref_ids, ref_lengths}; // BAM file

or records must be pushed that have a header available, as is the case when piping

seqan3::sam_file_output{"test.sam"} | seqan3::sam_file_output{"test.bam"}; 

@vercel
Copy link

vercel bot commented Oct 26, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
seqan3 ✅ Ready (Inspect) Visit Preview Oct 31, 2022 at 2:43PM (UTC)

@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels Oct 26, 2022
@seqan-actions seqan-actions added the lint [INTERNAL] signal for linting label Oct 26, 2022
@seqan-actions seqan-actions removed the lint [INTERNAL] signal for linting label Oct 26, 2022
@codecov
Copy link

codecov bot commented Oct 26, 2022

Codecov Report

❗ No coverage uploaded for pull request base (master@07c9fec). Click here to learn what that means.
Patch coverage: 96.20% of modified lines in pull request are covered.

❗ Current head 100da3c differs from pull request most recent head fe51c42. Consider uploading reports for the commit fe51c42 to get more accurate results

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #3081   +/-   ##
=========================================
  Coverage          ?   98.24%           
=========================================
  Files             ?      276           
  Lines             ?    12361           
  Branches          ?        0           
=========================================
  Hits              ?    12144           
  Misses            ?      217           
  Partials          ?        0           
Impacted Files Coverage Δ
include/seqan3/io/sam_file/format_sam.hpp 95.65% <ø> (ø)
include/seqan3/io/sam_file/format_bam.hpp 95.42% <95.23%> (ø)
...lude/seqan3/io/sam_file/detail/format_sam_base.hpp 97.97% <95.65%> (ø)
include/seqan3/io/sam_file/output.hpp 100.00% <100.00%> (ø)
...clude/seqan3/io/sam_file/output_format_concept.hpp 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels Oct 26, 2022
Copy link
Member

@eseiler eseiler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This time appliable :)
Previous review was on first commit

include/seqan3/io/sam_file/format_bam.hpp Outdated Show resolved Hide resolved
include/seqan3/io/sam_file/format_bam.hpp Outdated Show resolved Hide resolved
include/seqan3/io/sam_file/format_bam.hpp Outdated Show resolved Hide resolved
include/seqan3/io/sam_file/format_bam.hpp Outdated Show resolved Hide resolved
include/seqan3/io/sam_file/format_bam.hpp Outdated Show resolved Hide resolved
include/seqan3/io/sam_file/format_bam.hpp Outdated Show resolved Hide resolved
include/seqan3/io/sam_file/format_bam.hpp Outdated Show resolved Hide resolved
include/seqan3/io/sam_file/format_bam.hpp Outdated Show resolved Hide resolved
include/seqan3/io/sam_file/format_bam.hpp Outdated Show resolved Hide resolved
@smehringer smehringer changed the title [FIX] Create valid empty BAM file with header when writing [FIX] Write BAM header on sam_file deconstruction if not written before Oct 26, 2022
@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels Oct 26, 2022
@eseiler
Copy link
Member

eseiler commented Oct 26, 2022

GCC 10 doesn't have std::ostringstream::view() :(
Not sure if it would be worth it to use str() for gcc 10 and view() otherwise.
Would be nice to get rid of the string copy, I guess. And we would not miss this optimization opportunity once we drop GCC 10 (if I/O stays until then).

@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels Oct 26, 2022
@eseiler
Copy link
Member

eseiler commented Oct 26, 2022

Added a commit for using str() on GCC 10 and view() otherwise

@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels Oct 28, 2022
@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels Oct 28, 2022
@eseiler
Copy link
Member

eseiler commented Oct 28, 2022

There are two ope suggestions for code comments. After that, we could rebase? :D

@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels Oct 31, 2022
Copy link
Contributor

@Irallia Irallia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGFM, just one little thing I stumbled across. But it's not very important.

include/seqan3/io/sam_file/output.hpp Outdated Show resolved Hide resolved
@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels Oct 31, 2022
CHANGELOG.md Outdated Show resolved Hide resolved
include/seqan3/io/sam_file/format_bam.hpp Outdated Show resolved Hide resolved
include/seqan3/io/sam_file/format_bam.hpp Outdated Show resolved Hide resolved
include/seqan3/io/sam_file/format_bam.hpp Outdated Show resolved Hide resolved
include/seqan3/io/sam_file/format_bam.hpp Outdated Show resolved Hide resolved
include/seqan3/io/sam_file/output.hpp Outdated Show resolved Hide resolved
include/seqan3/io/sam_file/output.hpp Outdated Show resolved Hide resolved
@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels Oct 31, 2022
@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels Oct 31, 2022
@eseiler eseiler disabled auto-merge October 31, 2022 15:38
@eseiler eseiler merged commit 334b790 into seqan:master Oct 31, 2022
@smehringer smehringer deleted the io_empty_bam_file branch November 1, 2022 12:05
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

Successfully merging this pull request may close these issues.

[IO] What is the desired behavior when writing an empty BAM file?
4 participants