fix: delstop arg check

This commit is contained in:
kuoi 2024-09-10 02:25:16 +10:00
parent bc4526da33
commit f220da124e

View file

@ -139,27 +139,39 @@ void processFastaNT(string filePath, const FastaData fastaData) {
std.file.write(filePath, lines.join("\n")); std.file.write(filePath, lines.join("\n"));
} }
void processFasta(string fasta_aa, string fasta_nt){ void processFasta(string fasta_aa, string fasta_nt, string enableDelete){
// get pos from fasta_aa & modify // get pos from fasta_aa & modify
FastaData fastaData = processFastaAA(fasta_aa); FastaData fastaData = processFastaAA(fasta_aa);
if (fastaData.foundSpecialChar) { if (fastaData.foundSpecialChar) {
// if found special, proces fasta_nt backup(fasta_nt); // backup fasta_nt
// backup fasta_aa
backup(fasta_nt); // modify fasta_nt
processFastaNT(fasta_nt, fastaData); // modify fasta_nt processFastaNT(fasta_nt, fastaData); // modify fasta_nt
}
if (enableDelete == "--delete"){ // delete the nt's gap to meet the requirement of trimal
if(!fastaData.foundSpecialChar){
backup(fasta_nt);
}
string content = readText(fasta_nt);
content = replace(content, "-", "");
std.file.write(fasta_nt, content);
} }
} }
void main(string[] args) { void main(string[] args) {
if (args.length < 3) { if (args.length != 3 && args.length != 4) {
writeln("Usage: program <fasta_aa> <fasta_nt>"); writeln("\t\t\tDelete StopCondon generated by Macse\n\t\t\t\tAuthor: Guoyi Zhang\n\t\tUsage: " ~ args[0] ~ " <fasta_aa> <fasta_nt> --delete\n\t\tNote: fasta_aa and fasta_nt should be macse output files\n\t\t--delete should be used when downstream software is tirmal");
return; return;
} }
string fasta_aa = args[1]; string fasta_aa = args[1];
string fasta_nt = args[2]; string fasta_nt = args[2];
string enableDelete;
if(args.length>3){
enableDelete = args[3];
} else {
enableDelete = "";
}
processFasta(fasta_aa, fasta_nt); processFasta(fasta_aa, fasta_nt, enableDelete);
} }