From 5cef63d83945773caf2c8c64cca28b8f83a4483b Mon Sep 17 00:00:00 2001 From: Guoyi Zhang Date: Sun, 8 Dec 2024 18:08:00 +1100 Subject: [PATCH] polish: add some para check --- RGBEPP.d | 63 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/RGBEPP.d b/RGBEPP.d index 2211afe..45b907b 100644 --- a/RGBEPP.d +++ b/RGBEPP.d @@ -59,6 +59,14 @@ bool testFiles(string[] filePaths) { return pass; } +bool testString(string input) { + return input.length != 0; +} + +bool testStringArray(string[] input) { + return !input.empty; +} + void createDir(string path) { if (!exists(path)) { mkdir(path); @@ -587,55 +595,68 @@ void main(string[] args) { writeln("RGBEPP::Start"); // Perform steps based on provided function argument if (ARG_F == "all" || ARG_F == "clean") { - if(testFiles([PathFastp])){ - processQcTrim(ARG_L, ARG_T, DirRaw, DirQcTrim, PathFastp); + if(testFiles([PathFastp]) && testStringArray(ARG_L)){ + processQcTrim(ARG_L, ARG_T, DirRaw, DirQcTrim, PathFastp); //ARG_L + } else { + throw new Exception("please confirm paramenters are correct"); } } if (ARG_F == "all" || ARG_F == "assembly") { - if(testFiles([PathSpades])){ - processAssembly(ARG_L, ARG_M, ARG_T, DirQcTrim, DirAssembly, PathSpades); + if(testFiles([PathSpades]) && testStringArray(ARG_L)){ + processAssembly(ARG_L, ARG_M, ARG_T, DirQcTrim, DirAssembly, PathSpades); //ARG_L processAssemMv(ARG_L, DirAssembly); + } else { + throw new Exception("please confirm paramenters are correct"); } - } if (ARG_F == "all" || ARG_F == "map") { - if(testFiles([PathBowtie2, PathDiamond, PathSamtools, PathSortDiamond])){ - processMappingDenovo(ARG_L, ARG_R, ARG_T, DirQcTrim, DirAssembly, DirMap, PathBowtie2, PathDiamond, PathSamtools, PathSortDiamond); + if(testFiles([PathBowtie2, PathDiamond, PathSamtools, PathSortDiamond]) && testStringArray(ARG_L) && testString(ARG_R) ){ + processMappingDenovo(ARG_L, ARG_R, ARG_T, DirQcTrim, DirAssembly, DirMap, PathBowtie2, PathDiamond, PathSamtools, PathSortDiamond); //ARG_L, ARG_R + } else { + throw new Exception("please confirm paramenters are correct"); } } if (ARG_F == "all" || ARG_F == "postmap") { - if(testFiles([PathSamtools])){ - processPostMap(ARG_L, ARG_T, DirMap, DirBam, PathSamtools); - } + if(testFiles([PathSamtools]) && testStringArray(ARG_L) ){ + processPostMap(ARG_L, ARG_T, DirMap, DirBam, PathSamtools); //ARG_L + } else { + throw new Exception("please confirm paramenters are correct"); + } } if (ARG_F == "all" || ARG_F == "varcall") { - if(testFiles([PathBcftools])){ - processVarCallDenovo(ARG_L, ARG_T, DirAssembly, DirMap, DirBam, DirVcf, PathBcftools); - + if(testFiles([PathBcftools]) && testStringArray(ARG_L) ){ + processVarCallDenovo(ARG_L, ARG_T, DirAssembly, DirMap, DirBam, DirVcf, PathBcftools); //ARG_L + } else { + throw new Exception("please confirm paramenters are correct"); } - } if (ARG_F == "all" || ARG_F == "consen") { - if(testFiles([PathBcftools])){ - processConDenovo(ARG_G, ARG_L, ARG_T, DirAssembly, DirVcf, DirConsensus, PathBcftools); - processCombFasta(ARG_G, ARG_L, DirConsensus); + if(testFiles([PathBcftools]) && testStringArray(ARG_L) && testStringArray(ARG_G) ){ + processConDenovo(ARG_G, ARG_L, ARG_T, DirAssembly, DirVcf, DirConsensus, PathBcftools); //ARG_G ARG_L + processCombFasta(ARG_G, ARG_L, DirConsensus); //ARG_G ARG_L + } else { + throw new Exception("please confirm paramenters are correct"); } } if (ARG_F == "all" || ARG_F == "align") { - if(testFiles([PathMacse]) && testJava){ - processAlign(ARG_G, DirConsensus, DirAlign, PathMacse); + if(testFiles([PathMacse]) && testJava && testStringArray(ARG_G)){ + processAlign(ARG_G, DirConsensus, DirAlign, PathMacse); //ARG_G + } else { + throw new Exception("please confirm paramenters are correct"); } } if (ARG_F == "all" || ARG_F == "trim") { - if(testFiles([PathTrimal])){ - processTrimming(ARG_G, DirAlign, DirTrim, PathDelstop, PathTrimal); + if(testFiles([PathTrimal]) && testStringArray(ARG_G) ){ + processTrimming(ARG_G, DirAlign, DirTrim, PathDelstop, PathTrimal); //ARG_G + } else { + throw new Exception("please confirm paramenters are correct"); } }