Commit 5531345a authored by simon verdez's avatar simon verdez

change output in create html

parent f13b5639
...@@ -202,7 +202,7 @@ def main(): ...@@ -202,7 +202,7 @@ def main():
if opt in ("-t"): if opt in ("-t"):
tsvfile = arg tsvfile = arg
elif opt in ("-o"): elif opt in ("-o"):
sys.stdout = open(arg, 'w') outputfile = arg
except getopt.GetoptError: except getopt.GetoptError:
print("please use this command as follow: ") print("please use this command as follow: ")
print('usage : python2.7 create_html.py -v <vcf/file> -h <report/from/HLAscan> -t tableau_pharmgkb.tsv -o <path/to/file/results>') print('usage : python2.7 create_html.py -v <vcf/file> -h <report/from/HLAscan> -t tableau_pharmgkb.tsv -o <path/to/file/results>')
...@@ -222,6 +222,10 @@ def main(): ...@@ -222,6 +222,10 @@ def main():
print('No tsv file given') print('No tsv file given')
print('usage : python2.7 create_html.py -v <vcf/file> -h <report/from/HLAscan> -t tableau_pharmgkb.tsv -o <path/to/file/results>') print('usage : python2.7 create_html.py -v <vcf/file> -h <report/from/HLAscan> -t tableau_pharmgkb.tsv -o <path/to/file/results>')
sys.exit(1) sys.exit(1)
if not vars().has_key('outputfile'):
print('No output file given')
print('usage : python2.7 create_html.py -v <vcf/file> -h <report/from/HLAscan> -t tableau_pharmgkb.tsv -o <path/to/file/results>')
sys.exit(1)
# Check files # Check files
try: try:
...@@ -242,6 +246,12 @@ def main(): ...@@ -242,6 +246,12 @@ def main():
except IOError: except IOError:
print('PharmGKB tsv file does not exist') print('PharmGKB tsv file does not exist')
sys.exit(1) sys.exit(1)
try:
f = open(outputfile, 'w')
f.close()
except IOError:
print("Can't open output file" )
sys.exit(1)
#execute #execute
...@@ -251,7 +261,8 @@ def main(): ...@@ -251,7 +261,8 @@ def main():
body=extract_rs(tsvfile,vcfSNP,DictRs,body) body=extract_rs(tsvfile,vcfSNP,DictRs,body)
body=extract_HLA(report,DictHLA,body) body=extract_HLA(report,DictHLA,body)
print(htmltag.HTML(head+body)) with open(outputfile,'w') as output:
output.write(htmltag.HTML(head+body))
if __name__ == "__main__": if __name__ == "__main__":
main() main()
\ 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