Compare commits
5 commits
2968698cda
...
1697e38b97
Author | SHA1 | Date | |
---|---|---|---|
1697e38b97 | |||
c5928b62f0 | |||
516ce17d13 | |||
54bf6d9c72 | |||
7729c2e6ff |
1 changed files with 81 additions and 2 deletions
83
RGBEPP.d
83
RGBEPP.d
|
@ -175,6 +175,40 @@ void processQcTrim(string[] ARG_L, int ARG_T, string DirRaw, string DirQcTrim, s
|
|||
writeln("QcTrimming::End");
|
||||
}
|
||||
|
||||
void processMappingDenovo(string[] ARG_L, int ARG_T, string DirQcTrim, string DirAssembly, string DirMap, string PathBowtie2, string PathSamtools){
|
||||
// Prepare directory
|
||||
createDir(DirMap);
|
||||
createDir(DirMap ~ "/index");
|
||||
string DirAssemblySca = DirAssembly ~ "/" ~ "scaffolds";
|
||||
string DirAssemblyFas = DirAssembly ~ "/" ~ "fasta";
|
||||
createDir(DirAssemblySca);
|
||||
createDir(DirAssemblyFas);
|
||||
string ReferDmnd = DirAssemblySca ~ "/" ~ "Reference.dmnd";
|
||||
string PathBowtie2_build = PathBowtie2 ~ "-build";
|
||||
|
||||
foreach (string file; ARG_L) {
|
||||
string baseName = getBaseName(file);
|
||||
string inputM8 = DirAssemblySca ~ "/" ~ baseName ~ ".m8";
|
||||
string inputFasta = DirAssemblySca ~ "/" ~ baseName ~ ".fasta";
|
||||
string outputSort = DirAssemblyFas ~ "/" ~ baseName ~ ".fasta";
|
||||
string outputIndex = DirAssemblyFas ~ "/" ~ baseName;
|
||||
string inputFileR1 = DirQcTrim ~ "/" ~ baseName ~ "_R1.fastq.gz";
|
||||
string inputFileR2 = DirQcTrim ~ "/" ~ baseName ~ "_R2.fastq.gz";
|
||||
string outputBam = DirMap ~ "/" ~ baseName ~ ".bam";
|
||||
|
||||
string[] cmdDiamond = ["diamond", "blastx", "-d", "Reference.dmnd", "-q", inputFasta, "-o", inputM8, "--outfmt", "6", "qseqid", "sseqid", "pident", "length", "mismatch", "gapopen", "qstart", "qend", "sstart", "send", "evalue", "bitscore", "qlen", "slen", "gaps", "ppos", "qframe", "qseq"];
|
||||
string[] cmdSortDiamond = ["sortdiamond", inputM8, outputSort];
|
||||
string[] cmdBuildDB = [PathBowtie2_build, "--threads", ARG_T.to!string, outputSort, outputIndex];
|
||||
string[] cmdMap = [PathBowtie2, "-x", outputIndex, "-1", inputFileR1, "-2", inputFileR2, "-p", ARG_T.to!string];
|
||||
string[] cmdSam2Bam = [PathSamtools, "view", "-bS", "-@", ARG_T.to!string, "-o", outputBam];
|
||||
executeCommand(cmdDiamond);
|
||||
executeCommand(cmdSortDiamond);
|
||||
executeCommand(cmdBuildDB);
|
||||
executeCommandPipe([cmdMap, cmdSam2Bam]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void processMapping(string[] ARG_L, string ARG_R, int ARG_T, string DirQcTrim, string DirMap, string PathBowtie2, string PathSamtools) {
|
||||
writeln("Mapping::Start");
|
||||
|
||||
|
@ -232,6 +266,29 @@ void processPostMap(string[] ARG_L, int ARG_T, string DirMap, string DirBam, str
|
|||
writeln("PostMapping::End");
|
||||
}
|
||||
|
||||
void processVarCallDenovo(string[] ARG_L, int ARG_T, string DirAssembly, string DirMap, string DirBam, string DirVcf, string PathBcftools) {
|
||||
writeln("VarCalling::Start");
|
||||
|
||||
string DirAssemblyFas = DirAssembly ~ "/" ~ "fasta";
|
||||
createDir(DirVcf);
|
||||
|
||||
foreach (string file; parallel(ARG_L, 1)) {
|
||||
string baseName = getBaseName(file);
|
||||
string inputBam = DirBam ~ "/" ~ baseName ~ ".bam";
|
||||
string outputVcf = DirVcf ~ "/" ~ baseName ~ ".vcf.gz";
|
||||
string referFasta = DirAssemblyFas ~ "/" ~ baseName ~ ".fasta";
|
||||
// Variant calling using bcftools
|
||||
string[] cmdPileup = [PathBcftools, "mpileup", "-Oz", "--threads", ARG_T.to!string, "-f", referFasta, inputBam];
|
||||
string[] cmdVarCall = [PathBcftools, "call", "-mv", "-Oz", "--threads", ARG_T.to!string];
|
||||
string[] cmdNorm = [PathBcftools, "norm", "--threads", ARG_T.to!string, "-f", referFasta, "-Oz"];
|
||||
string[] cmdFilter = [PathBcftools, "filter", "--threads", ARG_T.to!string, "--IndelGap", "5", "-Oz", "-o", outputVcf];
|
||||
executeCommandPipe([cmdPileup, cmdVarCall, cmdNorm, cmdFilter]);
|
||||
}
|
||||
|
||||
writeln("VarCalling::End");
|
||||
|
||||
}
|
||||
|
||||
|
||||
void processVarCall(string[] ARG_L, string ARG_R, int ARG_T, string DirMap, string DirBam, string DirVcf, string PathBcftools) {
|
||||
writeln("VarCalling::Start");
|
||||
|
@ -258,6 +315,23 @@ void processVarCall(string[] ARG_L, string ARG_R, int ARG_T, string DirMap, stri
|
|||
|
||||
}
|
||||
|
||||
void processConSam(string[] ARG_L, string DirBam, string DirConsensus, string PathSamtools){
|
||||
writeln("Consensus::Start");
|
||||
|
||||
string DirConTaxa = DirConsensus ~ "/" ~ "taxa";
|
||||
createDir(DirConsensus);
|
||||
createDir(DirConTaxa);
|
||||
|
||||
foreach (string file; parallel(ARG_L,1)) {
|
||||
string baseName = getBaseName(file);
|
||||
string inputBam = DirBam ~ "/" ~ baseName ~ ".bam";
|
||||
string outputFasta = DirConTaxa ~ "/" ~ baseName ~ ".fasta";
|
||||
string [] cmdConsen1 = [PathSamtools, "consensus", "-f", "fasta", inputBam, "-o", outputFasta];
|
||||
executeCommand(cmdConsen1);
|
||||
}
|
||||
writeln("Consensus::End");
|
||||
}
|
||||
|
||||
void processCon(string[] ARG_G, string[] ARG_L, string ARG_R, int ARG_T, string DirMap, string DirVcf, string DirConsensus, string PathBcftools) {
|
||||
createDir(DirConsensus);
|
||||
|
||||
|
@ -423,6 +497,7 @@ void main(string[] args) {
|
|||
string DirBam = DirHome ~ "/03_bam";
|
||||
string DirVcf = DirHome ~ "/04_vcf";
|
||||
string DirConsensus = DirHome ~ "/05_consen";
|
||||
string DirConsensus1 = DirHome ~ "/05_consen1";
|
||||
string DirAlign = DirHome ~ "/06_macse";
|
||||
string DirTrim = DirHome ~ "/07_trimal";
|
||||
|
||||
|
@ -548,7 +623,8 @@ void main(string[] args) {
|
|||
|
||||
if (ARG_F == "all" || ARG_F == "map") {
|
||||
if(testFiles([PathBowtie2, PathSamtools])){
|
||||
processMapping(ARG_L, ARG_R, ARG_T, DirQcTrim, DirMap, PathBowtie2, PathSamtools);
|
||||
//processMapping(ARG_L, ARG_R, ARG_T, DirQcTrim, DirMap, PathBowtie2, PathSamtools);
|
||||
processMappingDenovo(ARG_L, ARG_T, DirQcTrim, DirAssembly, DirMap, PathBowtie2, PathSamtools);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -560,13 +636,16 @@ void main(string[] args) {
|
|||
|
||||
if (ARG_F == "all" || ARG_F == "varcall") {
|
||||
if(testFiles([PathBcftools])){
|
||||
processVarCall(ARG_L, ARG_R, ARG_T, DirMap, DirBam, DirVcf, PathBcftools);
|
||||
//processVarCall(ARG_L, ARG_R, ARG_T, DirMap, DirBam, DirVcf, PathBcftools);
|
||||
processVarCallDenovo(ARG_L, ARG_T, DirAssembly, DirMap, DirBam, DirVcf, PathBcftools);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (ARG_F == "all" || ARG_F == "consen") {
|
||||
if(testFiles([PathBcftools])){
|
||||
processCon(ARG_G, ARG_L, ARG_R, ARG_T, DirMap, DirVcf, DirConsensus, PathBcftools);
|
||||
//processConSam(ARG_L, DirBam, DirConsensus, PathSamtools);
|
||||
processCombFasta(ARG_G, ARG_L, DirConsensus);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue