-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparseBlastXML.py
executable file
·64 lines (43 loc) · 1.74 KB
/
parseBlastXML.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/env python2.7
import sys
import os
import argparse
def main():
args=processArgs()
"""
def processArgs():
class MyParser(argparse.ArgumentParser):
def error(self, message):
sys.stderr.write('\nerror: %s\n\n' % message)
self.print_help()
sys.exit(2)
argParser = MyParser()
argParser.add_argument('file', help="CHANGEME")
if len(sys.argv)==1:
argParser.print_help()
sys.exit(1)
args = argParser.parse_args()
return args
"""
def processArgs():
class MyParser(argparse.ArgumentParser):
def error(self, message):
sys.stderr.write('\nerror: %s\n\n' % message)
self.print_help()
sys.exit(2)
class Checkerrors(argparse.Action) :
def __call__(self,parser,namespace,value,option_string) :
if (option_string=="-f") :
if (os.path.isfile(value)==False) :
parser.error("The -f flag needs a valid filename")
else :
setattr(namespace,self.dest,value)
#argParser = MyParser(usage=("%s (sourceDir & filter) | filterFile" % (os.path.basename(sys.argv[0]))))
argParser = MyParser(description="""Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris rutrum
egestas magna, ac blandit odio pharetra non. Ut cursus ligula in arcu hendrerit
pretium id lobortis urna. Aenean a porttitor.
""")
argParser.add_argument('file', metavar="", help="Changeme")
#This is required because by default this is a module. Running this makes it execute main as if it is a script
if __name__ == '__main__':
main()