Skip to content

Sarah-Hesham-2022/BioPython-Getopt-Biological-Command-Line-Interpreter

Repository files navigation

BioPython-Getopt-Biological-Command-Line-Interpreter

BioPython Project using getopt library in python

image image image image image image image image image image image image

-All files used in the python code to check the functionality are uploaded including input and output results files.

-Some important remarks regarding the getopt library:

-An option followed by a colon only means that it needs an argument.

-It doesn't mean that the option is enforced. You should write your own code to enforce the existence of options/arguments.

-getopt.getopt(args, shortopts, longopts=[])

-Parses command line options and parameter list.

-args is the argument list to be parsed, without the leading reference to the running program. Typically, this means sys.argv[1:].

-shortopts is the string of option letters that the script wants to recognize,

-with options that require an argument followed by a colon (':'; i.e., the same format that Unix getopt() uses).

-exception getopt.GetoptError

-This is raised when an unrecognized option is found in the argument list or when an option requiring an argument is given none. The argument to the exception

-is a string indicating the cause of the error. For long options, an argument given to an option which does not require one will also cause this exception to be raised.

-The attributes msg and opt give the error message and related option; if there is no specific option to which the exception relates, opt is an empty string.

-One of the most important remarks is:

-that the getopt function reads options and forms a dictionary of each option and its argument if and only if the first

-input was an option ,rather than that it will consider the whole input as an argument even if there are option passed and the opts array will be empty in that case.

-Example Usage

-Short Form

-python3 code.py -s 2000-1-2 -e 2002-1-1

-Long Form

-python3 code.py --start_date 2000-1-2 --end_date 2002-1-1

-Input Formats:

-In this code many types of inputs are allowed and also many types of errors are well handeled

-Permitted Input Formats:

-command name param1 param2 param3 ... -o option1 -x option2 -y option3 ...

-command name -o option1 -x option2 -y option3 ...

-command name param1 param2 param3 ...

-So, your input can be only options associated with their arguments parameters

-or Only arguments

-Or a mix of options and arguments parameters

-In all these cases, many other logical errors are handeled according to the function type and functionality

-So as to give user freedom in their input format

-Also here are 20+ examples with all possible inputs from the user and using all function as well:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25