本文整理汇总了C++中OptArgs::CheckNoLeftovers方法的典型用法代码示例。如果您正苦于以下问题:C++ OptArgs::CheckNoLeftovers方法的具体用法?C++ OptArgs::CheckNoLeftovers怎么用?C++ OptArgs::CheckNoLeftovers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OptArgs
的用法示例。
在下文中一共展示了OptArgs::CheckNoLeftovers方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, const char *argv[]) {
OptArgs opts;
opts.ParseCmdLine(argc, argv);
string queryFile, goldFile;
double epsilon;
bool help = false;
bool version = false;
int allowedWrong = 0;
double maxAbsVal = 0;
double minCorrelation = 1;
opts.GetOption(queryFile, "", 'q', "query-wells");
opts.GetOption(goldFile, "", 'g', "gold-wells");
opts.GetOption(epsilon, "0.0", 'e', "epsilon");
opts.GetOption(allowedWrong, "0", 'm', "max-mismatch");
opts.GetOption(minCorrelation, "1", 'c', "min-cor");
opts.GetOption(maxAbsVal, "1e3", '-', "max-val");
opts.GetOption(help, "false", 'h', "help");
opts.GetOption(version, "false", 'v', "version");
opts.CheckNoLeftovers();
if (version) {
fprintf (stdout, "%s", IonVersion::GetFullVersion("RawWellsEquivalent").c_str());
exit(0);
}
if (queryFile.empty() || goldFile.empty() || help) {
cout << "RawWellsEquivalent - Check to see how similar two wells files are to each other" << endl
<< "options: " << endl
<< " -g,--gold-wells trusted wells to compare against." << endl
<< " -q,--query-wells new wells to check." << endl
<< " -e,--epsilon maximum allowed difference to be considered equivalent." << endl
<< " -m,--max-mixmatch maximum number of non-equivalent entries to allow." << endl
<< " -c,--min-cor minimum correlation allowed to be considered equivalent." << endl
<< " --max-val maximum absolute value considered (avoid extreme values)." << endl
<< " -h,--help this message." << endl
<< "" << endl
<< "usage: " << endl
<< " RawWellsEquivalent -e 10 --query-wells query.wells --gold-wells gold.wells " << endl;
exit(1);
}
NumericalComparison<double> compare = CompareWells(queryFile, goldFile, epsilon, maxAbsVal);
cout << compare.GetCount() << " total values. " << endl
<< compare.GetNumSame() << " (" << (100.0 * compare.GetNumSame())/compare.GetCount() << "%) are equivalent. " << endl
<< compare.GetNumDiff() << " (" << (100.0 * compare.GetNumDiff())/compare.GetCount() << "%) are not equivalent. " << endl
<< "Correlation of: " << compare.GetCorrelation() << endl;
if((compare.GetCount() - allowedWrong) >= compare.GetNumSame() ||
compare.GetCorrelation() < minCorrelation) {
cout << "Wells files not equivalent for allowed mismatch: " << allowedWrong
<< " minimum correlation: " << minCorrelation << endl;
return 1;
}
cout << "Wells files equivalent for allowed mismatch: " << allowedWrong
<< " minimum correlation: " << minCorrelation << endl;
return 0;
}
示例2: main
int main(int argc, const char *argv[]) {
OptArgs opts;
opts.ParseCmdLine(argc, argv);
string queryFile, goldFile;
double epsilon;
bool help = false;
bool version = false;
int allowedWrong = 0;
double maxAbsVal = 0;
double minCorrelation = 1;
bool dumpMisMatch = false;
opts.GetOption(queryFile, "", 'q', "query-wells");
opts.GetOption(goldFile, "", 'g', "gold-wells");
opts.GetOption(epsilon, "0.0", 'e', "epsilon");
opts.GetOption(allowedWrong, "0", 'm', "max-mismatch");
opts.GetOption(minCorrelation, "1", 'c', "min-cor");
opts.GetOption(maxAbsVal, "1e3", '-', "max-val");
opts.GetOption(help, "false", 'h', "help");
opts.GetOption(version, "false", 'v', "version");
opts.GetOption(dumpMisMatch, "false", 'o', "dump-mismatch");
opts.CheckNoLeftovers();
if (version) {
fprintf (stdout, "%s", IonVersion::GetFullVersion("RawWellsEquivalent").c_str());
exit(0);
}
if (queryFile.empty() || goldFile.empty() || help) {
printUsage();
exit(1);
}
DumpMismatches dump(dumpMisMatch);
NumericalComparison<double> compare = CompareWells(queryFile, goldFile, epsilon, maxAbsVal, dump);
cout << compare.GetCount() << " total values. " << endl
<< compare.GetNumSame() << " (" << (100.0 * compare.GetNumSame())/compare.GetCount() << "%) are equivalent. " << endl
<< compare.GetNumDiff() << " (" << (100.0 * compare.GetNumDiff())/compare.GetCount() << "%) are not equivalent. " << endl
<< "Correlation of: " << compare.GetCorrelation() << endl;
if((compare.GetCount() - allowedWrong) > compare.GetNumSame() ||
(compare.GetCorrelation() < minCorrelation && compare.GetCount() != compare.GetNumSame())) {
cout << "Wells files not equivalent for allowed mismatch: " << allowedWrong
<< " minimum correlation: " << minCorrelation << endl;
return 1;
}
cout << "Wells files equivalent for allowed mismatch: " << allowedWrong
<< " minimum correlation: " << minCorrelation << endl;
return 0;
}
示例3: main
int main (int argc, const char *argv[])
{
time_t program_start_time;
time(&program_start_time);
Json::Value calibration_json(Json::objectValue);
DumpStartingStateOfProgram (argc,argv,program_start_time, calibration_json["Calibration"]);
//
// Step 1. Process command line options
//
OptArgs opts;
opts.ParseCmdLine(argc, argv);
CalibrationContext calib_context;
if (not calib_context.InitializeFromOpts(opts)){
PrintHelp_CalModules();
}
HistogramCalibration master_histogram(opts, calib_context);
calib_context.hist_calibration_master = &master_histogram;
LinearCalibrationModel master_linear_model(opts, calib_context);
calib_context.linear_model_master = &master_linear_model;
opts.CheckNoLeftovers();
//
// Step 2. Execute threaded calibration
//
time_t calibration_start_time;
time(&calibration_start_time);
pthread_mutex_init(&calib_context.read_mutex, NULL);
pthread_mutex_init(&calib_context.write_mutex, NULL);
pthread_t worker_id[calib_context.num_threads];
for (int worker = 0; worker < calib_context.num_threads; worker++)
if (pthread_create(&worker_id[worker], NULL, CalibrationWorker, &calib_context)) {
cerr << "Calibration ERROR: Problem starting thread" << endl;
exit (EXIT_FAILURE);
}
for (int worker = 0; worker < calib_context.num_threads; worker++)
pthread_join(worker_id[worker], NULL);
pthread_mutex_destroy(&calib_context.read_mutex);
pthread_mutex_destroy(&calib_context.write_mutex);
time_t calibration_end_time;
time(&calibration_end_time);
//
// Step 3. Create models, write output, and close modules
//
// HP histogram calibration
if (master_histogram.CreateCalibrationModel())
master_histogram.ExportModelToJson(calibration_json["HPHistogram"]);
// Linear Model
if (master_linear_model.CreateCalibrationModel())
master_linear_model.ExportModelToJson(calibration_json["LinearModel"], "");
// Transfer stuff from calibration context and close bam reader
calib_context.Close(calibration_json["Calibration"]);
time_t program_end_time;
time(&program_end_time);
calibration_json["Calibration"]["end_time"] = get_time_iso_string(program_end_time);
calibration_json["Calibration"]["total_duration"] = (Json::Int)difftime(program_end_time,program_start_time);
calibration_json["Calibration"]["calibration_duration"] = (Json::Int)difftime(calibration_end_time,calibration_start_time);
SaveJson(calibration_json, calib_context.filename_json);
return EXIT_SUCCESS;
}
示例4: 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);
//.........这里部分代码省略.........
示例5: 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;
//.........这里部分代码省略.........
示例6: main
int main (int argc, const char *argv[])
{
time_t program_start_time;
time(&program_start_time);
Json::Value calibration_json(Json::objectValue);
DumpStartingStateOfProgram (argc,argv,program_start_time, calibration_json["Calibration"]);
//
// Step 1. Process command line options
//
OptArgs opts;
opts.ParseCmdLine(argc, argv);
// enable floating point exceptions during program execution
if (opts.GetFirstBoolean('-', "float-exceptions", true)) {
cout << "Calibration: Floating point exceptions enabled." << endl;
feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
} //*/
CalibrationContext calib_context;
if (not calib_context.InitializeFromOpts(opts)){
PrintHelp_CalModules();
}
HistogramCalibration master_histogram(opts, calib_context);
calib_context.hist_calibration_master = &master_histogram;
LinearCalibrationModel master_linear_model(opts, calib_context);
calib_context.linear_model_master = &master_linear_model;
opts.CheckNoLeftovers();
//
// Step 2. Execute threaded calibration
//
int calibration_thread_time = 0;
if (calib_context.successive_fit) {
// first train linear model
if (master_linear_model.DoTraining()) {
int l_thread_time = 0;
for (int i_iteration=0; i_iteration<calib_context.num_train_iterations; i_iteration++) {
cout << " -Training Iteration " << i_iteration+1;
l_thread_time = ExecuteThreadedCalibrationTraining(calib_context);
// Activate master linear model after every round of training
master_linear_model.CreateCalibrationModel(false); // make linear model
master_linear_model.SetModelGainsAndOffsets(); // expand for use in basecalling
calibration_thread_time += l_thread_time;
calib_context.bam_reader.Rewind(); // reset all files for another pass
cout << " Duration = " << l_thread_time << endl;
}
}
// Then apply it during polish model training
if (master_histogram.DoTraining()) {
calib_context.local_fit_linear_model = false;
calib_context.local_fit_polish_model = true;
calibration_thread_time += ExecuteThreadedCalibrationTraining(calib_context);
}
}
else {
// Single pass in which both models are fit jointly
calibration_thread_time=ExecuteThreadedCalibrationTraining(calib_context);
}
//
// Step 3. Create models, write output, and close modules
//
// Linear Model
if (master_linear_model.CreateCalibrationModel())
master_linear_model.ExportModelToJson(calibration_json["LinearModel"], "");
// HP histogram calibration
if (master_histogram.CreateCalibrationModel())
master_histogram.ExportModelToJson(calibration_json["HPHistogram"]);
// Transfer stuff from calibration context and close bam reader
calib_context.Close(calibration_json["Calibration"]);
time_t program_end_time;
time(&program_end_time);
calibration_json["Calibration"]["end_time"] = get_time_iso_string(program_end_time);
calibration_json["Calibration"]["total_duration"] = (Json::Int)difftime(program_end_time,program_start_time);
calibration_json["Calibration"]["calibration_duration"] = (Json::Int)calibration_thread_time;
SaveJson(calibration_json, calib_context.filename_json);
return EXIT_SUCCESS;
}
示例7: main
int main(int argc, const char *argv[]) {
OptArgs opts;
opts.ParseCmdLine(argc, argv);
int hpLength;
string statsOut;
string alignmentOut;
string pairedOut;
string flowsOut;
string summaryOut;
string samFile;
string qScoreCol;
string wellsFile;
string bfmaskFile;
string snrFile;
string binnedHpSigFile;
string flowErrFile;
string gcErrFile;
int gcWin;
string flowOrder;
string keySeq;
int numFlows;
bool help;
int qLength;
double colCenter;
double rowCenter;
int colSize;
int rowSize;
int sampleSize;
string wellsToUse;
string run1, run2;
opts.GetOption(run1, "", '-', "sff1");
opts.GetOption(run2, "", '-', "sff2");
opts.GetOption(wellsToUse, "", '-', "use-wells");
opts.GetOption(samFile, "", '-', "sam-parsed");
opts.GetOption(statsOut, "", '-', "stats-out");
opts.GetOption(flowsOut, "", '-', "flows-out");
opts.GetOption(alignmentOut, "", '-', "align-out");
opts.GetOption(summaryOut, "", '-', "summary-out");
opts.GetOption(pairedOut, "", '-', "paired-out");
opts.GetOption(numFlows, "40", '-', "num-flows");
opts.GetOption(hpLength, "6", '-', "max-hp");
opts.GetOption(qScoreCol, "q7Len", '-', "qscore-col");
opts.GetOption(qLength, "25", '-', "min-qlength");
opts.GetOption(help, "false", 'h', "help");
opts.GetOption(wellsFile, "", '-', "wells-file");
opts.GetOption(bfmaskFile, "", '-', "bfmask-file");
opts.GetOption(snrFile, "", '-', "snr-file");
opts.GetOption(binnedHpSigFile, "", '-', "binned-hp-sig-file");
opts.GetOption(flowErrFile, "", '-', "flow-err-file");
opts.GetOption(gcErrFile, "", '-', "gc-err-file");
opts.GetOption(flowOrder, "", '-', "flow-order");
opts.GetOption(keySeq, "", '-', "key-seq");
opts.GetOption(colCenter, "0.5", '-', "col-center");
opts.GetOption(rowCenter, "0.5", '-', "row-center");
opts.GetOption(colSize, "0", '-', "col-size");
opts.GetOption(rowSize, "0", '-', "row-size");
opts.GetOption(gcErrFile, "", '-', "gc-err-file");
opts.GetOption(gcWin, "40", '-', "gc-win");
opts.GetOption(sampleSize, "100000", '-', "sample-size");
if (help || samFile.empty() || statsOut.empty() || summaryOut.empty()) {
usage();
}
opts.CheckNoLeftovers();
// Some checks to make sure sensible bounds have been set
if(colCenter < 0 || colCenter > 1) {
cerr << "AnalyzeHPErrs - col-center must be in the range [0,1]" << endl;
exit(1);
}
if(rowCenter < 0 || rowCenter > 1) {
cerr << "AnalyzeHPErrs - row-center must be in the range [0,1]" << endl;
exit(1);
}
if(colSize < 0) {
cerr << "AnalyzeHPErrs - col-size cannot be negative." << endl;
exit(1);
}
if(rowSize < 0) {
cerr << "AnalyzeHPErrs - row-size cannot be negative." << endl;
exit(1);
}
// Determine rows & cols if a bfmask file was supplied
int nRow=0;
int nCol=0;
if(!bfmaskFile.empty()) {
if(GetRowColFromBfmask(bfmaskFile, &nRow, &nCol)) {
cerr << "AnalyzeHPErrs - problem determining rows & columns from bfmask file " << bfmaskFile << endl;
exit(1);
}
}
// Set up fds object
FlowDiffStats* fds;
if (!run1.empty()) {
SffDiffStats* sds = new SffDiffStats(hpLength, nCol, nRow, qScoreCol, run1, run2);
if (!pairedOut.empty())
sds->SetPairedOut(pairedOut);
fds = dynamic_cast<FlowDiffStats*>(sds);
}
//.........这里部分代码省略.........
示例8: 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 output_bed_filename = opts.GetFirstString ('d', "output-bed", "");
string output_vcf_filename = opts.GetFirstString ('o', "output-vcf", "");
string reference_filename = opts.GetFirstString ('r', "reference", "");
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", false);
opts.CheckNoLeftovers();
if((input_bed_filename.empty() == input_vcf_filename.empty()) or
(output_bed_filename.empty() and output_vcf_filename.empty()) or reference_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, "%s\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);
// 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;
}
char line2[65536];
int line_number = 0;
bool line_overflow = false;
while (fgets(line2, 65536, input) != NULL) {
if (line2[0] and line2[strlen(line2)-1] != '\n' and strlen(line2) == 65535) {
line_overflow = true;
continue;
}
line_number++;
if (line_overflow) {
line_overflow = false;
line_status.push_back(LineStatus(line_number));
line_status.back().filter_message_prefix = "Malformed hotspot BED line: line length exceeds 64K";
continue;
}
if (strncmp(line2, "browser", 7) == 0)
continue;
if (strncmp(line2, "track", 5) == 0) {
if (string::npos != string(line2).find("allowBlockSubstitutions=true"))
allow_block_substitutions = true;
continue;
}
char *current_chr = strtok(line2, "\t\r\n");
char *current_start = strtok(NULL, "\t\r\n");
char *current_end = strtok(NULL, "\t\r\n");
char *current_id = strtok(NULL, "\t\r\n");
char *penultimate = strtok(NULL, "\t\r\n");
char *ultimate = strtok(NULL, "\t\r\n");
for (char *next = strtok(NULL, "\t\r\n"); next; next = strtok(NULL, "\t\r\n")) {
//.........这里部分代码省略.........
示例9: 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;
}
示例10: main
int main(int argc, const char *argv[])
{
OptArgs opts;
opts.ParseCmdLine(argc, argv);
string inFile, outFile;
bool help = false;
bool version = false;
double lower = -5.0;
double upper = 28.0;
opts.GetOption(inFile, "", 'i', "input-file");
opts.GetOption(outFile, "", 'o', "output-file");
opts.GetOption(lower, "-5.0", '-', "wells-convert-low");
opts.GetOption(upper, "28.0", '-', "wells-convert-high");
opts.GetOption(help, "false", 'h', "help");
opts.GetOption(version, "false", 'v', "version");
opts.CheckNoLeftovers();
if (version)
{
fprintf (stdout, "%s", IonVersion::GetFullVersion("RawWellsConverter").c_str());
exit(0);
}
if (inFile.empty() || help)
{
cout << "RawWellsConverter - Convert unsigned short type wells file to float type wells file, or vice versa." << endl
<< "options: " << endl
<< " -i,--input-file input wells file." << endl
<< " -o,--output-file output wells file." << endl
<< " ,--wells-convert-low lower bound for converting to unsigned short." << endl
<< " ,--wells-convert-high upper bound for converting to unsigned short." << endl
<< " -h,--help this message." << endl
<< "" << endl
<< "usage: " << endl
<< " RawWellsConverter -i input_path/1.wells -o output_path/1.wells " << endl;
exit(1);
}
struct stat sb;
if(stat(inFile.c_str(), &sb) != 0)
{
cerr << "RawWellsConverter ERROR: " << inFile << " does not exist." << endl;
exit (1);
}
if (outFile.empty())
{
outFile = inFile;
outFile += ".converted";
}
string cmd("cp ");
cmd += inFile;
cmd += " ";
cmd += outFile;
int ret0 = system(cmd.c_str());
hid_t root = H5Fopen(outFile.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
if(root < 0)
{
cerr << "RawWellsConverter ERROR: Fail to open " << outFile << endl;
exit(1);
}
H5G_info_t group_info;
group_info.nlinks = 0;
if(H5Gget_info(root, &group_info) < 0)
{
H5Fclose(root);
cerr << "RawWellsConverter ERROR: Fail H5Gget_info." << endl;
exit(1);
}
char name[10];
string sName;
bool bWells = false;
bool bCopies = false;
for(unsigned int i = 0; i < group_info.nlinks; ++i)
{
int size = H5Gget_objname_by_idx(root, i, NULL, 0);
if(H5Gget_objname_by_idx(root, i, name, size + 1) < 0)
{
H5Fclose(root);
cerr << "RawWellsConverter ERROR: Fail H5Gget_objname_by_idx." << endl;
exit(1);
}
else
{
sName = name;
if(sName == "wells")
{
bWells = true;
}
if(sName == "wells_copies")
{
bCopies = true;
}
}
}
//.........这里部分代码省略.........
示例11: main
int main(int argc, const char *argv[])
{
#ifdef _DEBUG
atexit(memstatus);
dbgmemInit();
#endif /* _DEBUG */
printf ("%s - %s-%s (%s)\n", argv[0], IonVersion::GetVersion().c_str(), IonVersion::GetRelease().c_str(), IonVersion::GetSvnRev().c_str());
string bamInputFilename;
string fastaInputFilename;
string jsonOutputFilename;
bool help;
OptArgs opts;
opts.ParseCmdLine(argc, argv);
opts.GetOption(bamInputFilename, "", '-', "bam");
opts.GetOption(fastaInputFilename, "", '-', "ref");
opts.GetOption(jsonOutputFilename, "TFStats.json", '-', "output-json");
opts.GetOption(help, "false", 'h', "help");
opts.CheckNoLeftovers();
if (help || bamInputFilename.empty() || fastaInputFilename.empty())
return showHelp();
// Parse BAM header
BAMReader bamReader(bamInputFilename);
bamReader.open();
bam_header_t *header = (bam_header_t *)bamReader.get_header_ptr();
int numFlows = 0;
string flowOrder;
string key;
if (header->l_text >= 3) {
if (header->dict == 0)
header->dict = sam_header_parse2(header->text);
int nEntries = 0;
char **tmp = sam_header2list(header->dict, "RG", "FO", &nEntries);
if (nEntries) {
flowOrder = tmp[0];
numFlows = flowOrder.length();
}
if (tmp)
free(tmp);
nEntries = 0;
tmp = sam_header2list(header->dict, "RG", "KS", &nEntries);
if (nEntries) {
key = tmp[0];
}
if (tmp)
free(tmp);
}
if (numFlows <= 0) {
fprintf(stderr, "[TFMapper] Could not retrieve flow order from FO BAM tag. SFF-specific tags absent?\n");
exit(1);
}
if (key.empty()) {
fprintf(stderr, "[TFMapper] Could not retrieve key sequence from KS BAM tag. SFF-specific tags absent?\n");
exit(1);
}
//printf("Retrieved flow order from bam: %s (%d)\n", flowOrder.c_str(), numFlows);
//printf("Retrieved key from bam: %s\n", key.c_str());
// Retrieve test fragment sequences
vector<string> referenceSequences;
PopulateReferenceSequences(referenceSequences, fastaInputFilename, header->n_targets, header->target_name, string(""));
// Process the BAM reads and generate metrics
int numTFs = header->n_targets;
vector<int> TFCount(numTFs,0);
MetricGeneratorQualityHistograms metricGeneratorQualityHistograms[numTFs];
MetricGeneratorHPAccuracy metricGeneratorHPAccuracy[numTFs];
MetricGeneratorSNR metricGeneratorSNR[numTFs];
MetricGeneratorAvgIonogram metricGeneratorAvgIonogram[numTFs];
for (BAMReader::iterator i = bamReader.get_iterator(); i.good(); i.next()) {
BAMRead bamRead = i.get();
int bestTF = bamRead.get_tid();
if (bestTF < 0)
continue;
BAMUtils bamUtil(bamRead);
TFCount[bestTF]++;
// Extract flowspace signal from FZ BAM tag
uint16_t *bam_flowgram = NULL;
uint8_t *fz = bam_aux_get(bamRead.get_bam_ptr(), "FZ");
if (fz != NULL) {
if (fz[0] == (uint8_t)'B' && fz[1] == (uint8_t)'S' && *((uint32_t *)(fz+2)) == (uint32_t)numFlows)
bam_flowgram = (uint16_t *)(fz+6);
}
//.........这里部分代码省略.........