Skip to content

Commit 0cdf5f0

Browse files
author
Your Name
committed
Updated helppage and made dfit more rebust with regards do parsing of parameters. This should close issue #50
1 parent bc206db commit 0cdf5f0

2 files changed

Lines changed: 17 additions & 23 deletions

File tree

dfit_helppage.cpp

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ int HelpPageSimple(FILE *fp){
1919

2020
fprintf(fp,"\n--help \t\t\t\t Print extended help page to see all options.\n\n");
2121

22-
fprintf(stderr, "./metaDMG-cpp dfit file.bdamage.gz --names file.gz --nodes trestructure.gz --lcastat fil.gz --bam file.bam --showfits int --nopt int --nbootstrap int --seed int --doCI int --CI float --lib <ds,ss> --out file\n");
22+
fprintf(stderr, "./metaDMG-cpp dfit file.bdamage.gz --names file.gz --nodes trestructure.gz --bam file.bam --showfits int --nopt int --nbootstrap int --seed int --doCI int --CI float --lib <ds,ss> --out file\n");
2323

2424
fprintf(fp,"\n------------ Required ------------- \n");
2525
fprintf(fp,"file.bdamage.gz contains the misincorporation matrix, in global mode from getdamage command either global or local mode or from lca command\n");
@@ -35,7 +35,7 @@ int HelpPageSimple(FILE *fp){
3535
fprintf(stderr, "\n---------- Examples ----------\n");
3636
fprintf(stderr, "\t Local mode binomial:\n \t\t ./metaDMG-cpp getdamage Pitch6.bam -l 10 -p 15 -r 1 -o Pitch6getDMG\n \t\t ./metaDMG-cpp dfit Pitch6getDMG.bdamage.gz --showfits 1\n");
3737
fprintf(stderr, "\t Global mode binomial:\n \t\t ./metaDMG-cpp getdamage Pitch6.bam -l 10 -p 15 -r 0 -o Pitch6getDMG\n \t\t ./metaDMG-cpp dfit Pitch6getDMG.bdamage.gz --nbootstrap 2 --showfits 2\n");
38-
fprintf(stderr, "\t Lca mode beta-binomial:\n \t\t ./metaDMG-cpp lca --names names.dmp --nodes nodes.dmp --acc2tax acc2taxid.map.gz --weight_type 1 --fix_ncbi 0 --bam Pitch6.bam --out Pitch6lcatest \n \t\t ./metaDMG-cpp dfit Pitch6lcatest.bdamage.gz --names names.dmp --nodes nodes.dmp --lcastat Pitch6lcatest.stat --showfits 0\n");
38+
fprintf(stderr, "\t Lca mode beta-binomial:\n \t\t ./metaDMG-cpp lca --names names.dmp --nodes nodes.dmp --acc2tax acc2taxid.map.gz --weight_type 1 --fix_ncbi 0 --bam Pitch6.bam --out Pitch6lcatest \n \t\t ./metaDMG-cpp dfit Pitch6lcatest.bdamage.gz --names names.dmp --nodes nodes.dmp --showfits 0\n");
3939

4040
exit(1);
4141
return 0;
@@ -52,7 +52,7 @@ int HelpPage(FILE *fp){
5252

5353
fprintf(fp,"\n--help \t\t\t\t Print extended help page to see all options.\n\n");
5454

55-
fprintf(stderr, "./metaDMG-cpp dfit file.bdamage.gz --names file.gz --nodes trestructure.gz --lcastat fil.gz --bam file.bam --showfits int --nopt int --nbootstrap int --seed int --doCI int --CI float --lib <ds,ss> --out file\n");
55+
fprintf(stderr, "./metaDMG-cpp dfit file.bdamage.gz --names file.gz --nodes trestructure.gz --bam file.bam --showfits int --nopt int --nbootstrap int --seed int --doCI int --CI float --lib <ds,ss> --out file\n");
5656

5757
fprintf(fp,"\n------------ Required ------------- \n");
5858
fprintf(fp,"./metaDMG-cpp dfit file.bdamage.gz \t bdamage file contains the misincorporation matrix, in global mode from getdamage command or local mode from lca command\n");
@@ -115,16 +115,3 @@ int HelpPage(FILE *fp){
115115
exit(1);
116116
return 0;
117117
}
118-
/*
119-
fprintf(stderr, "./metaDMG-cpp dfit file.bdamage.gz -names file.gz -nodes trestructure.gz -lcastat fil.gz -bam file.bam -showfits int -nopt int -nbootstrap int -seed int -doCI int -CI float -lib <ds,ss> -out file\n");
120-
fprintf(stderr, "Estimate damage patterns with beta-binomial model\n");
121-
fprintf(stderr, "\tEstimate damage patterns for each chr/scaffold contig (local mode), using lca stats\n");
122-
fprintf(stderr, "\t\t./metaDMG-cpp dfit file.bdamage.gz -names file.gz -nodes trestructure.gz -lcastat fil.gz -bam file.bam -showfits int -nopt int -nbootstrap int -seed int -doCI int -CI float -lib <ds,ss> -out file\n");
123-
fprintf(stderr, "\tEstimate one global damage pattern \n");
124-
fprintf(stderr, "\t\t./metaDMG-cpp dfit metaDMG-cpp/metaDMG-cpp dfit Pitch6getDMG.bdamage.gz -doboot 1 -nbootstrap 5 -nopt 10 -showfits 0\n");
125-
fprintf(stderr, "Estimate damage patterns with binomial model\n");
126-
fprintf(stderr, "\tEstimate damage patterns for each chr/scaffold contig (local mode), using lca stats\n");
127-
fprintf(stderr, "\t\t./metaDMG-cpp dfit file.bdamage.gz -names file.gz -nodes trestructure.gz -lcastat fil.gz -bam file.bam -showfits int -nopt int -nbootstrap int -seed int -doCI int -CI float -lib <ds,ss> -out file\n");
128-
fprintf(stderr, "\tEstimate one global damage pattern \n");
129-
fprintf(stderr, "\t\t./metaDMG-cpp dfit metaDMG-cpp/metaDMG-cpp dfit Pitch6getDMG.bdamage.gz -doboot 1 -nbootstrap 5 -nopt 10 -showfits 0\n");
130-
*/

main_dfit.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -640,14 +640,14 @@ void slave_block(std::map<int, mydataD> &retmap,int howmany,sam_hdr_t *hdr,int2c
640640

641641
int main_dfit(int argc, char **argv) {
642642
/*
643-
fprintf(stderr, "./metaDMG-cpp dfit file.bdamage.gz -names file.gz -nodes trestructure.gz -lcastat fil.gz -bam file.bam -showfits int -nopt int -nbootstrap int -seed int -doCI int -CI float -lib <ds,ss> -out file\n");
643+
fprintf(stderr, "./metaDMG-cpp dfit file.bdamage.gz -names file.gz -nodes trestructure.gz -bam file.bam -showfits int -nopt int -nbootstrap int -seed int -doCI int -CI float -lib <ds,ss> -out file\n");
644644
fprintf(stderr, "-------------\n Estimate damage patterns with beta-binomial model\n");
645645
fprintf(stderr, "\tEstimate damage patterns for each chr/scaffold contig (local mode), using lca stats\n");
646-
fprintf(stderr, "\t\t./metaDMG-cpp dfit file.bdamage.gz -names file.gz -nodes trestructure.gz -lcastat fil.gz -bam file.bam -showfits int -nopt int -nbootstrap int -seed int -doCI int -CI float -lib <ds,ss> -out file\n");
646+
fprintf(stderr, "\t\t./metaDMG-cpp dfit file.bdamage.gz -names file.gz -nodes trestructure.gz -bam file.bam -showfits int -nopt int -nbootstrap int -seed int -doCI int -CI float -lib <ds,ss> -out file\n");
647647
fprintf(stderr, "\tEstimate one global damage pattern \n");
648648
fprintf(stderr, "-------------\n Estimate damage patterns with binomial model\n");
649649
fprintf(stderr, "\tEstimate damage patterns for each chr/scaffold contig (local mode), using lca stats\n");
650-
fprintf(stderr, "\t\t./metaDMG-cpp dfit file.bdamage.gz -names file.gz -nodes trestructure.gz -lcastat fil.gz -bam file.bam -showfits int -nopt int -nbootstrap int -seed int -doCI int -CI float -lib <ds,ss> -out file\n");
650+
fprintf(stderr, "\t\t./metaDMG-cpp dfit file.bdamage.gz -names file.gz -nodes trestructure.gz -bam file.bam -showfits int -nopt int -nbootstrap int -seed int -doCI int -CI float -lib <ds,ss> -out file\n");
651651
fprintf(stderr, "\tEstimate one global damage pattern \n");
652652
fprintf(stderr, "\t\t./metaDMG-cpp dfit metaDMG-cpp/metaDMG-cpp dfit Pitch6getDMG.bdamage.gz -doboot 1 -nbootstrap 5 -nopt 10 -showfits 0\n");
653653
*/
@@ -705,10 +705,17 @@ int main_dfit(int argc, char **argv) {
705705
doCI = atoi(*(++argv));
706706
else if (strcasecmp("--lib", *argv) == 0)
707707
lib_prep = strdup(*(++argv));
708-
else if (strcasecmp("--threads", *argv) == 0)
709-
nthreads = atoi(*(++argv));
710-
else
711-
infile_bdamage = strdup(*argv);
708+
else if (strcasecmp("--threads", *argv) == 0)
709+
nthreads = atoi(*(++argv));
710+
else{
711+
if(infile_bdamage==NULL){
712+
infile_bdamage = strdup(*argv);
713+
fprintf(stderr,"\t-> infile_bdamage: %s\n",infile_bdamage);
714+
}else{
715+
fprintf(stderr,"\t-> Possible problem. Looks like multiple bdamage files has been defined: %s and %s\n",infile_bdamage,*argv);
716+
exit(1);
717+
}
718+
}
712719
}
713720
if(infile_nodes&&!infile_names){
714721
fprintf(stderr,"\t-> --names file.gz must be defined with --nodes is defined\n");

0 commit comments

Comments
 (0)