fix: ref and gen conflict & " issue & splitfasta path

This commit is contained in:
kuoi 2024-12-09 16:22:03 +11:00
parent caf80feabf
commit 51630f7006

View file

@ -426,7 +426,7 @@ void processCombFasta(string[] ARG_G, string[] ARG_L, string DirConsensus) {
writeln("ConvertFasta::End"); writeln("ConvertFasta::End");
} }
void splitFasta(const string inputFasta) { void splitFasta(string inputFasta, string DirOut) {
File infile; File infile;
try { try {
infile = File(inputFasta, "r"); infile = File(inputFasta, "r");
@ -449,7 +449,7 @@ void splitFasta(const string inputFasta) {
outfile.close(); // previous output file outfile.close(); // previous output file
} }
seqName = cast(string)lineContent[1 .. $]; // Remove '>' 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 = File(outputFile, "w");
outfile.writeln(">", getBaseName(inputFasta)); outfile.writeln(">", getBaseName(inputFasta));
// will enter sequence // will enter sequence
@ -480,9 +480,14 @@ void processCodon(string[] ARG_G, string ARG_R, string DirConsensus, string Path
string ARG_R_Base = getBaseName(ARG_R); string ARG_R_Base = getBaseName(ARG_R);
string ARG_R_Ref = buildPath(DirConsensus, ARG_R_Base ~ ".fasta"); string ARG_R_Ref = buildPath(DirConsensus, ARG_R_Base ~ ".fasta");
copy(ARG_R, ARG_R_Ref); copy(ARG_R, ARG_R_Ref);
splitFasta(ARG_R_Ref); splitFasta(ARG_R_Ref, DirConsensus);
if (!exists(DirConGene ~ "_bak")) {
moveDir(DirConGene, DirConGene ~ "_bak"); moveDir(DirConGene, DirConGene ~ "_bak");
}
if (!exists(DirConGene)) {
createDir(DirConGene);
}
writeln("GetCodon::Start"); writeln("GetCodon::Start");
@ -490,11 +495,12 @@ void processCodon(string[] ARG_G, string ARG_R, string DirConsensus, string Path
string inputFile = buildPath(DirConGene ~ "_bak", gene ~ ".fasta"); string inputFile = buildPath(DirConGene ~ "_bak", gene ~ ".fasta");
string outputFile = buildPath(DirConGene, gene ~ ".fasta"); string outputFile = buildPath(DirConGene, gene ~ ".fasta");
string referFile = buildPath(DirConsensus, gene ~ ".fasta"); string referFile = buildPath(DirConsensus, gene ~ ".fasta");
if (!exists(inputFile)) { if (!exists(inputFile)) {
writeln("File not found: ", inputFile); writeln("File not found: ", inputFile);
continue; continue;
} else { } 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); executeCommandToFile(cmdExonerate, outputFile);
} }
std.file.remove(referFile); std.file.remove(referFile);
@ -692,7 +698,7 @@ void main(string[] args) {
} }
// get gene from ARG_R reference fasta // 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); ARG_G = getARG_G(ARG_R);
} }