I am trying to develop a python3 script using the click module to pass the arguments from commandline to variables in the script. my python3 version is 3.8.3 on a ubuntu 20.04 desktop.
The file is listed as following:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import click
@click.command()
@click.option('--bam', '-b', multiple=True, type=string, hide_input=False, required=True, help="BAM input")
@click.option('--threads', '-t', default=1, nargs=1, type=int, hide_input=False, required=False, help="Number of threads")
@click.option('--out', '-o', default="MyOut.stats", nargs=1, type=string, hide_input=False, required=False, help="Statistics Output")
debug_mode = 0
When I run it, I got a syntax error:
File "****/alignment_stats.py", line 12
debug_mode = 0
^
SyntaxError: invalid syntax
It seems the error locates at the line '@click.command()', but I can not figure it out why?
I am familiar with perl, but quite new to python3. If anyone knows the answer, please help.
1 answer
Sorry, it seems a computer-technical question rather than bioinformatics. I have moved this post to StackOverflow as suggested. One student in Computation College told me an sub-function should be added as a sub-func following 'click.option'. So basically I have solved this problem. Please help close this post. Thank you very much
Log in to answer this question.
Though this is building a bioinformatics tool, this isn't really a bioinformatics question. I won't close it just yet, but my advice would be to ask this over on StackOverflow anyway where you are more likely to get input from more people who use
clickregularly.I can't see anything obviously wrong in your code snippet, but its possible something outside of what you've shown us is the problem. Is what you pasted accurate in terms of indentation level etc?
Hello phoenixice154!
We believe that this post does not fit the main topic of this site.
Not a bioinformatics question - resolved on StackOverflow.
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!