From fea84b803aefb00b05386d802b5382d7d268f3be Mon Sep 17 00:00:00 2001 From: grenaud Date: Fri, 31 May 2024 13:06:00 +0200 Subject: [PATCH] added possibility of specifying file descriptors --- README.md | 8 ++ src/leeHom.cpp | 217 +++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 201 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 91cb150..807ba8b 100644 --- a/README.md +++ b/README.md @@ -145,3 +145,11 @@ src/leeHom -f AGATCGGAAGAGCACACGTCTGAACTCCAG -s GGAAGAGCGTCGTGTAGGGAAAGAGTGTAG - ``` The output files will have the `testData/outfq*` prefix. + +Alternatively, you can specify the names of all 6 files: + +```bash +src/leeHom -f AGATCGGAAGAGCACACGTCTGAACTCCAG -s GGAAGAGCGTCGTGTAGGGAAAGAGTGTAG --ancientdna -fq1 testData/rawAncientDNA.f1.gz -fq2 testData/rawAncientDNA.f2.gz -fqose testData/outfq.fq.gz -fqosef testData/outfq.fail.fq.gz -fqope1 testData/outfq_r1.fq.gz -fqope1f testData/outfq_r1.fail.fq.gz -fqope2 testData/outfq_r2.fq.gz -fqope2f testData/outfq_r2.fail.fq.gz +``` + + diff --git a/src/leeHom.cpp b/src/leeHom.cpp index f8feb3c..91a0858 100644 --- a/src/leeHom.cpp +++ b/src/leeHom.cpp @@ -1772,6 +1772,14 @@ int main (int argc, char *argv[]) { string fastqfile2 = ""; string fastqoutfile = ""; + bool fastqoutfileb=false; + string fastqoutfilese = ""; + string fastqoutfilesef = ""; + string fastqoutfilepe1 = ""; + string fastqoutfilepe1f = ""; + string fastqoutfilepe2 = ""; + string fastqoutfilepe2f = ""; + string intfastqoutfile = ""; bool singleEndModeFQ=true; @@ -1787,7 +1795,7 @@ int main (int argc, char *argv[]) { //int numberOfThreads = 1; - const string usage=string(string(argv[0])+ + const string usage1=string(string(argv[0])+ " [options] BAMfile"+"\n"+ "\nThis program takes an unaligned BAM where mates are consecutive\nor fastq files and trims and merges reads\n"+ @@ -1795,8 +1803,19 @@ int main (int argc, char *argv[]) { "\n\tYou can specify a unaligned bam file or one or two fastq :\n"+ "\t\t"+"-fq1 [file]" +"\t\t"+"First fastq file"+"\n"+ "\t\t"+"-fq2 [file]" +"\t\t"+"Second fastq file (for paired-end)"+"\n"+ - "\t\t"+"-fqo [file]" +"\t\t"+"Output fastq prefix to file"+"\n"+ - "\t\t"+"-fqt [file]" +"\t\t"+"Output interweaved fastq"+"\n\n"+ + "\t\t"+"-fqo [string]" +"\t\t"+"Output fastq prefix to file (type --help for more options)"+"\n"); + + const string usage2=string(string("or you can use specify manually those:\n")+ + "\t\t"+"-fqose [file]" +"\t\t"+"Output file for fastq single-end (or merged)"+"\n"+ + "\t\t"+"-fqosef [file]" +"\t\t"+"Output file for fastq single-end (or merged) that failed"+"\n"+ + "\t\t"+"-fqope1 [file]" +"\t\t"+"Output file for fastq first paired-end (or merged)"+"\n"+ + "\t\t"+"-fqope1f [file]" +"\t\t"+"Output file for fastq first paired-end (or merged) that failed"+"\n"+ + "\t\t"+"-fqope2 [file]" +"\t\t"+"Output file for fastq first paired-end (or merged)"+"\n"+ + "\t\t"+"-fqope2f [file]" +"\t\t"+"Output file for fastq first paired-end (or merged) that failed"+"\n"); + + + const string usage3=string(string("")+ + "\t\t"+"-fqt [file]" +"\t\t"+"Output interweaved fastq"+"\n\n"+ //"\t"+"-p , --PIPE"+"\n\t\t"+"Read BAM from and write it to PIPE"+"\n"+ "\t"+"-o , --outfile" +"\t\t"+"Output (BAM format)."+"\n"+ @@ -1845,12 +1864,19 @@ int main (int argc, char *argv[]) { "\t\t"+"--trimCutoff"+"\t\t\t\t"+"Lowest number of adapter bases to be observed for single Read trimming (default "+stringify(trimCutoff)+")"); if( (argc== 1) || - (argc== 2 && string(argv[1]) == "-h") || + (argc== 2 && string(argv[1]) == "-h") ){ + cout<<"Usage:"<1){ + cerr<<"If running in fastq input/output mode, cannot specify both -fqo and -fqt (or the name of the 6 fastq files)."<good()){ cerr<<"Cannot write to file "<good()){ cerr<<"Cannot write to file "<open(outdirs.c_str(), ios::out); - onereadgroup.singlef=onereadgroup.single; - - if(!onereadgroup.single->good()){ cerr<<"Cannot write to file "<open(outdirs.c_str(), ios::out); + onereadgroup.singlef->open(outdirsf.c_str(), ios::out); + + if(!onereadgroup.single->good()){ cerr<<"Cannot write to file "<good()){ cerr<<"Cannot write to file "<open(outdirs.c_str(), ios::out); + onereadgroup.singlef=onereadgroup.single; + + if(!onereadgroup.single->good()){ cerr<<"Cannot write to file "<good()){ cerr<<"Cannot write to file "<good()){ cerr<<"Cannot write to file "<good()){ cerr<<"Cannot write to file "<open(outdirs.c_str(), ios::out); + if(fastqoutfileb){ - onereadgroup.pairr1 =onereadgroup.single; - onereadgroup.pairr2 =onereadgroup.single; - onereadgroup.singlef=onereadgroup.single; - onereadgroup.pairr1f=onereadgroup.single; - onereadgroup.pairr2f=onereadgroup.single; + string outdirs = fastqoutfilese; + string outdir1 = fastqoutfilepe1; + string outdir2 = fastqoutfilepe2; + + string outdirsf = fastqoutfilesef; + string outdir1f = fastqoutfilepe1f; + string outdir2f = fastqoutfilepe2f; + + onereadgroup.single = new ogzstream(); + onereadgroup.pairr1 = new ogzstream(); + onereadgroup.pairr2 = new ogzstream(); + + onereadgroup.singlef = new ogzstream(); + onereadgroup.pairr1f = new ogzstream(); + onereadgroup.pairr2f = new ogzstream(); - if(!onereadgroup.single->good()){ cerr<<"Cannot write to file "<open(outdirs.c_str(), ios::out); + onereadgroup.pairr1->open(outdir1.c_str(), ios::out); + onereadgroup.pairr2->open(outdir2.c_str(), ios::out); + + onereadgroup.singlef->open(outdirsf.c_str(), ios::out); + onereadgroup.pairr1f->open(outdir1f.c_str(), ios::out); + onereadgroup.pairr2f->open(outdir2f.c_str(), ios::out); + + if(!onereadgroup.single->good()){ cerr<<"Cannot write to file "<good()){ cerr<<"Cannot write to file "<good()){ cerr<<"Cannot write to file "<good()){ cerr<<"Cannot write to file "<good()){ cerr<<"Cannot write to file "<good()){ cerr<<"Cannot write to file "<open(outdirs.c_str(), ios::out); + + onereadgroup.pairr1 =onereadgroup.single; + onereadgroup.pairr2 =onereadgroup.single; + onereadgroup.singlef=onereadgroup.single; + onereadgroup.pairr1f=onereadgroup.single; + onereadgroup.pairr2f=onereadgroup.single; + + if(!onereadgroup.single->good()){ cerr<<"Cannot write to file "<