comparison allele-counts.py @ 2:d83368b907f7

No error on existing output file
author nick
date Fri, 24 May 2013 10:54:13 -0400
parents 57e85db3f13c
children 4627d99aa105
comparison
equal deleted inserted replaced
1:7c95db468ad5 2:d83368b907f7
97 97
98 # set outfile_handle to either stdout or the output file 98 # set outfile_handle to either stdout or the output file
99 if outfile == OPT_DEFAULTS.get('outfile'): 99 if outfile == OPT_DEFAULTS.get('outfile'):
100 outfile_handle = sys.stdout 100 outfile_handle = sys.stdout
101 else: 101 else:
102 if os.path.exists(outfile): 102 try:
103 fail('Error: The given output filename '+outfile+' already exists.')
104 else:
105 outfile_handle = open(outfile, 'w') 103 outfile_handle = open(outfile, 'w')
104 except IOError, e:
105 fail('Error: The given output filename '+outfile+' could not be opened.')
106 106
107 if print_header: 107 if print_header:
108 outfile_handle.write('#'+'\t'.join(COLUMNS)+"\n") 108 outfile_handle.write('#'+'\t'.join(COLUMNS)+"\n")
109 109
110 # main loop: process and print one line at a time 110 # main loop: process and print one line at a time