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

Alignment pretty printing issues #3309

Open
2 tasks done
feldroop opened this issue Nov 26, 2024 · 3 comments
Open
2 tasks done

Alignment pretty printing issues #3309

feldroop opened this issue Nov 26, 2024 · 3 comments
Labels
documentation documentation is missing to close this issue

Comments

@feldroop
Copy link
Member

Does this problem persist on the current main?

  • I have verified the issue on the current main

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Printing the alignment of the alignment result from the align_pairwise function using the debug_stream seems to be broken. Maybe the issue is using the uint8_t alphabet. Here is the code:

#include <seqan3/alignment/cigar_conversion/cigar_from_alignment.hpp>
#include <seqan3/alignment/configuration/align_config_edit.hpp>
#include <seqan3/alignment/pairwise/align_pairwise.hpp>
#include <seqan3/alphabet/adaptation/uint.hpp>
#include <seqan3/core/debug_stream.hpp>

int main() {
    std::vector<uint8_t> seq1 {
        0,0,0,0,0,0,0,0,0,0,
        1,1,1,1,1,1,1,1,1,1,
        0,0,0,0,0,0,0,0,0,0
    };
    std::vector<uint8_t> seq2 {
        1,1,1,1,1
    };

    auto config = seqan3::align_cfg::method_global{
        seqan3::align_cfg::free_end_gaps_sequence1_leading{true},
        seqan3::align_cfg::free_end_gaps_sequence2_leading{false},
        seqan3::align_cfg::free_end_gaps_sequence1_trailing{true},
        seqan3::align_cfg::free_end_gaps_sequence2_trailing{false}
    }
    | seqan3::align_cfg::edit_scheme
    | seqan3::align_cfg::output_score{}
    | seqan3::align_cfg::output_begin_position{}
    | seqan3::align_cfg::output_alignment{};

    auto alignment_results = seqan3::align_pairwise(std::tie(seq1, seq2), config);
    auto alignment = *alignment_results.begin();

    seqan3::debug_stream << alignment << '\n';
    seqan3::debug_stream << alignment.alignment() << '\n';
    seqan3::debug_stream << seqan3::cigar_from_alignment(alignment.alignment(), {}, true) << '\n';

    return 0;
}

It prints:

{score: 0, begin: (15,0), 
alignment:
(,)}
(,)
[5=]

The CIGAR string is as expected, but just printing the alignment shows as (,), which seem to be not intended.

Expected Behavior

I would expect it to either not compile, because the uint8_t alphabet wrapper does not support this kind of pretty printing or to print a useful debug representation of the alignment (5 matches) and not just the symbols (,).

Steps To Reproduce

See above

Environment

- Operating system: Ubuntu 20.04
- SeqAn version: newest commit on main right now
- Compiler: gcc 12.3

Anything else?

No response

@feldroop feldroop added the bug faulty or wrong behaviour of code label Nov 26, 2024
@eseiler
Copy link
Member

eseiler commented Nov 26, 2024

Hey Felix,

you'll need to additionally include

#include <seqan3/alignment/aligned_sequence/debug_stream_alignment.hpp>

We redesigned the debug_stream (#3259). It also ahs the side effect that <iostream> and seqan3's debug_stream are not auto-included, unless you actually want them.

With the include, the output is

{score: 0, begin: (15,0), 
alignment:
      0     .
        �����
        |||||
        �����
}
      0     .
        �����
        |||||
        �����

[5=]

Which I guess is OK, because uint8_t 0 isn't a printable character.

Without the include, it would use the next best fitting available printer, which would be the tuple printer, which does not convert the input sequences to char.

@eseiler eseiler added documentation documentation is missing to close this issue and removed bug faulty or wrong behaviour of code labels Nov 26, 2024
@eseiler
Copy link
Member

eseiler commented Nov 26, 2024

I'm changing this issue from bug to documentation.

https://docs.seqan.de/seqan3/main_user/group__core__debug__stream.html

Could at least use a list of printers and the corresponding types it prints.
Some printers are missing in the auto generated list of printers, because they are documented in another group (for example, the alignment printer)

@feldroop
Copy link
Member Author

Maybe it would also be good to add it to the tutorial page of the pairwaise alignment?
I looked for in in the Solution of assignment 4 and I didn't find it. link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation documentation is missing to close this issue
Projects
None yet
Development

No branches or pull requests

2 participants