Commit ef2a927a authored by Thomas Schwarzl's avatar Thomas Schwarzl

added checks and contraints for command line options

parent dfadd1f5
......@@ -45,16 +45,16 @@ OUTFILE = ""
LOGOUT = ""
# stem size
STEM_SIZE = 3#5
STEM_SIZE = 5
# loop size
MIN_LOOP_SIZE = 2#4
MIN_LOOP_SIZE = 4
# loop size
MAX_LOOP_SIZE = 2#6
MAX_LOOP_SIZE = 6
# maximum gap size
MAX_GAP_SIZE = 0 #2
MAX_GAP_SIZE = 2
# maximum total gap count
MAX_TOTAL_GAP_COUNT = 2
......@@ -63,7 +63,7 @@ MAX_TOTAL_GAP_COUNT = 2
MIN_MATCHES_BEFORE_FIRST_GAP = 2
# minimum GC content
MIN_GC_CONTENT = 0.9
MIN_GC_CONTENT = 0.2
__HELP__ = '''
......@@ -143,8 +143,10 @@ from lib.StemLoopFactory import StemLoopFactory
LOGGER = logging.getLogger()
def exceptionHandling(exception):
global options
if options.__VERBOSE__:
traceback.print_exc()
print(str(exception))
traceback.print_exc()
os._exit(1)
def main():
......@@ -270,14 +272,28 @@ if __name__ == '__main__':
if len(args) > 1:
parser.error ('too many arguments')
if options.MIN_LOOP_SIZE > options.MAX_LOOP_SIZE:
raise Exception("minimal loop size cannot be bigger than maximal loop size")
if not options.MIN_GC_CONTENT >= 0.0 and options.MIN_GC_CONTENT <= 1.0:
raise Exception("minimal gc content has to be between 0 and 1 [0% and 100%]")
if options.MAX_GAP_SIZE < 0:
raise Exception("maximal gap size has to be greater or equal 0")
if options.MAX_TOTAL_GAP_COUNT < 0:
raise Exception("maximal total gap count has to be greater or equal 0")
if options.MIN_MATCHES_BEFORE_FIRST_GAP < 0:
raise Exception("minimal matches before first gap has to be greater or equal 0")
if options.STEM_SIZE < 1:
raise Exception("stem size has to be greater than 0")
main()
# Exception Handling: Interruption / Errors
except KeyboardInterrupt as exception: # Control - C
raise exception
print("Program was stopped. (Ctrl + C / KeyboardInterrupt)")
sys.stderr.close()
except SystemExit as exception:
raise exception
except Exception as exception:
print('Error.')
print("------------[ Error ]--------------")
exceptionHandling(exception)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment