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

Allow min_score alignment config for arbitrary (user defined) edit distance schemes #3253

Closed
feldroop opened this issue May 8, 2024 · 4 comments · Fixed by #3254
Closed
Labels
feature/proposal a new feature or an idea of

Comments

@feldroop
Copy link
Member

feldroop commented May 8, 2024

I want to align sequences with a custom uint8_t based alphabet and edit distance. I also have a bound on the number of allowed errors in the alignment, so I would like to additionally use the seqan3::align_cfg::min_score configuration.

I am using the seqan3/alphabet/adaptation/uint.hpp header and have already implemented my own scoring scheme by specializing the seqan3::scoring_scheme_base class.

This is my code:

// custom scoring scheme
template <seqan3::arithmetic score_type = int8_t>
class uint8_adaptation_scoring_scheme : public seqan3::scoring_scheme_base<
    uint8_adaptation_scoring_scheme<score_type>, 
    uint8_t, score_type
> {
private:
    using base_t = seqan3::scoring_scheme_base<uint8_adaptation_scoring_scheme<score_type>, uint8_t, score_type>;
    friend base_t;

public:
    constexpr uint8_adaptation_scoring_scheme() noexcept 
        : base_t(seqan3::match_score<score_type>{0}, seqan3::mismatch_score<score_type>{-1}) {};
};

// alignment config
 auto config = seqan3::align_cfg::method_global{}
    | seqan3::align_cfg::scoring_scheme{uint8_adaptation_scoring_scheme{}} // gap scheme defaults to edit distance
    | seqan3::align_cfg::min_score{-10}; // <-- this doesn't work

seqan3::align_pairwise(std::tie(reference, query), config);

This code compiles, but I get the following runtime error:

The align_cfg::min_score configuration is only allowed for the specific edit distance computation

Would it be possible to add a feature that allows this code to work and let me use the min_score config (for optimization purposes)?

@feldroop feldroop added the feature/proposal a new feature or an idea of label May 8, 2024
@rrahn
Copy link
Contributor

rrahn commented May 9, 2024

Thanks for reporting this. At the moment we explicitly allow the fast myers edit distance computation only for nucleotide scoring schemes and min_score is only implemented for this type of algorithm and not the general DP algorithm.
This however is somewhat limiting as the bitparallel algorithm doesn't even need to access the scoring scheme once since the score values are predefined anyway.
Solving this, however, is less intuitive than I first expected, but I am looking into ways how to solve this.

@rrahn
Copy link
Contributor

rrahn commented May 15, 2024

@feldroop with the above linked PR your code should just work by sticking to the seqan3::align_cfg::edit_scheme{} without setting the scoring scheme or the gap scheme explicitly.

@eseiler
Copy link
Member

eseiler commented May 31, 2024

As far as I understand, this should now work?

auto config = seqan3::align_cfg::method_global{}
            | seqan3::align_cfg::scoring_scheme{seqan3::hamming_scoring_scheme{}}
            | seqan3::align_cfg::min_score{-10};

seqan3::align_pairwise(std::tie(reference, query), config);

@feldroop
Copy link
Member Author

Yes, and this also works even with an adapted uint8 alphabet, which is exactly my use case.

auto config = seqan3::align_cfg::method_global{}
            | seqan3::align_cfg::edit_scheme
            | seqan3::align_cfg::min_score{-10};

seqan3::align_pairwise(std::tie(reference, query), config);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/proposal a new feature or an idea of
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants