I am trying to pass BioPython sequences to Ilya Stepanov's implementation of Ukkonen's suffix tree algorithm in iPython's notebook environment. I am stumbling on the argparse component.
I have never had to deal directly with argparse before. How can I use this without rewriting main()?
By the by, this writeup of Ukkonen's algorithm is fantastic.
I ended up using BioPython to extract the sequences and then editing Ilya Steanov's implementation to remove the argparse methods.
For the algorithm, I had
main()
take one argument, hisstrings
variable, but this sends the algorithm a list of special BioPython Sequence objects, which the re module doesn't like. So I had to extract the sequence stringto
which seems kind of brittle, but that's all I've got for now.
If you use iPython for testing, transforming argparse into class format can be a quick dummy solution.
Github page repo offers transformation web service. http://35.192.144.192:8000/arg2cls.html
I hope that it would be helpful for your testing. Jan 9/19 many bugs are fixed.
Transformation script. Python3 is required.
then copy & paste class format to replace argparse functions.
I face a similar problem in invoking argsparse, the string '-f' was causing this problem. Just removing that from sys.srgv does the trick.
An alternative to use argparse in Ipython notebooks is passing a string to:
args = parser.parse_args()
(line 303 from the git repo you referenced.)Would be something like:
and
args = parser.parse_args("AAA --file /path/to/sequences.txt".split())
Edit: It works
I've had a similar problem before, but using
optparse
instead ofargparse
.You don't need to change anything in the original script, just assign a new list to
sys.argv
like so: