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

[MISC] Remove field::offset from sam_file_[in/out]put. #3089

Merged
merged 6 commits into from
Nov 7, 2022

Conversation

smehringer
Copy link
Member

Follow up on #3058

@vercel
Copy link

vercel bot commented Nov 1, 2022

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

Name Status Preview Updated
seqan3 ✅ Ready (Inspect) Visit Preview Nov 2, 2022 at 2:58PM (UTC)

@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels Nov 1, 2022
@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels Nov 1, 2022
{
return get_impl(field_constant<seqan3::field::offset>{}, static_cast<tuple_base_t &&>(*this));
return static_cast<int32_t>(0);
Copy link
Member

@eseiler eseiler Nov 1, 2022

Choose a reason for hiding this comment

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

Suggested change
return static_cast<int32_t>(0);
return format_sam_base::soft_clipping_at_front(cigar()); // Won't work as the base is protected

Wouldn't we want something like this? Such that it is deprecated, but still does the correct thing.
Thinking about it, alignment() should probably throw instead of just doing nothing...though you cannot get to call alignment() because it will static assert.

I guess it's the same here :D
One could argue that it might help to provide the soft_clipping_at_front function. It does seem like a common use case. Especially since there seems to be a pitfall where there might be hard clipping in the first position and the soft clipping in the second.

Copy link
Member Author

@smehringer smehringer Nov 2, 2022

Choose a reason for hiding this comment

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

Wouldn't we want something like this? Such that it is deprecated, but still does the correct thing.

That was also my first impulse but it is not guaranteed that cigar is available. Maybe we should not return anything to mimic the alingment removal and avoid unexpected semantic issues.

Thinking about it, alignment() should probably throw instead of just doing nothing...though you cannot get to call alignment() because it will static assert.

Yes, you would never get to the exception because you would need to ignore the deprecation warning and then just use rec.alignment() without catching the result. When trying to catch it, you will get the error that alignment is void.

One could argue that it might help to provide the soft_clipping_at_front function. It does seem like a common use case. Especially since there seems to be a pitfall where there might be hard clipping in the first position and the soft clipping in the second.

Yes. But this would be part of several utility functions for a cigar vector.
We need to discuss them separately and should not implement them without a use case.

Utility that'd be nice:

  • CIGAR String <-> CIGAR Vector transformation
  • Get Hard/Softclipping at front or back
  • Get Length of the reference sequence region
  • Get Length of the query sequence region

Copy link
Member Author

Choose a reason for hiding this comment

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

So in summary, I would remove the return completely, analog to alignment().

Copy link
Member

Choose a reason for hiding this comment

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

I agree, should just be

SEQAN3_DEPRECATED_340 decltype(auto) sequence_position() &&
{}

etc.

include/seqan3/io/sam_file/format_bam.hpp Outdated Show resolved Hide resolved
*
* The position is the length of the soft-clipping at the start of the seqan3::sam_record::cigar_sequence if a
* soft-clipping is present and `0` otherwise.
*/
decltype(auto) sequence_position() &&
SEQAN3_DEPRECATED_340 decltype(auto) sequence_position() &&
Copy link
Member

Choose a reason for hiding this comment

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

In lieu of the other comment, would this work?

    SEQAN3_DEPRECATED_340 int32_t sequence_position() &&
    {
        return {};
    }

@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels Nov 1, 2022
@seqan-actions seqan-actions added the lint [INTERNAL] signal for linting label Nov 2, 2022
@eseiler eseiler removed the lint [INTERNAL] signal for linting label Nov 2, 2022
@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels Nov 2, 2022
@codecov
Copy link

codecov bot commented Nov 2, 2022

Codecov Report

Base: 98.23% // Head: 98.22% // Decreases project coverage by -0.01% ⚠️

Coverage data is based on head (800ddc9) compared to base (92164e6).
Patch coverage: 85.71% of modified lines in pull request are covered.

❗ Current head 800ddc9 differs from pull request most recent head 8cc85e4. Consider uploading reports for the commit 8cc85e4 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3089      +/-   ##
==========================================
- Coverage   98.23%   98.22%   -0.02%     
==========================================
  Files         275      275              
  Lines       12197    12175      -22     
==========================================
- Hits        11982    11959      -23     
- Misses        215      216       +1     
Impacted Files Coverage Δ
include/seqan3/io/sam_file/format_sam.hpp 95.09% <ø> (-0.08%) ⬇️
include/seqan3/io/sam_file/input.hpp 100.00% <ø> (ø)
...nclude/seqan3/io/sam_file/input_format_concept.hpp 100.00% <ø> (ø)
include/seqan3/io/sam_file/output.hpp 100.00% <ø> (ø)
...clude/seqan3/io/sam_file/output_format_concept.hpp 100.00% <ø> (ø)
include/seqan3/io/sam_file/record.hpp 100.00% <ø> (ø)
...io/sam_file/simple_three_verbose_reads_fixture.hpp 93.61% <ø> (-0.39%) ⬇️
...lude/seqan3/io/sam_file/detail/format_sam_base.hpp 97.81% <80.00%> (-0.04%) ⬇️
include/seqan3/io/sam_file/format_bam.hpp 94.92% <100.00%> (-0.08%) ⬇️
...de/seqan3/argument_parser/detail/version_check.hpp 92.96% <0.00%> (-0.79%) ⬇️
... and 1 more

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.

Co-authored-by: Enrico Seiler <eseiler@users.noreply.github.com>
@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels Nov 2, 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.

LGTM, one 💅

I suggest we talk about the way we are "deprecating"/removing offset and alignment once this PR is merged.

  • Since we static_assert on the fields, we cannot even call the member functions on the record (?)
  • To deprecate something usually means that it still works, but will be removed later. Which is not the case here.
  • We can still have the record member functions for documentation purposes, i.e. wrap the members in a #if SEQAN3_DOXYGEN_ONLY(1)0

@@ -515,16 +505,18 @@ format_bam::read_alignment_record(stream_type & stream,
// -------------------------------------------------------------------------------------------------------------
if constexpr (!detail::decays_to_ignore_v<cigar_type>)
{
int32_t const sc_front = soft_clipping_at_front(cigar_vector);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
int32_t const sc_front = soft_clipping_at_front(cigar_vector);
int32_t const sc_front{soft_clipping_at_front(cigar_vector)};

💅

{
return get_impl(field_constant<seqan3::field::offset>{}, static_cast<tuple_base_t &&>(*this));
return static_cast<int32_t>(0);
Copy link
Member

Choose a reason for hiding this comment

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

I agree, should just be

SEQAN3_DEPRECATED_340 decltype(auto) sequence_position() &&
{}

etc.

@eseiler eseiler requested a review from SGSSGene November 4, 2022 13:43
@eseiler eseiler merged commit 8816830 into seqan:master Nov 7, 2022
@smehringer smehringer deleted the io_remove_non_sam_fields branch November 17, 2022 10:48
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.

None yet

4 participants