本文整理汇总了C++中OptArgs类的典型用法代码示例。如果您正苦于以下问题:C++ OptArgs类的具体用法?C++ OptArgs怎么用?C++ OptArgs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OptArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PostProcessArgs
void CommandLineOpts::PostProcessArgs(OptArgs &opts)
{
sys_context.FindExpLogPath();
SetGlobalChipID ( sys_context.explog_path );
if(ChipIdDecoder::IsProtonChip())
{
if(!opts.HasOption('-', "clonal-filter-bkgmodel"))
{
bkg_control.polyclonal_filter.enable = false;
}
if(!opts.HasOption('-', "xtalk-correction"))
{
bkg_control.enable_trace_xtalk_correction = false;
}
if(!opts.HasOption('-', "col-flicker-correct"))
{
img_control.col_flicker_correct = true;
}
if(!opts.HasOption('-', "col-flicker-correct-aggressive"))
{
img_control.aggressive_cnc = true;
}
if(!opts.HasOption('-', "img-gain-correct"))
{
img_control.gain_correct_images = true;
}
}
}
示例2: main
int main(int argc, const char *argv[]) {
OptArgs opts;
opts.ParseCmdLine(argc, argv);
bool help;
string topFile, bottomFile, outFile;
opts.GetOption(topFile, "", '-', "top");
opts.GetOption(bottomFile, "", '-', "bottom");
opts.GetOption(outFile, "", '-', "merged");
opts.GetOption(help, "false", 'h', "help");
if (help || argc == 1) {
usage();
}
ION_ASSERT(!topFile.empty() && !bottomFile.empty() && !outFile.empty(),
"Need top, bottom and merged files. use --help for details.");
MergeAcq merger;
Image top;
Image bottom;
Image combo;
cout << "Loading images." << endl;
ION_ASSERT(top.LoadRaw(topFile.c_str()), "Couldn't load file.");
ION_ASSERT(bottom.LoadRaw(bottomFile.c_str()), "Couldn't load file.");
merger.SetFirstImage(&bottom);
merger.SetSecondImage(&top, bottom.GetRows(), 0); // starting vertically raised but columns the same.
cout << "Merging." << endl;
merger.Merge(combo);
Acq acq;
cout << "Saving. " << endl;
acq.SetData(&combo);
acq.WriteVFC(outFile.c_str(), 0, 0, combo.GetCols(), combo.GetRows());
cout << "Done." << endl;
return 0;
}
示例3: RetrieveParameterBool
bool RetrieveParameterBool(OptArgs &opts, Json::Value& json, char short_name, const string& long_name_hyphens, bool default_value)
{
string long_name_underscores = long_name_hyphens;
for (unsigned int i = 0; i < long_name_underscores.size(); ++i)
if (long_name_underscores[i] == '-')
long_name_underscores[i] = '_';
bool value = default_value;
string source = "builtin default";
if (json.isMember(long_name_underscores)) {
if (json[long_name_underscores].isString())
value = atoi(json[long_name_underscores].asCString());
else
value = json[long_name_underscores].asInt();
source = "parameters json file";
}
if (opts.HasOption(short_name, long_name_hyphens)) {
value = opts.GetFirstBoolean(short_name, long_name_hyphens, value);
source = "command line option";
}
cout << setw(35) << long_name_hyphens << " = " << setw(10) << (value ? "true" : "false") << " (boolean, " << source << ")" << endl;
return value;
}
示例4: Initialize
void RecalibrationModel::Initialize(OptArgs& opts, vector<string> &bam_comments, const string & run_id, const ion::ChipSubset & chip_subset)
{
string model_file_name = opts.GetFirstString ('-', "model-file", "");
int model_threshold = opts.GetFirstInt('-', "recal-model-hp-thres", 4);
bool save_hpmodel = opts.GetFirstBoolean('-', "save-hpmodel", true);
bool diagonal_state_prog = opts.GetFirstBoolean('-', "diagonal-state-prog", false);
if (diagonal_state_prog)
model_file_name.clear();
if (InitializeModel(model_file_name, model_threshold) and save_hpmodel)
SaveModelFileToBamComments(model_file_name, bam_comments, run_id, chip_subset.GetColOffset(), chip_subset.GetRowOffset());
}
示例5: Initialize
void RecalibrationModel::Initialize(OptArgs& opts)
{
is_enabled_ = false;
string model_file_name = opts.GetFirstString ('-', "model-file", "");
if (model_file_name.empty() or model_file_name == "off") {
printf("RecalibrationModel: disabled\n\n");
return;
}
ifstream model_file;
model_file.open(model_file_name.c_str());
if (model_file.fail()) {
printf("RecalibrationModel: disabled (cannot open %s)\n\n", model_file_name.c_str());
model_file.close();
return;
}
recalModelHPThres = opts.GetFirstInt('-', "recal-model-hp-thres", 4);
string comment_line;
getline(model_file, comment_line); //skip the comment time
int flowStart, flowEnd, flowSpan, xMin, xMax, xSpan, yMin, yMax, ySpan, max_hp_calibrated;
model_file >> flowStart >> flowEnd >> flowSpan >> xMin >> xMax >> xSpan >> yMin >> yMax >> ySpan >> max_hp_calibrated;
stratification.SetupRegion(xMin, xMax, xSpan, yMin, yMax, ySpan);
//calculate number of partitions and initialize the stratifiedAs and stratifiedBs
SetupStratification(flowStart,flowEnd, flowSpan,xMin,xMax,xSpan,yMin,yMax,ySpan,max_hp_calibrated);
//TODO: parse model_file into stratifiedAs and stratifiedBs
while (model_file.good()) {
float paramA, paramB;
int refHP;
char flowBase;
model_file >> flowBase >> flowStart >> flowEnd >> xMin >> xMax >> yMin >> yMax >> refHP >> paramA >> paramB;
//populate it to stratifiedAs and startifiedBs
int nucInd = NuctoInt(flowBase);
//boundary check
int offsetRegion = stratification.OffsetRegion(xMin,yMin);
FillIndexes(offsetRegion,nucInd, refHP, flowStart, flowEnd, paramA, paramB);
}
model_file.close();
printf("Recalibration: enabled (using calibration file %s)\n\n", model_file_name.c_str());
is_enabled_ = true;
if (recalModelHPThres > MAX_HPXLEN) is_enabled_ = false;
}
示例6: SetupFileIO
void ExtendParameters::SetupFileIO(OptArgs &opts) {
// freeBayes slot
fasta = opts.GetFirstString('r', "reference", "");
if (fasta.empty()) {
cerr << "Fatal ERROR: Reference file not specified via -r" << endl;
exit(1);
}
ValidateAndCanonicalizePath(fasta);
// freeBayes slot
variantPriorsFile = opts.GetFirstString('c', "input-vcf", "");
if (variantPriorsFile.empty()) {
cerr << "INFO: No input VCF (Hotspot) file specified via -c,--input-vcf" << endl;
}
else
ValidateAndCanonicalizePath(variantPriorsFile);
sseMotifsFileName = opts.GetFirstString('e', "error-motifs", "");
sseMotifsProvided = true;
if (sseMotifsFileName.empty()) {
sseMotifsProvided = false;
cerr << "INFO: Systematic error motif file not specified via -e" << endl;
}
else
ValidateAndCanonicalizePath(sseMotifsFileName);
opts.GetOption(bams, "", 'b', "input-bam");
if (bams.empty()) {
cerr << "FATAL ERROR: BAM file not specified via -b" << endl;
exit(-1);
}
for (unsigned int i_bam = 0; i_bam < bams.size(); ++i_bam)
ValidateAndCanonicalizePath(bams[i_bam]);
outputDir = opts.GetFirstString('O', "output-dir", ".");
ValidateAndCanonicalizePath(outputDir);
outputFile = opts.GetFirstString('o', "output-vcf", "");
if (outputFile.empty()) {
cerr << "Fatal ERROR: Output VCF filename not specified via -o" << endl;
exit(1);
}
// Are those file names?
postprocessed_bam = opts.GetFirstString('-', "postprocessed-bam", "");
sampleName = opts.GetFirstString('g', "sample-name", "");
force_sample_name = opts.GetFirstString('-', "force-sample-name", "");
}
示例7: SetFreeBayesParameters
void ExtendParameters::SetFreeBayesParameters(OptArgs &opts, Json::Value& fb_params) {
// FreeBayes parameters
// primarily used in candidate generation
targets = opts.GetFirstString('t', "target-file", "");
trim_ampliseq_primers = opts.GetFirstBoolean('-', "trim-ampliseq-primers", false);
if (targets.empty() and trim_ampliseq_primers) {
cerr << "ERROR: --trim-ampliseq-primers enabled but no --target-file provided" << endl;
exit(1);
}
allowIndels = RetrieveParameterBool (opts, fb_params, '-', "allow-indels", true);
allowSNPs = RetrieveParameterBool (opts, fb_params, '-', "allow-snps", true);
allowMNPs = RetrieveParameterBool (opts, fb_params, '-', "allow-mnps", true);
allowComplex = RetrieveParameterBool (opts, fb_params, '-', "allow-complex", false);
// deprecated:
// leftAlignIndels = RetrieveParameterBool (opts, fb_params, '-', "left-align-indels", false);
RetrieveParameterBool (opts, fb_params, '-', "left-align-indels", false);
//useBestNAlleles = 0;
useBestNAlleles = RetrieveParameterInt (opts, fb_params, 'm', "use-best-n-alleles", 2);
onlyUseInputAlleles = RetrieveParameterBool (opts, fb_params, '-', "use-input-allele-only", false);
min_mapping_qv = RetrieveParameterInt (opts, fb_params, 'M', "min-mapping-qv", 4);
read_snp_limit = RetrieveParameterInt (opts, fb_params, 'U', "read-snp-limit", 10);
readMaxMismatchFraction = RetrieveParameterDouble(opts, fb_params, 'z', "read-max-mismatch-fraction", 1.0);
maxComplexGap = RetrieveParameterInt (opts, fb_params, '!', "max-complex-gap", 1);
// read from json or command line, otherwise default to snp frequency
minAltFraction = RetrieveParameterDouble(opts, fb_params, '-', "gen-min-alt-allele-freq", my_controls.filter_snps.min_allele_freq);
minCoverage = RetrieveParameterInt (opts, fb_params, '-', "gen-min-coverage", my_controls.filter_snps.min_cov);
minIndelAltFraction = RetrieveParameterDouble(opts, fb_params, '-', "gen-min-indel-alt-allele-freq", my_controls.filter_hp_indel.min_allele_freq);
//set up debug levels
if (program_flow.DEBUG > 0)
debug = true;
if (program_flow.inputPositionsOnly) {
processInputPositionsOnly = true;
}
if (variantPriorsFile.empty() && (processInputPositionsOnly || onlyUseInputAlleles) ) {
cerr << "ERROR: Parameter error - Process-input-positions-only: " << processInputPositionsOnly << " use-input-allele-only: " << onlyUseInputAlleles << " : Specified without Input VCF File " << endl;
exit(1);
}
}
示例8: RetrieveParameterString
string RetrieveParameterString(OptArgs &opts, Json::Value& json, char short_name, const string& long_name_hyphens, const string& default_value)
{
string long_name_underscores = GetRidOfDomainAndHyphens(long_name_hyphens);
string value = default_value;
string source = "builtin default";
if (json.isMember(long_name_underscores)) {
value = json[long_name_underscores].asCString();
source = "parameters json file";
}
if (opts.HasOption(short_name, long_name_hyphens)) {
value = opts.GetFirstString(short_name, long_name_hyphens, value);
source = "command line option";
}
cout << setw(35) << long_name_hyphens << " = " << setw(10) << value << " (string, " << source << ")" << endl;
return value;
}
示例9: IonstatsReduceH5
int IonstatsReduceH5(int argc, const char *argv[])
{
OptArgs opts;
opts.ParseCmdLine(argc-1, argv+1);
string output_h5_filename = opts.GetFirstString ('o', "output", "");
bool merge_proton_blocks = opts.GetFirstBoolean ('b', "merge-proton-blocks", "true");
vector<string> input_h5_filename;
opts.GetLeftoverArguments(input_h5_filename);
if(input_h5_filename.empty() or output_h5_filename.empty()) {
IonstatsReduceH5Help();
return 1;
}
if(merge_proton_blocks)
cout << "NOTE:" << argv[0] << " " << argv[1] << ": --merge-proton-blocks=true so any Proton block-specific read group suffixes will be merged" << endl;
return IonstatsAlignmentReduceH5(output_h5_filename, input_h5_filename, merge_proton_blocks);
}
示例10: IonstatsReduce
int IonstatsReduce(int argc, const char *argv[])
{
OptArgs opts;
opts.ParseCmdLine(argc, argv);
string output_json_filename = opts.GetFirstString('o', "output", "");
vector<string> input_jsons;
opts.GetLeftoverArguments(input_jsons);
if(input_jsons.empty() or output_json_filename.empty()) {
IonstatsReduceHelp();
return 1;
}
ifstream in(input_jsons[0].c_str(), ifstream::in);
if (!in.good()) {
fprintf(stderr, "[ionstats] ERROR: cannot open %s\n", input_jsons[0].c_str());
return 1;
}
Json::Value first_input_json;
in >> first_input_json;
in.close();
if (!first_input_json.isMember("meta")) {
fprintf(stderr, "[ionstats] ERROR: %s is not a valid input file for ionstats reduce\n", input_jsons[0].c_str());
return 1;
}
string format_name = first_input_json["meta"].get("format_name","").asString();
if (format_name == "ionstats_basecaller")
return IonstatsBasecallerReduce(output_json_filename, input_jsons);
if (format_name == "ionstats_tf")
return IonstatsTestFragmentsReduce(output_json_filename, input_jsons);
if (format_name == "ionstats_alignment")
return IonstatsAlignmentReduce(output_json_filename, input_jsons);
fprintf(stderr, "[ionstats] ERROR: %s is not a valid input file for ionstats reduce\n", input_jsons[0].c_str());
return 1;
}
示例11: SetOpts
void ProgramControlSettings::SetOpts(OptArgs &opts, Json::Value &tvc_params) {
DEBUG = opts.GetFirstInt ('d', "debug", 0);
nThreads = RetrieveParameterInt (opts, tvc_params, 'n', "num-threads", 12);
nVariantsPerThread = RetrieveParameterInt (opts, tvc_params, 'N', "num-variants-per-thread", 250);
use_SSE_basecaller = RetrieveParameterBool (opts, tvc_params, '-', "use-sse-basecaller", true);
// decide diagnostic
rich_json_diagnostic = RetrieveParameterBool (opts, tvc_params, '-', "do-json-diagnostic", false);
minimal_diagnostic = RetrieveParameterBool (opts, tvc_params, '-', "do-minimal-diagnostic", false);
inputPositionsOnly = RetrieveParameterBool (opts, tvc_params, '-', "process-input-positions-only", false);
suppress_recalibration = RetrieveParameterBool (opts, tvc_params, '-', "suppress-recalibration", true);
resolve_clipped_bases = RetrieveParameterBool (opts, tvc_params, '-', "resolve-clipped-bases", false);
}
示例12: ParametersFromJSON
void ExtendParameters::ParametersFromJSON(OptArgs &opts, Json::Value &tvc_params, Json::Value &freebayes_params, Json::Value ¶ms_meta) {
string parameters_file = opts.GetFirstString('-', "parameters-file", "");
Json::Value parameters_json(Json::objectValue);
if (not parameters_file.empty()) {
ifstream in(parameters_file.c_str(), ifstream::in);
if (!in.good()) {
fprintf(stderr, "[tvc] FATAL ERROR: cannot open %s\n", parameters_file.c_str());
exit(-1);
}
in >> parameters_json;
in.close();
if (parameters_json.isMember("pluginconfig"))
parameters_json = parameters_json["pluginconfig"];
tvc_params = parameters_json.get("torrent_variant_caller", Json::objectValue);
freebayes_params = parameters_json.get("freebayes", Json::objectValue);
params_meta = parameters_json.get("meta", Json::objectValue);
}
示例13: SetKeyAndFlowOrder
bool BaseCallerContext::SetKeyAndFlowOrder(OptArgs& opts, const char * FlowOrder, const int NumFlows)
{
flow_order.SetFlowOrder( opts.GetFirstString ('-', "flow-order", FlowOrder),
opts.GetFirstInt ('f', "flowlimit", NumFlows));
if (flow_order.num_flows() > NumFlows)
flow_order.SetNumFlows(NumFlows);
assert(flow_order.is_ok());
string lib_key = opts.GetFirstString ('-', "lib-key", "TCAG"); //! @todo Get default key from wells
string tf_key = opts.GetFirstString ('-', "tf-key", "ATCG");
lib_key = opts.GetFirstString ('-', "librarykey", lib_key); // Backward compatible opts
tf_key = opts.GetFirstString ('-', "tfkey", tf_key);
keys.resize(2);
keys[0].Set(flow_order, lib_key, "lib");
keys[1].Set(flow_order, tf_key, "tf");
return true;
};
示例14: InitializeFromOptArgs
void PhaseEstimator::InitializeFromOptArgs(OptArgs& opts)
{
phasing_estimator_ = opts.GetFirstString ('-', "phasing-estimator", "spatial-refiner-2");
string arg_cf_ie_dr = opts.GetFirstString ('-', "libcf-ie-dr", "");
residual_threshold_ = opts.GetFirstDouble ('-', "phasing-residual-filter", 1.0);
max_phasing_levels_ = opts.GetFirstInt ('-', "max-phasing-levels", max_phasing_levels_default_);
use_pid_norm_ = opts.GetFirstString ('-', "keynormalizer", "keynorm-old") == "keynorm-new";
windowSize_ = opts.GetFirstInt ('-', "window-size", DPTreephaser::kWindowSizeDefault_);
if (!arg_cf_ie_dr.empty()) {
phasing_estimator_ = "override";
result_regions_x_ = 1;
result_regions_y_ = 1;
result_cf_.assign(1, 0.0);
result_ie_.assign(1, 0.0);
result_dr_.assign(1, 0.0);
if (3 != sscanf (arg_cf_ie_dr.c_str(), "%f,%f,%f", &result_cf_[0], &result_ie_[0], &result_dr_[0])) {
fprintf (stderr, "Option Error: libcf-ie-dr %s\n", arg_cf_ie_dr.c_str());
exit (EXIT_FAILURE);
}
return; // --libcf-ie-dr overrides other phasing-related options
}
}
示例15: IonstatsTestFragments
int IonstatsTestFragments(int argc, const char *argv[])
{
OptArgs opts;
opts.ParseCmdLine(argc, argv);
string input_bam_filename = opts.GetFirstString('i', "input", "");
string fasta_filename = opts.GetFirstString('r', "ref", "");
string output_json_filename = opts.GetFirstString('o', "output", "ionstats_tf.json");
int histogram_length = opts.GetFirstInt ('h', "histogram-length", 400);
if(argc < 2 or input_bam_filename.empty() or fasta_filename.empty()) {
IonstatsTestFragmentsHelp();
return 1;
}
//
// Prepare for metric calculation
//
map<string,string> tf_sequences;
PopulateReferenceSequences(tf_sequences, fasta_filename);
BamReader input_bam;
if (!input_bam.Open(input_bam_filename)) {
fprintf(stderr, "[ionstats] ERROR: cannot open %s\n", input_bam_filename.c_str());
return 1;
}
int num_tfs = input_bam.GetReferenceCount();
SamHeader sam_header = input_bam.GetHeader();
if(!sam_header.HasReadGroups()) {
fprintf(stderr, "[ionstats] ERROR: no read groups in %s\n", input_bam_filename.c_str());
return 1;
}
string flow_order;
string key;
for (SamReadGroupIterator rg = sam_header.ReadGroups.Begin(); rg != sam_header.ReadGroups.End(); ++rg) {
if(rg->HasFlowOrder())
flow_order = rg->FlowOrder;
if(rg->HasKeySequence())
key = rg->KeySequence;
}
// Need these metrics stratified by TF.
vector<ReadLengthHistogram> called_histogram(num_tfs);
vector<ReadLengthHistogram> aligned_histogram(num_tfs);
vector<ReadLengthHistogram> AQ10_histogram(num_tfs);
vector<ReadLengthHistogram> AQ17_histogram(num_tfs);
vector<SimpleHistogram> error_by_position(num_tfs);
vector<MetricGeneratorSNR> system_snr(num_tfs);
vector<MetricGeneratorHPAccuracy> hp_accuracy(num_tfs);
for (int tf = 0; tf < num_tfs; ++tf) {
called_histogram[tf].Initialize(histogram_length);
aligned_histogram[tf].Initialize(histogram_length);
AQ10_histogram[tf].Initialize(histogram_length);
AQ17_histogram[tf].Initialize(histogram_length);
error_by_position[tf].Initialize(histogram_length);
}
vector<uint16_t> flow_signal_fz(flow_order.length());
vector<int16_t> flow_signal_zm(flow_order.length());
const RefVector& refs = input_bam.GetReferenceData();
// Missing:
// - hp accuracy - tough, copy verbatim from TFMapper?
BamAlignment alignment;
vector<char> MD_op;
vector<int> MD_len;
MD_op.reserve(1024);
MD_len.reserve(1024);
string MD_tag;
//
// Main loop over mapped reads in the input BAM
//
while(input_bam.GetNextAlignment(alignment)) {
if (!alignment.IsMapped() or !alignment.GetTag("MD",MD_tag))
continue;
// The check below eliminates unexpected alignments
if (alignment.IsReverseStrand() or alignment.Position > 5)
continue;
int current_tf = alignment.RefID;
//
// Step 1. Parse MD tag
//
//.........这里部分代码省略.........