From 51c8028d6f028702f3d1254b077eaa62206b8156 Mon Sep 17 00:00:00 2001 From: vishakad Date: Fri, 29 Mar 2019 12:41:47 +0530 Subject: [PATCH] Creates PCR output directory if it does not exist Earlier commit did not deal with the case when the output/pcr-data/ directory did not exist on the current working directory from which the script is executed. Now, the output/pcr-data sub-directory is created when it does not exist. --- PCR.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/PCR.py b/PCR.py index d4fd44a..688b2d9 100644 --- a/PCR.py +++ b/PCR.py @@ -1,6 +1,7 @@ import numpy as np import sys -from os.path import isfile, join +from os.path import isfile, join, isdir +from os import makedirs from scipy.sparse import dok_matrix from scipy.stats import binom @@ -161,7 +162,11 @@ def computePCRdist( self, pAmp ): data sets." Nucleic acids research 43.21 (2015): e143-e143. """ - possFilePath = join( sys.path[0], 'output', 'pcr-data', '{}-{}.npy'.format( self.nCycles, pAmp ) ) + outputPcrPath = join( sys.path[0], 'output', 'pcr-data' ) + if not isdir( outputPcrPath ): + makedirs( join( outputPcrPath ) ) + + possFilePath = join( outputPcrPath, '{}-{}.npy'.format( self.nCycles, pAmp ) ) #In case the distribution has been already computed before, retrieve it #and return it instead of re-computing it afresh.