From 94241d6c8703a601c1e4dd6e8627e137ffa25426 Mon Sep 17 00:00:00 2001 From: Sarvesh Prakash Nikumbh Date: Mon, 31 Jul 2017 15:19:57 +0200 Subject: [PATCH] Adding readConfigFile function was pending --- readConfigFile.m | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 readConfigFile.m diff --git a/readConfigFile.m b/readConfigFile.m new file mode 100644 index 0000000..ab3a40b --- /dev/null +++ b/readConfigFile.m @@ -0,0 +1,76 @@ +function configParams = readConfigFile(configFilename) + +% READCONFIGFILE +% Reads all the parameter values given in the config file and returns +% a structure of all the params +% +% INPUT PARAMS +% Param 'configFilename' (string) +% Config filename to read the parameter values from. +% +% OUTPUT PARAMS +% configParams +% A struct with all variables +% +% ADDITIONAL NOTES +% +% Author: snikumbh@mpi-inf.mpg.de + + +fid = fopen(configFilename, 'r'); + +while feof(fid) == 0 + l = fgetl(fid); + if findstr(l, '##') > 0 + % skip the comment lines + elseif findstr(l, '=') > 0 + l2 = strsplit(l,'='); + switch(l2{1}) + case 'POSITIVE_FASTA_FILE' + configParams.givenPosFastaFilename = l2{2}; + case 'NEGATIVE_FASTA_FILE' + configParams.givenNegFastaFilename = l2{2}; + case 'NUMBER_OF_POSITIVES' + configParams.nPosSequences = str2num(l2{2}); + case 'NUMBER_OF_NEGATIVES' + configParams.nNegSequences = str2num(l2{2}); + case 'TEST_INDICES' + configParams.testIndices = eval(l2{2}); + case 'OUTPUT_FOLDER' + configParams.outputFolder = l2{2}; + case 'OLIGO_LEN' + configParams.oligoLen = eval(l2{2}); + case 'MAX_DIST' + configParams.maxDist = str2num(l2{2}); + case 'SEGMENT_SIZE_IN_BPS' + configParams.segmentSizeInBps = str2num(l2{2}); + case 'NUMBER_OF_CLUSTERS' + configParams.nClusterVals = eval(l2{2}); + case 'SIGMA_VALUES' + configParams.sigmaVals = eval(l2{2}); + case 'COST_VALUES' + configParams.Cs = eval(l2{2}); + case 'MKL_NORM' + configParams.mklNorm = str2num(l2{2}); + case 'NUMBER_OF_INNER_FOLDS' + configParams.nFolds = str2num(l2{2}); + case 'NUMBER_OF_OUTER_FOLDS' + configParams.nOuterFolds = str2num(l2{2}); + case 'WHETHER_TO_PLOT_HEATMAP' + configParams.whetherToPlotHeatmap = l2{2}; + case 'WHETHER_TO_VISUALIZE_WEIGHT_VECTOR' + configParams.whetherToVisualizeWVector = l2{2}; + case 'DEBUG_LEVEL' + configParams.debugLevel = str2num(l2{2}); + case 'DEBUG_MSG_LOCATION' + configParams.debugMsgLocation = l2{2}; + case 'COMPUTATION_VERSION' + configParams.computationVersion = l2{2}; + end % switch ends + else + + end % if-else ends +end % while ends +fclose(fid); + +end