diff 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
line wrap: on
line diff
--- a/allele-counts.py	Fri May 24 08:55:29 2013 -0400
+++ b/allele-counts.py	Fri May 24 10:54:13 2013 -0400
@@ -99,10 +99,10 @@
   if outfile == OPT_DEFAULTS.get('outfile'):
     outfile_handle = sys.stdout
   else:
-    if os.path.exists(outfile):
-      fail('Error: The given output filename '+outfile+' already exists.')
-    else:
+    try:
       outfile_handle = open(outfile, 'w')
+    except IOError, e:
+      fail('Error: The given output filename '+outfile+' could not be opened.')
 
   if print_header:
     outfile_handle.write('#'+'\t'.join(COLUMNS)+"\n")