diff --git a/delstop.d b/delstop.d index f0af3a0..8b18acc 100644 --- a/delstop.d +++ b/delstop.d @@ -139,27 +139,39 @@ void processFastaNT(string filePath, const FastaData fastaData) { 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 FastaData fastaData = processFastaAA(fasta_aa); if (fastaData.foundSpecialChar) { - // if found special, proces fasta_nt - // backup fasta_aa - backup(fasta_nt); // modify fasta_nt + backup(fasta_nt); // backup 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) { - if (args.length < 3) { - writeln("Usage: program "); + if (args.length != 3 && args.length != 4) { + writeln("\t\t\tDelete StopCondon generated by Macse\n\t\t\t\tAuthor: Guoyi Zhang\n\t\tUsage: " ~ args[0] ~ " --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; } - + string fasta_aa = args[1]; 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); }