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
Added 'testseq' function #1262
Added 'testseq' function #1262
Conversation
I've reviewed the Travis CI test failures and they all occurred during the docstring tests. Due to the random nature of the sequence generation, no two occurences will be exactly alike. It would mean a lot to me if you would help me figure out how to circumvent this situation. Thanks, |
Alright. I've decided to add a random seed to the function. The user will have the option of changing the seed as a function argument. I will also play around with having a global Boolean variable that the user can change to revert the function's behavior to what it is currently but it will require some testing. Thanks, |
As you have noticed, random examples are not well suited to doctests. I'm wondering if rather than adding a (Note the Tutorial is currently written in LaTeX with special comments for doctests which are run via I think we should ask for more opinions on the Biopython(-dev) mailing list - are you subscribed to those? http://biopython.org/wiki/Mailing_lists |
- added global seed variable 'shuffle_seed' - added argument 'rand_seed' - added argument 'shuffle' - updated docstrings to seeded outputs - updated docstrings to include new arguments
Just a couple of comments. While I think that this is a good idea for the purpose of education, I don't know if there is any obvious utility in everyday research use. Happy to hear otherwise - I haven't given this too much thought yet. As such, I think I agree with @peterjc that this would be better off somewhere other than the main SeqUtils module. Or perhaps we keep it under SeqUtils, but don't import it by default? A few comments on the code itself. I'd be really hesitant to introduce a global variable (
Without providing another seed, we get a different number the second time we call random()
Resetting the seed reproduces the same sequence of random numbers
Given this, I think you can reduce your random seeding code down to:
Set the default random seed to 0. No need to use an arbitrary number such as 9001. And you can then drop the One other comment from my cursory look at this - if a user sets Happy to give this a more thorough review if there is consensus that this is a useful addition to the code-base. Edit: You need to set the default random seed to |
For random number generation, an even better idea would be to instantiate a local version of the |
Hi Adil, I've just seen your message on the dev mailing list. With regards to the random number generation, I would put the Within the function body you can then reduce it to:
No need to convert the seed to an integer, as Python uses the hash of the provided seed, so the seed can really be any hashable object. |
See Pull Request #1269 |
Hopefully resolved all of the Travis CI style conflicts.
This function (and all of its helper functions/classes) have been instrumental in demonstrating the Biopython module to others. My hope is to pass this utility on to others and help them as well.
Very open to comments and criticisms. And will support my work for the foreseeable future.