From f63373265f75a3968424f4d2ca528d280c5dea21 Mon Sep 17 00:00:00 2001 From: aakechin Date: Wed, 5 Sep 2018 18:40:54 +0700 Subject: [PATCH] Fix bug of checking output files --- cutPrimers.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/cutPrimers.py b/cutPrimers.py index 1ddb6af..cc23849 100644 --- a/cutPrimers.py +++ b/cutPrimers.py @@ -320,6 +320,19 @@ def trimPrimers(data): print('ERROR! Could not create file:',args.trimmedReadsR1) print('########') exit(0) + if args.untrimmedReadsR1==args.trimmedReadsR1: + untrimmedReadsR1=trimmedReadsR1 + else: + try: + if args.untrimmedReadsR1[-3:]!='.gz': + untrimmedReadsR1=open(args.untrimmedReadsR1,'w') + else: + untrimmedReadsR1=gzip.open(args.untrimmedReadsR1,'wt') + except FileNotFoundError: + print('########') + print('ERROR! Could not create file:',args.untrimmedReadsR1) + print('########') + exit(0) if args.trimmedReadsR2: try: if args.trimmedReadsR2[-3:]!='.gz': @@ -331,19 +344,6 @@ def trimPrimers(data): print('ERROR! Could not create file:',args.trimmedReadsR2) print('########') exit(0) - if args.untrimmedReadsR1==args.trimmedReadsR1: - untrimmedReadsR1=trimmedReadsR1 - else: - try: - if args.untrimmedReadsR1[-3:]!='.gz': - untrimmedReadsR1=open(args.untrimmedReadsR1,'w') - else: - untrimmedReadsR1=gzip.open(args.untrimmedReadsR1,'wt') - except FileNotFoundError: - print('########') - print('ERROR! Could not create file:',args.untrimmedReadsR1) - print('########') - exit(0) if args.untrimmedReadsR2: if args.untrimmedReadsR2==args.trimmedReadsR2: untrimmedReadsR2=trimmedReadsR2