-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcommand_line_parsing.h
1015 lines (840 loc) · 40.6 KB
/
command_line_parsing.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifndef POPINS_CLP_H_
#define POPINS_CLP_H_
#include <string>
#include <seqan/arg_parse.h>
#include "popins_utils.h"
using namespace seqan;
// ==========================================================================
// struct <Command>Options
// ==========================================================================
struct AssemblyOptions {
CharString mappingFile;
CharString matepairFile;
CharString referenceFile;
CharString prefix;
CharString sampleID;
unsigned kmerLength;
CharString adapters;
int humanSeqs;
unsigned threads;
CharString memory;
AssemblyOptions () :
matepairFile(""), referenceFile(""), prefix("."), sampleID(""),
kmerLength(47), humanSeqs(maxValue<int>()), threads(1), memory("768M")
{}
};
struct MergingOptions {
CharString prefix;
CharString outputFile;
CharString skippedFile;
CharString contigsFileName;
std::fstream outputStream;
std::fstream skippedStream;
bool verbose;
double errorRate;
int minimalLength;
unsigned qgramLength;
int matchScore;
int errorPenalty;
int minScore;
int minTipScore;
double minEntropy;
MergingOptions() :
prefix("."), outputFile("supercontigs.fa"), skippedFile(""), contigsFileName("contigs.fa"), verbose(false),
errorRate(0.01), minimalLength(60), qgramLength(47), matchScore(1), errorPenalty(-5), minScore(90), minTipScore(30), minEntropy(0.75)
{}
};
struct ContigMapOptions {
CharString prefix;
CharString sampleID;
CharString contigFile;
CharString referenceFile;
bool bestAlignment;
int maxInsertSize;
bool deleteNonRefNew;
unsigned threads;
CharString memory;
ContigMapOptions() :
prefix("."), sampleID(""), contigFile("supercontigs.fa"), referenceFile("genome.fa"),
bestAlignment(false), maxInsertSize(800), deleteNonRefNew(false), threads(1), memory("768M")
{}
};
struct RefAlign_;
typedef Tag<RefAlign_> RefAlign;
struct SplitAlign_;
typedef Tag<SplitAlign_> SplitAlign;
struct SplitCombine_;
typedef Tag<SplitCombine_> SplitCombine;
template<typename TTag>
struct PlacingOptions {
CharString prefix;
CharString sampleID;
CharString outFile;
CharString locationsFile;
CharString groupsFile;
CharString supercontigFile;
CharString referenceFile;
double minLocScore;
unsigned minAnchorReads;
unsigned readLength;
unsigned maxInsertSize;
unsigned groupDist;
PlacingOptions() :
prefix("."), sampleID(""), outFile("insertions.vcf"), locationsFile("locations.txt"), groupsFile("groups.txt"),
supercontigFile("supercontigs.fa"), referenceFile("genome.fa"),
minLocScore(0.3), minAnchorReads(2), readLength(100), maxInsertSize(800), groupDist(100)
{}
};
struct GenotypingOptions {
CharString prefix;
CharString sampleID;
CharString referenceFile;
CharString supercontigFile;
CharString vcfFile;
CharString genotypingModel;
int regionWindowSize;
bool addReadGroup;
int maxInsertSize;
int bpQclip;
int minSeqLen;
double minReadProb;
int maxBARcount;
int match;
int mismatch;
int gapOpen;
int gapExtend;
int minAlignScore;
// hidden options
bool verbose;
bool callBoth;
bool useReadCounts;
bool fullOverlap;
GenotypingOptions() :
prefix("."), sampleID(""), referenceFile("genome.fa"), supercontigFile("supercontigs.fa"), vcfFile("insertions.vcf"),
genotypingModel("RANDOM"), regionWindowSize(50), addReadGroup(false),
maxInsertSize(500), bpQclip(0), minSeqLen(10), minReadProb(0.00001), maxBARcount(200),
match(1), mismatch(-2), gapOpen(-4), gapExtend(-1), minAlignScore(55),
verbose(false), callBoth(false), useReadCounts(false), fullOverlap(false)
{}
};
// ==========================================================================
// Function hideOptions()
// ==========================================================================
void
setHiddenOptions(ArgumentParser & parser, bool hide, AssemblyOptions &)
{
hideOption(parser, "matePair", hide);
hideOption(parser, "kmerLength", hide);
}
void
setHiddenOptions(ArgumentParser & parser, bool hide, MergingOptions &)
{
hideOption(parser, "e", hide);
hideOption(parser, "l", hide);
hideOption(parser, "k", hide);
hideOption(parser, "m", hide);
hideOption(parser, "mm", hide);
hideOption(parser, "a", hide);
hideOption(parser, "t", hide);
hideOption(parser, "v", hide);
hideOption(parser, "f", hide);
}
void
setHiddenOptions(ArgumentParser & parser, bool hide, ContigMapOptions &)
{
hideOption(parser, "b", hide);
hideOption(parser, "e", hide);
hideOption(parser, "d", hide);
}
void
setHiddenOptions(ArgumentParser & parser, bool hide, PlacingOptions<RefAlign> &)
{
hideOption(parser, "groupDist", hide);
}
void
setHiddenOptions(ArgumentParser & /*parser*/, bool /*hide*/, PlacingOptions<SplitAlign> &)
{
// Nothing to be done.
}
void
setHiddenOptions(ArgumentParser & /*parser*/, bool /*hide*/, PlacingOptions<SplitCombine> &)
{
// Nothing to be done.
}
void
setHiddenOptions(ArgumentParser & parser, bool hide, GenotypingOptions &)
{
hideOption(parser, "addReadGroup", hide);
hideOption(parser, "maxInsertSize", hide);
hideOption(parser, "qual", hide);
hideOption(parser, "minSeqLen", hide);
hideOption(parser, "minReadProb", hide);
hideOption(parser, "maxReadCount", hide);
hideOption(parser, "match", hide);
hideOption(parser, "mismatch", hide);
hideOption(parser, "gapOpen", hide);
hideOption(parser, "gapExtend", hide);
hideOption(parser, "minScore", hide);
}
// ==========================================================================
// Function setupParser()
// ==========================================================================
void
setupParser(ArgumentParser & parser, AssemblyOptions & options)
{
setShortDescription(parser, "Assembly of unmapped reads.");
setVersion(parser, VERSION);
setDate(parser, VERSION_DATE);
// Define usage line and long description.
addUsageLine(parser, "[\\fIOPTIONS\\fP] \\fIBAM_FILE\\fP");
addDescription(parser, "Finds reads without high-quality alignment in the \\fIBAM FILE\\fP, quality filters them "
"using SICKLE and assembles them into contigs using VELVET. If the option \'--reference \\fIFASTA FILE\\fP\' "
"is set, the reads are first remapped to this reference using BwA-MEM and only reads that remain without "
"high-quality alignment after remapping are quality-filtered and assembled.");
// Require a bam file as argument.
addArgument(parser, ArgParseArgument(ArgParseArgument::INPUT_FILE, "BAM_FILE"));
// Setup the options.
addSection(parser, "Input/output options");
addOption(parser, ArgParseOption("p", "prefix", "Path to the sample directories.", ArgParseArgument::STRING, "PATH"));
addOption(parser, ArgParseOption("s", "sample", "An ID for the sample.", ArgParseArgument::STRING, "SAMPLE_ID"));
addOption(parser, ArgParseOption("mp", "matePair", "", ArgParseArgument::INPUT_FILE, "BAM FILE"));
addSection(parser, "Algorithm options");
addOption(parser, ArgParseOption("a", "adapters", "Enable adapter removal for Illumina reads. Default: \\fIno adapter removal\\fP.", ArgParseArgument::STRING, "STR"));
addOption(parser, ArgParseOption("r", "reference", "Remap reads to this reference before assembly. Default: \\fIno remapping\\fP.", ArgParseArgument::INPUT_FILE, "FASTA_FILE"));
addOption(parser, ArgParseOption("f", "filter", "Treat reads aligned to all but the first INT reference sequences after remapping as high-quality aligned even if their alignment quality is low. "
"Recommended for non-human reference sequences.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("k", "kmerLength", "The k-mer size for velvet assembly.", ArgParseArgument::INTEGER, "INT"));
addSection(parser, "Compute resource options");
addOption(parser, ArgParseOption("t", "threads", "Number of threads to use for BWA and samtools sort.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("m", "memory", "Maximum memory per thread for samtools sort; suffix K/M/G recognized.", ArgParseArgument::STRING, "STR"));
// Set valid and default values.
setValidValues(parser, "adapters", "HiSeq HiSeqX");
setValidValues(parser, "reference", "fa fna fasta gz");
setMinValue(parser, "threads", "1");
setDefaultValue(parser, "prefix", "\'.\'");
setDefaultValue(parser, "sample", "retrieval from BAM file header");
setDefaultValue(parser, "kmerLength", options.kmerLength);
setDefaultValue(parser, "threads", options.threads);
setDefaultValue(parser, "memory", options.memory);
// Hide some options from default help.
setHiddenOptions(parser, true, options);
}
void
setupParser(ArgumentParser & parser, MergingOptions & options)
{
setShortDescription(parser, "Merging of insertion contigs into supercontigs.");
setVersion(parser, VERSION);
setDate(parser, VERSION_DATE);
// Define usage line and long description.
addUsageLine(parser, "[\\fIOPTIONS\\fP]");
addDescription(parser, "Merges the contigs in \'<prefix>/*/contigs.fa\' into a single set of supercontigs. The "
"input contigs are first partitioned into sets of similar sequences using the SWIFT filtering algorithm, "
"and then each set of sequences is aligned into a graph of supercontigs.");
// Setup the options.
addSection(parser, "Input/output options");
addOption(parser, ArgParseOption("p", "prefix", "Path to the sample directories.", ArgParseArgument::STRING, "PATH"));
addOption(parser, ArgParseOption("f", "contigsFileName", "Name of the contig files to look for.", ArgParseArgument::STRING, "FASTA_FILE"));
addOption(parser, ArgParseOption("c", "contigs", "Name of supercontigs output file.", ArgParseArgument::OUTPUT_FILE, "FASTA_FILE"));
addOption(parser, ArgParseOption("s", "skipped", "Write skipped contigs to a file. Default: \\fIdo not write skipped contigs\\fP", ArgParseArgument::OUTPUT_FILE, "FASTA_FILE"));
addOption(parser, ArgParseOption("v", "verbose", "Enable verbose output of components."));
addSection(parser, "Algorithm options");
addOption(parser, ArgParseOption("y", "minEntropy", "Ignore low-complexity contigs with entropy below FLOAT. Use 0 to disable.", ArgParseArgument::DOUBLE, "FLOAT"));
addOption(parser, ArgParseOption("e", "errRate", "Maximal error rate for SWIFT filtering.", ArgParseArgument::DOUBLE, "FLOAT"));
addOption(parser, ArgParseOption("l", "minLength", "Minimal length for SWIFT filtering.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("k", "kmerLength", "Length of k-mers for SWIFT filtering.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("m", "match", "Match score for Smith-Waterman alignment.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("mm", "penalty", "Error penalty for Smith-Waterman alignment.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("a", "minScore", "Minimal score for Smith-Waterman alignment.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("t", "minTipScore", "Minimal score for tips in supercontig graph.", ArgParseArgument::INTEGER, "INT"));
// Set valid values.
setValidValues(parser, "c", "fa fna fasta");
setValidValues(parser, "s", "fa fna fasta");
setMinValue(parser, "y", "0");
setMaxValue(parser, "y", "1");
setMinValue(parser, "e", "0");
setMaxValue(parser, "e", "0.25");
setMinValue(parser, "l", "3");
setMinValue(parser, "k", "3");
setMinValue(parser, "t", "0");
// Set default values.
setDefaultValue(parser, "prefix", "\'.\'");
setDefaultValue(parser, "c", options.outputFile);
setDefaultValue(parser, "f", options.contigsFileName);
setDefaultValue(parser, "y", options.minEntropy);
setDefaultValue(parser, "e", options.errorRate);
setDefaultValue(parser, "l", options.minimalLength);
setDefaultValue(parser, "k", options.qgramLength);
setDefaultValue(parser, "m", options.matchScore);
setDefaultValue(parser, "mm", options.errorPenalty);
setDefaultValue(parser, "a", options.minScore);
setDefaultValue(parser, "t", options.minTipScore);
// Hide some options from default help.
setHiddenOptions(parser, true, options);
}
void
setupParser(ArgumentParser & parser, ContigMapOptions & options)
{
setShortDescription(parser, "Alignment of unmapped reads to assembled contigs.");
setVersion(parser, VERSION);
setDate(parser, VERSION_DATE);
// Define usage line and long description.
addUsageLine(parser, "[\\fIOPTIONS\\fP] \\fISAMPLE_ID\\fP");
addDescription(parser, "Aligns the reads with low-quality alignments of a sample to the set of supercontigs using "
"BWA-MEM. Merges the BWA output file with the sample's non_ref.bam file into a non_ref_new.bam file where "
"information about read mates is set.");
addArgument(parser, ArgParseArgument(ArgParseArgument::STRING, "SAMPLE_ID"));
// Setup the options.
addSection(parser, "Input/output options");
addOption(parser, ArgParseOption("p", "prefix", "Path to the sample directories.", ArgParseArgument::STRING, "PATH"));
addOption(parser, ArgParseOption("c", "contigs", "Name of (super-)contigs file.", ArgParseArgument::INPUT_FILE, "FASTA_FILE"));
addOption(parser, ArgParseOption("r", "reference", "Name of reference genome file.", ArgParseArgument::INPUT_FILE, "FASTA_FILE"));
addSection(parser, "Algorithm options");
addOption(parser, ArgParseOption("b", "best", "Do not use BWA-mem's -a option to output all alignments of a read."));
addOption(parser, ArgParseOption("e", "maxInsertSize", "The maximum expected insert size of the read pairs.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("d", "noNonRefNew", "Delete the non_ref_new.bam file after writing locations."));
addSection(parser, "Compute resource options");
addOption(parser, ArgParseOption("t", "threads", "Number of threads to use for BWA and samtools sort.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("m", "memory", "Maximum memory per thread for samtools sort; suffix K/M/G recognized.", ArgParseArgument::STRING, "STR"));
// Set valid values.
setMinValue(parser, "threads", "1");
setValidValues(parser, "reference", "fa fna fasta");
setValidValues(parser, "contigs", "fa fna fasta");
// Set default values.
setDefaultValue(parser, "prefix", "\'.\'");
setDefaultValue(parser, "contigs", options.contigFile);
setDefaultValue(parser, "reference", options.referenceFile);
setDefaultValue(parser, "best", "false");
setDefaultValue(parser, "maxInsertSize", options.maxInsertSize);
setDefaultValue(parser, "noNonRefNew", "false");
setDefaultValue(parser, "threads", options.threads);
setDefaultValue(parser, "memory", options.memory);
// Hide some options from default help.
setHiddenOptions(parser, true, options);
}
void
setupParser(ArgumentParser & parser, PlacingOptions<RefAlign> & options)
{
setShortDescription(parser, "Contig placing by alignment of contig ends to reference genome.");
setVersion(parser, VERSION);
setDate(parser, VERSION_DATE);
addUsageLine(parser, "[\\fIOPTIONS\\fP]");
addDescription(parser, "This is step 1/3 of contig placing. The contig locations in the sample directories are "
"merged into one file of locations. Next, prefixes/suffixes of contigs are aligned to the merged locations "
"on the reference genome and VCF records are written if the alignment is successful. Locations of contigs "
"that do not align to the reference genome are written to additional output files \\fIlocations_unplaced.txt\\fP "
"in the sample directories. Further, groups of contigs that can be placed at the same position and whose "
"prefixes/suffixes align to each other are written to another output file; only a single VCF record is "
"written per group.");
// Setup the options.
addSection(parser, "Input/output options");
addOption(parser, ArgParseOption("p", "prefix", "Path to the sample directories.", ArgParseArgument::STRING, "PATH"));
addOption(parser, ArgParseOption("l", "locations", "Name of merged locations file.", ArgParseArgument::OUTPUT_FILE, "FILE"));
addOption(parser, ArgParseOption("i", "insertions", "Name of VCF output file.", ArgParseArgument::OUTPUT_FILE, "VCF_FILE"));
addOption(parser, ArgParseOption("c", "contigs", "Name of supercontigs file.", ArgParseArgument::INPUT_FILE, "FASTA_FILE"));
addOption(parser, ArgParseOption("r", "reference", "Name of reference genome file.", ArgParseArgument::INPUT_FILE, "FASTA_FILE"));
addOption(parser, ArgParseOption("g", "groups", "Name of file containing groups of contigs that can be placed at the same position and whose prefixes/suffixes align.", ArgParseArgument::OUTPUT_FILE, "FILE"));
addSection(parser, "Algorithm options");
addOption(parser, ArgParseOption("", "minScore", "Minimal anchoring score for a location.", ArgParseArgument::DOUBLE, "FLOAT"));
addOption(parser, ArgParseOption("", "minReads", "Minimal number of anchoring read pairs for a location.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("", "maxInsertSize", "The maximum expected insert size of the read pairs.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("", "readLength", "The length of the reads.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("", "groupDist", "Minimal distance between groups of locations.", ArgParseArgument::INTEGER, "INT"));
// Set valid values.
setMinValue(parser, "minScore", "0");
setMaxValue(parser, "minScore", "1");
setValidValues(parser, "contigs", "fa fna fasta");
setValidValues(parser, "reference", "fa fna fasta");
setValidValues(parser, "insertions", "vcf");
// Set default values.
setDefaultValue(parser, "prefix", "\'.\'");
setDefaultValue(parser, "locations", options.locationsFile);
setDefaultValue(parser, "insertions", options.outFile);
setDefaultValue(parser, "contigs", options.supercontigFile);
setDefaultValue(parser, "reference", options.referenceFile);
setDefaultValue(parser, "groups", options.groupsFile);
setDefaultValue(parser, "minScore", options.minLocScore);
setDefaultValue(parser, "minReads", options.minAnchorReads);
setDefaultValue(parser, "groupDist", options.groupDist);
setDefaultValue(parser, "readLength", options.readLength);
setDefaultValue(parser, "maxInsertSize", options.maxInsertSize);
// Hide some options from default help.
setHiddenOptions(parser, true, options);
}
void
setupParser(ArgumentParser & parser, PlacingOptions<SplitAlign> & options)
{
setShortDescription(parser, "Contig placing by split-read alignment.");
setVersion(parser, VERSION);
setDate(parser, VERSION_DATE);
addUsageLine(parser, "[\\fIOPTIONS\\fP] \\fISAMPLE_ID\\fP");
addDescription(parser, "This is step 2/3 of contig placing. All locations in a sample's "
"\\fIlocations_unplaced.txt\\fP are split-read aligned and the results are written to a file "
"\\fIlocations_placed.txt\\fP in the sample directory.");
addArgument(parser, ArgParseArgument(ArgParseArgument::STRING, "SAMPLE_ID"));
// Setup the options.
addSection(parser, "Input/output options");
addOption(parser, ArgParseOption("p", "prefix", "Path to the sample directories.", ArgParseArgument::STRING, "PATH"));
addOption(parser, ArgParseOption("c", "contigs", "Name of supercontigs file.", ArgParseArgument::INPUT_FILE, "FASTA_FILE"));
addOption(parser, ArgParseOption("r", "reference", "Name of reference genome file.", ArgParseArgument::INPUT_FILE, "FASTA_FILE"));
addSection(parser, "Algorithm options");
addOption(parser, ArgParseOption("", "maxInsertSize", "The maximum expected insert size of the read pairs.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("", "readLength", "The length of the reads.", ArgParseArgument::INTEGER, "INT"));
// Set valid values.
setValidValues(parser, "contigs", "fa fna fasta");
setValidValues(parser, "reference", "fa fna fasta");
// Set default values.
setDefaultValue(parser, "prefix", "\'.\'");
setDefaultValue(parser, "contigs", options.supercontigFile);
setDefaultValue(parser, "reference", options.referenceFile);
setDefaultValue(parser, "readLength", options.readLength);
setDefaultValue(parser, "maxInsertSize", options.maxInsertSize);
// Hide some options from default help.
setHiddenOptions(parser, true, options);
}
void
setupParser(ArgumentParser & parser, PlacingOptions<SplitCombine> & options)
{
setShortDescription(parser, "Combining breakpoint positions from split-read alignment.");
setVersion(parser, VERSION);
setDate(parser, VERSION_DATE);
addUsageLine(parser, "[\\fIOPTIONS\\fP]");
addDescription(parser, "This is step 3/3 of contig placing. The results from split-read alignment (the "
"\\fIlocations_placed.txt\\fP files) of all samples are combined and appended to the VCF output file.");
// Setup the options.
addSection(parser, "Input/output options");
addOption(parser, ArgParseOption("p", "prefix", "Path to the sample directories.", ArgParseArgument::STRING, "PATH"));
addOption(parser, ArgParseOption("i", "insertions", "Name of VCF output file.", ArgParseArgument::OUTPUT_FILE, "VCF_FILE"));
addOption(parser, ArgParseOption("r", "reference", "Name of reference genome file.", ArgParseArgument::INPUT_FILE, "FASTA_FILE"));
// Set valid values.
setValidValues(parser, "reference", "fa fna fasta");
setValidValues(parser, "insertions", "vcf");
// Set default values.
setDefaultValue(parser, "prefix", "\'.\'");
setDefaultValue(parser, "insertions", options.outFile);
setDefaultValue(parser, "reference", options.referenceFile);
// Hide some options from default help.
setHiddenOptions(parser, true, options);
}
void
setupParser(ArgumentParser & parser, GenotypingOptions & options)
{
setShortDescription(parser, "Genotyping a sample for insertions.");
setVersion(parser, VERSION);
setDate(parser, VERSION_DATE);
addUsageLine(parser, "[\\fIOPTIONS\\fP] \\fISAMPLE_ID\\fP");
addDescription(parser, "Computes genotype likelihoods for a sample for all insertions given in the input VCF file "
"by aligning all reads, which are mapped to the reference genome around the insertion breakpoint or to the "
"contig, to the reference and to the alternative insertion sequence. VCF records with the genotype "
"likelihoods in GT:PL format for the individual are written to a file \\fIinsertions.vcf\\fP in the sample "
"directory.");
addArgument(parser, ArgParseArgument(ArgParseArgument::STRING, "SAMPLE_ID"));
// Setup the options.
addSection(parser, "Input/output options");
addOption(parser, ArgParseOption("p", "prefix", "Path to the sample directories.", ArgParseArgument::STRING, "PATH"));
addOption(parser, ArgParseOption("i", "insertions", "Name of VCF input file.", ArgParseArgument::INPUT_FILE, "VCF_FILE"));
addOption(parser, ArgParseOption("c", "contigs", "Name of supercontigs file.", ArgParseArgument::INPUT_FILE, "FASTA_FILE"));
addOption(parser, ArgParseOption("r", "reference", "Name of reference genome file.", ArgParseArgument::INPUT_FILE, "FASTA_FILE"));
addSection(parser, "Algorithm options");
addOption(parser, ArgParseOption("m", "model", "Model used for genotyping.", ArgParseArgument::STRING, "GENOTYPING_MODEL"));
addOption(parser, ArgParseOption("w", "window", "Region window size.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("rg", "addReadGroup", "Add read group."));
addSection(parser, "Read(-pair) options");
addOption(parser, ArgParseOption("", "maxInsertSize", "Maximum read pair insert size.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("", "qual", "Quality score threshold for read trimming.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("", "minSeqLen", "Minimum read length after trimming.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("", "minReadProb", "Minimum read probability.", ArgParseArgument::DOUBLE, "DOUBLE"));
addOption(parser, ArgParseOption("", "maxReadCount", "Maximum number of reads to consider in region window.", ArgParseArgument::INTEGER, "INT"));
addSection(parser, "Alignment options");
addOption(parser, ArgParseOption("", "match", "Cost of match.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("", "mismatch", "Cost of mismatch.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("", "gapOpen", "Cost of gap open.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("", "gapExtend", "Cost of gap extend.", ArgParseArgument::INTEGER, "INT"));
addOption(parser, ArgParseOption("", "minScore", "Minimum alignment score.", ArgParseArgument::INTEGER, "INT"));
// Misc hidden options.
addOption(parser, ArgParseOption("v", "verbose", "Enable verbose output."));
hideOption(parser, "verbose", true);
addOption(parser, ArgParseOption("", "callBoth", "Call both models."));
hideOption(parser, "callBoth", true);
addOption(parser, ArgParseOption("", "readCounts", "Use read counts."));
hideOption(parser, "readCounts", true);
addOption(parser, ArgParseOption("", "fullOverlap", "Full overlap of read."));
hideOption(parser, "fullOverlap", true);
// Set valid values.
setValidValues(parser, "contigs", "fa fna fasta");
setValidValues(parser, "reference", "fa fna fasta");
setValidValues(parser, "insertions", "vcf");
setValidValues(parser, "model", "DUP RANDOM");
// Set default values.
setDefaultValue(parser, "prefix", "\'.\'");
setDefaultValue(parser, "insertions", options.vcfFile);
setDefaultValue(parser, "contigs", options.supercontigFile);
setDefaultValue(parser, "reference", options.referenceFile);
setDefaultValue(parser, "model", options.genotypingModel);
setDefaultValue(parser, "window", options.regionWindowSize);
setDefaultValue(parser, "maxInsertSize", options.maxInsertSize);
setDefaultValue(parser, "qual", options.bpQclip);
setDefaultValue(parser, "minReadProb", options.minReadProb);
setDefaultValue(parser, "maxReadCount", options.maxBARcount);
setDefaultValue(parser, "match", options.match);
setDefaultValue(parser, "mismatch", options.mismatch);
setDefaultValue(parser, "gapOpen", options.gapOpen);
setDefaultValue(parser, "gapExtend", options.gapExtend);
setDefaultValue(parser, "minScore", options.minAlignScore);
// Hide some options from default help.
setHiddenOptions(parser, true, options);
}
// ==========================================================================
// Function getOptionValues()
// ==========================================================================
void
getOptionValues(AssemblyOptions & options, ArgumentParser const & parser)
{
getArgumentValue(options.mappingFile, parser, 0);
if (isSet(parser, "prefix"))
getOptionValue(options.prefix, parser, "prefix");
if (isSet(parser, "sample"))
getOptionValue(options.sampleID, parser, "sample");
if (isSet(parser, "matePair"))
getOptionValue(options.matepairFile, parser, "matePair");
if (isSet(parser, "adapters"))
getOptionValue(options.adapters, parser, "adapters");
if (isSet(parser, "reference"))
getOptionValue(options.referenceFile, parser, "reference");
if (isSet(parser, "filter"))
getOptionValue(options.humanSeqs, parser, "filter");
if (isSet(parser, "kmerLength"))
getOptionValue(options.kmerLength, parser, "kmerLength");
if (isSet(parser, "threads"))
getOptionValue(options.threads, parser, "threads");
if (isSet(parser, "memory"))
getOptionValue(options.memory, parser, "memory");
}
void
getOptionValues(MergingOptions & options, ArgumentParser & parser)
{
if (isSet(parser, "prefix"))
getOptionValue(options.prefix, parser, "prefix");
if (isSet(parser, "contigs"))
getOptionValue(options.outputFile, parser, "contigs");
if (isSet(parser, "contigsFileName"))
getOptionValue(options.contigsFileName, parser, "contigsFileName");
if (isSet(parser, "skipped"))
getOptionValue(options.skippedFile, parser, "skipped");
if (isSet(parser, "verbose"))
options.verbose = true;
if (isSet(parser, "minEntropy"))
getOptionValue(options.minEntropy, parser, "minEntropy");
if (isSet(parser, "errRate"))
getOptionValue(options.errorRate, parser, "errRate");
if (isSet(parser, "minLength"))
getOptionValue(options.minimalLength, parser, "minLength");
if (isSet(parser, "kmerLength"))
getOptionValue(options.qgramLength, parser, "kmerLength");
if (isSet(parser, "match"))
getOptionValue(options.matchScore, parser, "match");
if (isSet(parser, "minScore"))
getOptionValue(options.minScore, parser, "minScore");
if (isSet(parser, "penalty"))
getOptionValue(options.errorPenalty, parser, "penalty");
if (isSet(parser, "minTipScore"))
getOptionValue(options.minTipScore, parser, "minTipScore");
}
void
getOptionValues(ContigMapOptions & options, ArgumentParser & parser)
{
getArgumentValue(options.sampleID, parser, 0);
if (isSet(parser, "prefix"))
getOptionValue(options.prefix, parser, "prefix");
if (isSet(parser, "contigs"))
getOptionValue(options.contigFile, parser, "contigs");
if (isSet(parser, "reference"))
getOptionValue(options.referenceFile, parser, "reference");
if (isSet(parser, "best"))
options.bestAlignment = true;
if (isSet(parser, "maxInsertSize"))
getOptionValue(options.maxInsertSize, parser, "maxInsertSize");
if (isSet(parser, "noNonRefNew"))
options.deleteNonRefNew = true;
if (isSet(parser, "threads"))
getOptionValue(options.threads, parser, "threads");
if (isSet(parser, "memory"))
getOptionValue(options.memory, parser, "memory");
}
void
getOptionValues(PlacingOptions<RefAlign> & options, ArgumentParser & parser)
{
if (isSet(parser, "prefix"))
getOptionValue(options.prefix, parser, "prefix");
if (isSet(parser, "locations"))
getOptionValue(options.locationsFile, parser, "locations");
if (isSet(parser, "contigs"))
getOptionValue(options.supercontigFile, parser, "contigs");
if (isSet(parser, "insertions"))
getOptionValue(options.outFile, parser, "insertions");
if (isSet(parser, "reference"))
getOptionValue(options.referenceFile, parser, "reference");
if (isSet(parser, "groups"))
getOptionValue(options.groupsFile, parser, "groups");
if (isSet(parser, "maxInsertSize"))
getOptionValue(options.maxInsertSize, parser, "maxInsertSize");
if (isSet(parser, "readLength"))
getOptionValue(options.readLength, parser, "readLength");
if (isSet(parser, "minScore"))
getOptionValue(options.minLocScore, parser, "minScore");
if (isSet(parser, "minReads"))
getOptionValue(options.minAnchorReads, parser, "minReads");
if (isSet(parser, "groupDist"))
getOptionValue(options.groupDist, parser, "groupDist");
}
void
getOptionValues(PlacingOptions<SplitAlign> & options, ArgumentParser & parser)
{
getArgumentValue(options.sampleID, parser, 0);
if (isSet(parser, "prefix"))
getOptionValue(options.prefix, parser, "prefix");
if (isSet(parser, "contigs"))
getOptionValue(options.supercontigFile, parser, "contigs");
if (isSet(parser, "reference"))
getOptionValue(options.referenceFile, parser, "reference");
if (isSet(parser, "maxInsertSize"))
getOptionValue(options.maxInsertSize, parser, "maxInsertSize");
if (isSet(parser, "readLength"))
getOptionValue(options.readLength, parser, "readLength");
}
void
getOptionValues(PlacingOptions<SplitCombine> & options, ArgumentParser & parser)
{
if (isSet(parser, "prefix"))
getOptionValue(options.prefix, parser, "prefix");
if (isSet(parser, "insertions"))
getOptionValue(options.outFile, parser, "insertions");
if (isSet(parser, "reference"))
getOptionValue(options.referenceFile, parser, "reference");
}
void
getOptionValues(GenotypingOptions & options, ArgumentParser & parser)
{
getArgumentValue(options.sampleID, parser, 0);
if (isSet(parser, "prefix"))
getOptionValue(options.prefix, parser, "prefix");
if (isSet(parser, "contigs"))
getOptionValue(options.supercontigFile, parser, "contigs");
if (isSet(parser, "insertions"))
getOptionValue(options.vcfFile, parser, "insertions");
if (isSet(parser, "reference"))
getOptionValue(options.referenceFile, parser, "reference");
if (isSet(parser, "model"))
getOptionValue(options.genotypingModel, parser, "model");
if(isSet(parser, "window"))
getOptionValue( options.regionWindowSize, parser, "window");
options.addReadGroup = isSet(parser, "addReadGroup");
if (isSet(parser, "match"))
getOptionValue(options.match, parser, "match");
if (isSet(parser, "mismatch"))
getOptionValue(options.mismatch, parser, "mismatch");
if (isSet(parser, "gapOpen"))
getOptionValue(options.gapOpen, parser, "gapOpen");
if (isSet(parser, "gapExtend"))
getOptionValue(options.gapExtend, parser, "gapExtend");
if (isSet(parser, "minScore"))
getOptionValue(options.minAlignScore, parser, "minScore");
if (isSet(parser, "maxInsertSize"))
getOptionValue(options.maxInsertSize, parser, "maxInsertSize");
if (isSet(parser, "minReadProb"))
getOptionValue(options.minReadProb, parser, "minReadProb");
if (isSet(parser, "maxReadCount"))
getOptionValue(options.maxBARcount, parser, "maxReadCount");
if (isSet(parser, "qual"))
getOptionValue(options.bpQclip, parser, "qual");
if (isSet(parser, "minSeqLen"))
getOptionValue(options.minSeqLen, parser, "minSeqLen");
options.verbose = isSet(parser, "verbose");
options.callBoth = isSet(parser, "callBoth");
options.fullOverlap = isSet(parser, "fullOverlap");
options.useReadCounts = isSet(parser, "readCounts");
}
ArgumentParser::ParseResult
checkInput(AssemblyOptions & options)
{
ArgumentParser::ParseResult res = ArgumentParser::PARSE_OK;
if (options.prefix != "." && !exists(options.prefix))
{
std::cerr << "ERROR: Path to sample direcotories \'" << options.prefix << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
if (!exists(options.mappingFile))
{
std::cerr << "ERROR: Input BAM file \'" << options.mappingFile << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
CharString baiFile = options.mappingFile;
baiFile += ".bai";
if (!exists(baiFile))
{
std::cerr << "ERROR: BAM index file \'" << baiFile << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
if (options.matepairFile != "" && !exists(options.matepairFile))
{
std::cerr << "ERROR: Input BAM file \'" << options.matepairFile << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
return res;
}
ArgumentParser::ParseResult
checkInput(MergingOptions & options)
{
ArgumentParser::ParseResult res = ArgumentParser::PARSE_OK;
if (options.prefix != "." && !exists(options.prefix))
{
std::cerr << "ERROR: Path to sample direcotories \'" << options.prefix << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
if (options.contigsFileName == "")
{
std::cerr << "ERROR: Name of contig files \'" << options.contigsFileName << "\' should not be empty." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
return res;
}
ArgumentParser::ParseResult
checkInput(ContigMapOptions & options)
{
ArgumentParser::ParseResult res = ArgumentParser::PARSE_OK;
if (options.prefix != "." && !exists(options.prefix))
{
std::cerr << "ERROR: Path to sample direcotories \'" << options.prefix << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
if (!exists(options.contigFile))
{
std::cerr << "ERROR: Contig file \'" << options.contigFile << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
if (!exists(options.referenceFile))
{
std::cerr << "ERROR: Reference genome file \'" << options.referenceFile << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
return res;
}
ArgumentParser::ParseResult
checkInput(PlacingOptions<RefAlign> & options)
{
ArgumentParser::ParseResult res = ArgumentParser::PARSE_OK;
if (options.prefix != "." && !exists(options.prefix))
{
std::cerr << "ERROR: Path to sample direcotories \'" << options.prefix << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
if (!exists(options.supercontigFile))
{
std::cerr << "ERROR: Contig file \'" << options.supercontigFile << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
if (!exists(options.referenceFile))
{
std::cerr << "ERROR: Reference genome file \'" << options.referenceFile << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
return res;
}
ArgumentParser::ParseResult
checkInput(PlacingOptions<SplitAlign> & options)
{
ArgumentParser::ParseResult res = ArgumentParser::PARSE_OK;
if (options.prefix != "." && !exists(options.prefix))
{
std::cerr << "ERROR: Path to sample direcotories \'" << options.prefix << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
if (!exists(options.supercontigFile))
{
std::cerr << "ERROR: Contig file \'" << options.supercontigFile << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
if (!exists(options.referenceFile))
{
std::cerr << "ERROR: Reference genome file \'" << options.referenceFile << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
return res;
}
ArgumentParser::ParseResult
checkInput(PlacingOptions<SplitCombine> & options)
{
ArgumentParser::ParseResult res = ArgumentParser::PARSE_OK;
if (options.prefix != "." && !exists(options.prefix))
{
std::cerr << "ERROR: Path to sample direcotories \'" << options.prefix << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
if (!exists(options.referenceFile))
{
std::cerr << "ERROR: Reference genome file \'" << options.referenceFile << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
return res;
}
ArgumentParser::ParseResult
checkInput(GenotypingOptions & options)
{
ArgumentParser::ParseResult res = ArgumentParser::PARSE_OK;
if (options.prefix != "." && !exists(options.prefix))
{
std::cerr << "ERROR: Path to sample direcotories \'" << options.prefix << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
if (!exists(options.vcfFile))
{
std::cerr << "ERROR: Input VCF file \'" << options.vcfFile << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
if (!exists(options.supercontigFile))
{
std::cerr << "ERROR: Contig file \'" << options.supercontigFile << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
if (!exists(options.referenceFile))
{
std::cerr << "ERROR: Reference genome file \'" << options.referenceFile << "\' does not exist." << std::endl;
res = ArgumentParser::PARSE_ERROR;
}
return res;
}
// ==========================================================================
// Function parseCommandLine()
// ==========================================================================
template<typename TOptions>
ArgumentParser::ParseResult
parseCommandLine(TOptions & options, int argc, char const ** argv)
{
// Concatenate program name from name and command.
CharString prog_name = argv[0];
prog_name += " ";
prog_name += argv[1];
++argv;
--argc;
// Setup the parser.
ArgumentParser parser(toCString(prog_name));
addOption(parser, ArgParseOption("H", "fullHelp", "Display the help message with the full list of options."));
setupParser(parser, options);
// Parse the command line.
ArgumentParser::ParseResult res = parse(parser, argc, argv);
// Check if full help option is set.
if (isSet(parser, "fullHelp"))
{
setHiddenOptions(parser, false, options);
printHelp(parser);
return ArgumentParser::PARSE_HELP;
}