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

[TEST] implement sequence generator #1985

Merged
merged 1 commit into from
Oct 8, 2020

Conversation

Irallia
Copy link
Contributor

@Irallia Irallia commented Jul 15, 2020

resolves part of seqan/product_backlog#12

The first commit will be done by another PR: #1995 ([TEST] Repair seqan2 tests)

@codecov
Copy link

codecov bot commented Jul 15, 2020

Codecov Report

Merging #1985 into master will increase coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1985   +/-   ##
=======================================
  Coverage   97.97%   97.98%           
=======================================
  Files         262      262           
  Lines       10045    10054    +9     
=======================================
+ Hits         9842     9851    +9     
  Misses        203      203           
Impacted Files Coverage Δ
include/seqan3/range/views/move.hpp
include/seqan3/alphabet/nucleotide/dna4.hpp
include/seqan3/alphabet/nucleotide/dna3bs.hpp
include/seqan3/core/detail/debug_stream_range.hpp
include/seqan3/io/detail/record.hpp
include/seqan3/alphabet/hash.hpp
...ignment/pairwise/policy/affine_gap_init_policy.hpp
...qan3/alignment/pairwise/edit_distance_unbanded.hpp
include/seqan3/alphabet/quality/phred63.hpp
.../matrix/detail/combined_score_and_trace_matrix.hpp
... and 513 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c4b1e79...c7bb6d2. Read the comment docs.

@Irallia Irallia marked this pull request as draft July 16, 2020 11:15
@marehr marehr self-requested a review July 27, 2020 09:12
@Irallia Irallia force-pushed the TEST/implement_sequence_generator branch 5 times, most recently from d61513a to 5cde5e6 Compare July 28, 2020 15:46
@Irallia Irallia self-assigned this Jul 28, 2020
@Irallia Irallia force-pushed the TEST/implement_sequence_generator branch 2 times, most recently from 1aec6de to 997f710 Compare August 3, 2020 08:29
@Irallia Irallia force-pushed the TEST/implement_sequence_generator branch 6 times, most recently from 30959f1 to fe7b96e Compare August 18, 2020 14:29
@Irallia Irallia force-pushed the TEST/implement_sequence_generator branch 2 times, most recently from d6a32ec to 6e1c646 Compare August 19, 2020 12:34
@Irallia Irallia marked this pull request as ready for review August 19, 2020 14:28
@Irallia Irallia requested a review from marehr August 19, 2020 14:29
Copy link
Member

@marehr marehr left a comment

Choose a reason for hiding this comment

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

First round :)

test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
@Irallia Irallia requested a review from marehr August 21, 2020 13:23
Copy link
Member

@marehr marehr left a comment

Choose a reason for hiding this comment

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

2nd Round :)

test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
@Irallia Irallia force-pushed the TEST/implement_sequence_generator branch from 32f6f0c to 649e389 Compare August 26, 2020 10:04
@Irallia
Copy link
Contributor Author

Irallia commented Aug 26, 2020

I get an error message in the seqan2 part of the sequence_generator_test. Should I just remove this part as it will be covered later?

In file included from .../seqan3/test/unit/test/sequence_generator_test.cpp:12:
.../seqan3/test/include/seqan3/test/performance/sequence_generator.hpp: In instantiation of 'sequence_t seqan3::test::random_sequence_generator<sequence_t>::operator()(generator_t&&) const [with generator_t = std::mersenne_twister_engine<long long unsigned int, 64, 312, 156, 31, 13043109905998158313, 29, 6148914691236517205, 17, 8202884508482404352, 37, 18444473444759240704, 43, 6364136223846793005>&; sequence_t = seqan::String<seqan::SimpleType<unsigned char, seqan::Dna_>, seqan::Alloc<> >]':
..../seqan3/test/unit/test/sequence_generator_test.cpp:101:68:   required from here
.../seqan3/test/include/seqan3/test/performance/sequence_generator.hpp:81:33: error: use of invalid variable template 'alphabet_size<alphabet_t>'
   81 |             max_alphabet_rank = alphabet_size<alphabet_t> - 1ull;
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~

@Irallia Irallia requested a review from marehr August 26, 2020 11:55
@eseiler
Copy link
Member

eseiler commented Aug 26, 2020

Seems like you are using the operator() in the seqan2 part, which then calls seqan3 stuff on seqan2 alphabets.
Wouldn't you need to call generate_sequence_seqan2 for the seqan2 part?

Copy link
Member

@marehr marehr left a comment

Choose a reason for hiding this comment

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

next round :)

test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
@Irallia
Copy link
Contributor Author

Irallia commented Aug 28, 2020

If you approve I will rebase and clear up the history.

@Irallia Irallia requested a review from marehr August 28, 2020 10:41
Copy link
Member

@marehr marehr left a comment

Choose a reason for hiding this comment

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

Thank you, we are nearly done :)

test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
test/unit/test/sequence_generator_test.cpp Outdated Show resolved Hide resolved
@Irallia Irallia requested a review from marehr August 31, 2020 10:21
Copy link
Member

@marehr marehr left a comment

Choose a reason for hiding this comment

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

Thank you, we are very close to finish :)

@Irallia Irallia force-pushed the TEST/implement_sequence_generator branch from 8768c7a to 18e21ed Compare September 3, 2020 16:48
@Irallia Irallia requested a review from marehr September 3, 2020 17:04
Copy link
Member

@marehr marehr left a comment

Choose a reason for hiding this comment

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

Thank you :) Second Reviewer do your work!

@Irallia Irallia requested a review from rrahn September 7, 2020 09:12
Copy link
Contributor

@rrahn rrahn left a comment

Choose a reason for hiding this comment

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

This is already a big start towards a better design :).
I found some issues that should be addressed. Otherwise it looks fine to me.
Thank you!

std::uniform_int_distribution<size_t> dis_alpha(0ull, max_val);
std::uniform_int_distribution<size_t> dis_length(len - variance, len + variance);
public:

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

~random_sequence_generator() = default; //!< Defaulted

/*!\brief Initialises a random sequence generator which generates sequences with a given mean size.
* \param[in] size The size of the random sequence.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* \param[in] size The size of the random sequence.
* \param[in] size The size of the random sequence.


/*!\brief Initialises a random sequence generator which generates sequences with a given mean size.
* \param[in] size The size of the random sequence.
* \param[in] size_variance The variance of the random sequence size.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* \param[in] size_variance The variance of the random sequence size.
* \param[in] size_variance The variance of the random sequence size (defaults to `0`).

*/

/*!\brief Returns a random sequence for a set size (and variance).
* \param[in,out] random_generator e.g. std::mt19937 with a seed of 42
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* \param[in,out] random_generator e.g. std::mt19937 with a seed of 42
* \param[in,out] random_generator, e.g. std::mt19937 with a seed of 42


/*!\brief Returns a random sequence for a set size (and variance).
* \param[in,out] random_generator e.g. std::mt19937 with a seed of 42
* \returns a random generated sequence.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* \returns a random generated sequence.
* \returns a generated random sequence.

std::uniform_int_distribution<size_t> alphabet_rank_distribution(0ull, max_alphabet_rank);
std::uniform_int_distribution<size_t> sequence_size_distribution(size - size_variance, size + size_variance);

size_t sequence_size = sequence_size_distribution(random_generator);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
size_t sequence_size = sequence_size_distribution(random_generator);
size_t const sequence_size = sequence_size_distribution(random_generator);


size_t sequence_size = sequence_size_distribution(random_generator);
sequence_t random_sequence(sequence_size);
std::ranges::generate(random_sequence, [&]() -> alphabet_t
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
std::ranges::generate(random_sequence, [&]() -> alphabet_t
std::ranges::generate(random_sequence, [&] () -> alphabet_t

std::uniform_int_distribution<size_t> sequence_size_distribution(size - size_variance, size + size_variance);

size_t sequence_size = sequence_size_distribution(random_generator);
sequence_t random_sequence(sequence_size);
Copy link
Contributor

Choose a reason for hiding this comment

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

Pheww, can we actually assume that this does in fact always does what we expect? I think this is not handled properly by the concepts yet. The biggest problem that I see is handling the SeqAn2 sequence types which do not have push_back or resize member functions. So I guess later on we need to use a helper function to differentiate between sequences that have a resize member function. For now I propose to add this inline requires clause in the head of the class template:

requires requires (sequence_t & s) { {s.resize()}; }

And then use here the resize member function instead of the constructor.

@Irallia Irallia force-pushed the TEST/implement_sequence_generator branch from 18e21ed to 7c7cc61 Compare September 10, 2020 11:19
@Irallia Irallia requested a review from rrahn September 10, 2020 14:38
template <typename sequence_t>
//!\cond
requires (std::ranges::output_range<sequence_t, std::ranges::range_value_t<sequence_t>> &&
requires (sequence_t & s) { {s.resize(1)}; } )
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
requires (sequence_t & s) { {s.resize(1)}; } )
requires (sequence_t & s) { {s.resize(1)}; })

else
sequence.push_back(assign_rank_to(dis_alpha(gen), alphabet_t{}));
max_alphabet_rank = alphabet_size<alphabet_t> - 1ull;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
max_alphabet_rank = alphabet_size<alphabet_t> - 1ull;
max_alphabet_rank = seqan3::alphabet_size<alphabet_t> - 1ull;

if constexpr (std::is_same_v<alphabet_t, uint64_t>)
return alphabet_rank_distribution(random_generator);
else
return assign_rank_to(alphabet_rank_distribution(random_generator), alphabet_t{});
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return assign_rank_to(alphabet_rank_distribution(random_generator), alphabet_t{});
return seqan3::assign_rank_to(alphabet_rank_distribution(random_generator), alphabet_t{});

@Irallia Irallia force-pushed the TEST/implement_sequence_generator branch from 7c7cc61 to d6012fc Compare September 22, 2020 08:54
@Irallia Irallia requested a review from rrahn September 22, 2020 09:20
Copy link
Contributor

@rrahn rrahn left a comment

Choose a reason for hiding this comment

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

Minor stuff only. Please rebase right away. I approve already.

*/

/*!\brief Returns a random sequence for a set size (and variance).
* \param[in,out] random_generator, e.g. std::mt19937 with a seed of 42
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* \param[in,out] random_generator, e.g. std::mt19937 with a seed of 42
* \param[in,out] random_generator, e.g. std::mt19937 with a seed of 42.


/*!\brief Returns a random sequence for a set size (and variance).
* \param[in,out] random_generator, e.g. std::mt19937 with a seed of 42
* \returns a generated random sequence.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* \returns a generated random sequence.
* \returns A generated random sequence.

Signed-off-by: Lydia Buntrock <lydia.buntrock@fu-berlin.de>
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.

4 participants