本文整理汇总了C++中OptArgs::GetFirstString方法的典型用法代码示例。如果您正苦于以下问题:C++ OptArgs::GetFirstString方法的具体用法?C++ OptArgs::GetFirstString怎么用?C++ OptArgs::GetFirstString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OptArgs
的用法示例。
在下文中一共展示了OptArgs::GetFirstString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitContextVarsFromOptArgs
bool BaseCallerParameters::InitContextVarsFromOptArgs(OptArgs& opts){
assert(bc_files.options_set);
char default_run_id[6]; // Create a run identifier from full output directory string
ion_run_to_readname (default_run_id, (char*)bc_files.output_directory.c_str(), bc_files.output_directory.length());
context_vars.run_id = opts.GetFirstString ('-', "run-id", default_run_id);
num_threads_ = opts.GetFirstInt ('n', "num-threads", max(2*numCores(), 4));
num_bamwriter_threads_ = opts.GetFirstInt ('-', "num-threads-bamwriter", 6);
context_vars.flow_signals_type = opts.GetFirstString ('-', "flow-signals-type", "none");
context_vars.extra_trim_left = opts.GetFirstInt ('-', "extra-trim-left", 0);
context_vars.only_process_unfiltered_set = opts.GetFirstBoolean('-', "only-process-unfiltered-set", false);
// Treephaser options
context_vars.dephaser = opts.GetFirstString ('-', "dephaser", "treephaser-sse");
context_vars.keynormalizer = opts.GetFirstString ('-', "keynormalizer", "gain");
context_vars.windowSize = opts.GetFirstInt ('-', "window-size", DPTreephaser::kWindowSizeDefault_);
context_vars.skip_droop = opts.GetFirstBoolean('-', "skip-droop", true);
context_vars.skip_recal_during_norm = opts.GetFirstBoolean('-', "skip-recal-during-normalization", false);
context_vars.diagonal_state_prog = opts.GetFirstBoolean('-', "diagonal-state-prog", false);
// Not every combination of options is possible here:
if (context_vars.diagonal_state_prog and context_vars.dephaser != "treephaser-swan") {
cout << " === BaseCaller Option Incompatibility: Using dephaser treephaser-swan with diagonal state progression instead of "
<< context_vars.dephaser << endl;
context_vars.dephaser = "treephaser-swan";
}
context_vars.process_tfs = true;
context_vars.options_set = true;
return true;
};
示例2: 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;
};
示例3: 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());
}
示例4: 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", "");
}
示例5: 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
}
}
示例6: 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;
}
示例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: 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);
}
示例10: 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);
}
示例11: 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;
}
示例12: main
int main(int argc, const char* argv[])
{
printf ("tvcvalidator %s-%s (%s) - Prototype tvc validation tool\n\n",
IonVersion::GetVersion().c_str(), IonVersion::GetRelease().c_str(), IonVersion::GetSvnRev().c_str());
if (argc == 1) {
VariantValidatorHelp();
return 1;
}
OptArgs opts;
opts.ParseCmdLine(argc, argv);
if (opts.GetFirstBoolean('v', "version", false)) {
return 0;
}
if (opts.GetFirstBoolean('h', "help", false)) {
VariantValidatorHelp();
return 0;
}
string input_vcf_filename = opts.GetFirstString ('i', "input-vcf", "");
string truth_filename = opts.GetFirstString ('t', "truth-file", "");
string truth_dir = opts.GetFirstString ('d', "truth-dir", "/results/plugins/validateVariantCaller/files");
// TODO: reference optional, only used to verify reference allele in input-vcf and truth files
//string reference_filename = opts.GetFirstString ('r', "reference", "");
opts.CheckNoLeftovers();
//
// Step 1. Load input VCF file into memory
//
if (input_vcf_filename.empty()) {
VariantValidatorHelp();
cerr << "ERROR: Input VCF file not specified " << endl;
return 1;
}
VariantCallerResults results_vcf;
results_vcf.load_vcf(input_vcf_filename);
printf("Loaded VCF %s with %d variant calls\n", input_vcf_filename.c_str(), (int)results_vcf.variants.size());
//
// Step 2. Parse truth files, compare them to the input vcf, and compute match scores
//
if (not truth_filename.empty()) {
ValidatorTruth truth;
truth.ReadTruthFile(truth_filename);
truth.CompareToCalls(results_vcf);
return 0;
}
truth_dir += "/*.bed";
glob_t glob_result;
glob(truth_dir.c_str(), GLOB_TILDE, NULL, &glob_result);
for(unsigned int i = 0; i < glob_result.gl_pathc; ++i) {
ValidatorTruth truth;
truth.ReadTruthFile(string(glob_result.gl_pathv[i]));
truth.CompareToCalls(results_vcf);
}
globfree(&glob_result);
return 0;
}
示例13: PrepareHotspots
int PrepareHotspots(int argc, const char *argv[])
{
OptArgs opts;
opts.ParseCmdLine(argc, argv);
string input_bed_filename = opts.GetFirstString ('b', "input-bed", "");
string input_vcf_filename = opts.GetFirstString ('v', "input-vcf", "");
string input_real_vcf_filename = opts.GetFirstString ('p', "input-real-vcf", "");
string output_hot_vcf = opts.GetFirstString ('q', "output-fake-hot-vcf", "");
string output_bed_filename = opts.GetFirstString ('d', "output-bed", "");
string output_vcf_filename = opts.GetFirstString ('o', "output-vcf", "");
string reference_filename = opts.GetFirstString ('r', "reference", "");
string unmerged_bed = opts.GetFirstString ('u', "unmerged-bed", "");
bool left_alignment = opts.GetFirstBoolean('a', "left-alignment", false);
bool filter_bypass = opts.GetFirstBoolean('f', "filter-bypass", false);
bool allow_block_substitutions = opts.GetFirstBoolean('s', "allow-block-substitutions", true);
bool strict_check = opts.GetFirstBoolean('S', "strict-check", true);
opts.CheckNoLeftovers();
if((input_bed_filename.empty() == (input_vcf_filename.empty() and input_real_vcf_filename.empty())) or
(output_bed_filename.empty() and output_vcf_filename.empty()) or reference_filename.empty()) {
PrepareHotspotsHelp();
return 1;
}
if ((not input_real_vcf_filename.empty()) and (output_vcf_filename.empty() or not input_vcf_filename.empty())) {
PrepareHotspotsHelp();
return 1;
}
// Populate chromosome list from reference.fai
// Use mmap to fetch the entire reference
int ref_handle = open(reference_filename.c_str(),O_RDONLY);
struct stat ref_stat;
fstat(ref_handle, &ref_stat);
char *ref = (char *)mmap(0, ref_stat.st_size, PROT_READ, MAP_SHARED, ref_handle, 0);
FILE *fai = fopen((reference_filename+".fai").c_str(), "r");
if (!fai) {
fprintf(stderr, "ERROR: Cannot open %s.fai\n", reference_filename.c_str());
return 1;
}
vector<Reference> ref_index;
map<string,int> ref_map;
char line[1024], chrom_name[1024];
while (fgets(line, 1024, fai) != NULL) {
Reference ref_entry;
long chr_start;
if (5 != sscanf(line, "%1020s\t%ld\t%ld\t%d\t%d", chrom_name, &ref_entry.size, &chr_start,
&ref_entry.bases_per_line, &ref_entry.bytes_per_line))
continue;
ref_entry.chr = chrom_name;
ref_entry.start = ref + chr_start;
ref_index.push_back(ref_entry);
ref_map[ref_entry.chr] = (int) ref_index.size() - 1;
}
fclose(fai);
junction junc;
if (!unmerged_bed.empty()) {
FILE *fp = fopen(unmerged_bed.c_str(), "r");
if (!fp) {
fprintf(stderr, "ERROR: Cannot open %s\n", unmerged_bed.c_str());
return 1;
}
char line2[65536];
junc.init(ref_index.size());
bool line_overflow = false;
while (fgets(line2, 65536, fp) != NULL) {
if (line2[0] and line2[strlen(line2)-1] != '\n' and strlen(line2) == 65535) {
line_overflow = true;
continue;
}
if (line_overflow) {
line_overflow = false;
continue;
}
if (strstr(line2, "track")) continue;
char chr[100];
int b, e;
sscanf(line2, "%s %d %d", chr, &b, &e);
junc.add(ref_map[chr], b, e);
}
fclose(fp);
}
// Load input BED or load input VCF, group by chromosome
deque<LineStatus> line_status;
vector<deque<Allele> > alleles(ref_index.size());
if (!input_bed_filename.empty()) {
FILE *input = fopen(input_bed_filename.c_str(),"r");
if (!input) {
fprintf(stderr,"ERROR: Cannot open %s\n", input_bed_filename.c_str());
return 1;
//.........这里部分代码省略.........
示例14: main
int main (int argc, const char *argv[])
{
printf ("------------- bamrealignment --------------\n");
OptArgs opts;
opts.ParseCmdLine(argc, argv);
vector<int> score_vals(4);
string input_bam = opts.GetFirstString ('i', "input", "");
string output_bam = opts.GetFirstString ('o', "output", "");
opts.GetOption(score_vals, "4,-6,-5,-2", 's', "scores");
int clipping = opts.GetFirstInt ('c', "clipping", 2);
bool anchors = opts.GetFirstBoolean ('a', "anchors", true);
int bandwidth = opts.GetFirstInt ('b', "bandwidth", 10);
bool verbose = opts.GetFirstBoolean ('v', "verbose", false);
bool debug = opts.GetFirstBoolean ('d', "debug", false);
int format = opts.GetFirstInt ('f', "format", 1);
int num_threads = opts.GetFirstInt ('t', "threads", 8);
string log_fname = opts.GetFirstString ('l', "log", "");
if (input_bam.empty() or output_bam.empty())
return PrintHelp();
opts.CheckNoLeftovers();
std::ofstream logf;
if (log_fname.size ())
{
logf.open (log_fname.c_str ());
if (!logf.is_open ())
{
fprintf (stderr, "bamrealignment: Failed to open log file %s\n", log_fname.c_str());
return 1;
}
}
BamReader reader;
if (!reader.Open(input_bam)) {
fprintf(stderr, "bamrealignment: Failed to open input file %s\n", input_bam.c_str());
return 1;
}
SamHeader header = reader.GetHeader();
RefVector refs = reader.GetReferenceData();
BamWriter writer;
writer.SetNumThreads(num_threads);
if (format == 1)
writer.SetCompressionMode(BamWriter::Uncompressed);
else
writer.SetCompressionMode(BamWriter::Compressed);
if (!writer.Open(output_bam, header, refs)) {
fprintf(stderr, "bamrealignment: Failed to open output file %s\n", output_bam.c_str());
return 1;
}
// The meat starts here ------------------------------------
if (verbose)
cout << "Verbose option is activated, each alignment will print to screen." << endl
<< " After a read hit RETURN to continue to the next one," << endl
<< " or press q RETURN to quit the program," << endl
<< " or press s Return to silence verbose," << endl
<< " or press c RETURN to continue printing without further prompt." << endl << endl;
unsigned int readcounter = 0;
unsigned int mapped_readcounter = 0;
unsigned int realigned_readcounter = 0;
unsigned int modified_alignment_readcounter = 0;
unsigned int pos_update_readcounter = 0;
unsigned int failed_clip_realigned_readcount = 0;
unsigned int already_perfect_readcount = 0;
unsigned int bad_md_tag_readcount = 0;
unsigned int error_recreate_ref_readcount = 0;
unsigned int error_clip_anchor_readcount = 0;
unsigned int error_sw_readcount = 0;
unsigned int error_unclip_readcount = 0;
unsigned int start_position_shift;
int orig_position;
int new_position;
string md_tag, new_md_tag, input = "x";
vector<CigarOp> new_cigar_data;
vector<MDelement> new_md_data;
bool position_shift = false;
time_t start_time = time(NULL);
Realigner aligner;
aligner.verbose_ = verbose;
aligner.debug_ = debug;
if (!aligner.SetScores(score_vals))
cout << "bamrealignment: Four scores need to be provided: match, mismatch, gap open, gap extend score!" << endl;
aligner.SetAlignmentBandwidth(bandwidth);
//.........这里部分代码省略.........
示例15: IonstatsAlignment
int IonstatsAlignment(int argc, const char *argv[])
{
OptArgs opts;
opts.ParseCmdLine(argc, argv);
string input_bam_filename = opts.GetFirstString('i', "input", "");
string output_json_filename = opts.GetFirstString('o', "output", "ionstats_alignment.json");
int histogram_length = opts.GetFirstInt ('h', "histogram-length", 400);
if(argc < 2 or input_bam_filename.empty()) {
IonstatsAlignmentHelp();
return 1;
}
//
// Prepare for metric calculation
//
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;
}
ReadLengthHistogram called_histogram;
ReadLengthHistogram aligned_histogram;
ReadLengthHistogram AQ7_histogram;
ReadLengthHistogram AQ10_histogram;
ReadLengthHistogram AQ17_histogram;
ReadLengthHistogram AQ20_histogram;
ReadLengthHistogram AQ47_histogram;
SimpleHistogram error_by_position;
called_histogram.Initialize(histogram_length);
aligned_histogram.Initialize(histogram_length);
AQ7_histogram.Initialize(histogram_length);
AQ10_histogram.Initialize(histogram_length);
AQ17_histogram.Initialize(histogram_length);
AQ20_histogram.Initialize(histogram_length);
AQ47_histogram.Initialize(histogram_length);
error_by_position.Initialize(histogram_length);
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)) {
// Record read length
called_histogram.Add(alignment.Length);
if (!alignment.IsMapped() or !alignment.GetTag("MD",MD_tag))
continue;
//
// Step 1. Parse MD tag
//
MD_op.clear();
MD_len.clear();
for (const char *MD_ptr = MD_tag.c_str(); *MD_ptr;) {
int item_length = 0;
if (*MD_ptr >= '0' and *MD_ptr <= '9') { // Its a match
MD_op.push_back('M');
for (; *MD_ptr and *MD_ptr >= '0' and *MD_ptr <= '9'; ++MD_ptr)
item_length = 10*item_length + *MD_ptr - '0';
} else {
if (*MD_ptr == '^') { // Its a deletion
MD_ptr++;
MD_op.push_back('D');
} else // Its a substitution
MD_op.push_back('X');
for (; *MD_ptr and *MD_ptr >= 'A' and *MD_ptr <= 'Z'; ++MD_ptr)
item_length++;
}
MD_len.push_back(item_length);
}
//
// Step 2. Synchronously scan through Cigar and MD, doing error accounting
//
int MD_idx = alignment.IsReverseStrand() ? MD_op.size()-1 : 0;
int cigar_idx = alignment.IsReverseStrand() ? alignment.CigarData.size()-1 : 0;
int increment = alignment.IsReverseStrand() ? -1 : 1;
int AQ7_bases = 0;
int AQ10_bases = 0;
int AQ17_bases = 0;
int AQ20_bases = 0;
int AQ47_bases = 0;
int num_bases = 0;
//.........这里部分代码省略.........