From 51630f70069dddb239d3d0496b2ee4df30540337 Mon Sep 17 00:00:00 2001 From: Guoyi Zhang Date: Mon, 9 Dec 2024 16:22:03 +1100 Subject: [PATCH] fix: ref and gen conflict & " issue & splitfasta path --- RGBEPP.d | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/RGBEPP.d b/RGBEPP.d index 1d868db..b0854e2 100644 --- a/RGBEPP.d +++ b/RGBEPP.d @@ -426,7 +426,7 @@ void processCombFasta(string[] ARG_G, string[] ARG_L, string DirConsensus) { writeln("ConvertFasta::End"); } -void splitFasta(const string inputFasta) { +void splitFasta(string inputFasta, string DirOut) { File infile; try { infile = File(inputFasta, "r"); @@ -449,7 +449,7 @@ void splitFasta(const string inputFasta) { outfile.close(); // previous output file } seqName = cast(string)lineContent[1 .. $]; // Remove '>' - string outputFile = seqName ~ ".fasta"; // suitable to many os + string outputFile = buildPath(DirOut, seqName ~ ".fasta"); // suitable to many os outfile = File(outputFile, "w"); outfile.writeln(">", getBaseName(inputFasta)); // will enter sequence @@ -480,21 +480,27 @@ void processCodon(string[] ARG_G, string ARG_R, string DirConsensus, string Path string ARG_R_Base = getBaseName(ARG_R); string ARG_R_Ref = buildPath(DirConsensus, ARG_R_Base ~ ".fasta"); copy(ARG_R, ARG_R_Ref); - splitFasta(ARG_R_Ref); - - moveDir(DirConGene, DirConGene ~ "_bak"); + splitFasta(ARG_R_Ref, DirConsensus); + if (!exists(DirConGene ~ "_bak")) { + moveDir(DirConGene, DirConGene ~ "_bak"); + } + if (!exists(DirConGene)) { + createDir(DirConGene); + } + writeln("GetCodon::Start"); foreach (gene; ARG_G) { string inputFile = buildPath(DirConGene ~ "_bak", gene ~ ".fasta"); string outputFile = buildPath(DirConGene, gene ~ ".fasta"); string referFile = buildPath(DirConsensus, gene ~ ".fasta"); + if (!exists(inputFile)) { writeln("File not found: ", inputFile); continue; } else { - string[] cmdExonerate = [PathExonerate, inputFile, referFile, "--showalignment", "no", "--showvulgar", "no", "--showtargetgff", "no", "--ryo", "\">%qi\n%qcs\n\"", "--verbose", "0"]; + string[] cmdExonerate = [PathExonerate, inputFile, referFile, "--showalignment", "no", "--showvulgar", "no", "--showtargetgff", "no", "--ryo", ">%qi\n%qcs\n", "--verbose", "0"]; executeCommandToFile(cmdExonerate, outputFile); } std.file.remove(referFile); @@ -692,7 +698,7 @@ void main(string[] args) { } // get gene from ARG_R reference fasta - if (ARG_R.length != 0 ){ + if (ARG_R.length != 0 && ARG_R.length == 0 ){ ARG_G = getARG_G(ARG_R); }