本文整理汇总了C++中OptArgs::GetOption方法的典型用法代码示例。如果您正苦于以下问题:C++ OptArgs::GetOption方法的具体用法?C++ OptArgs::GetOption怎么用?C++ OptArgs::GetOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OptArgs
的用法示例。
在下文中一共展示了OptArgs::GetOption方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例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;
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;
}
示例3: 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;
}
示例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: 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);
//.........这里部分代码省略.........
示例6: main
int main(int argc, const char *argv[]) {
OptArgs opts;
TraceConfig config;
string inputDir;
string outputDir;
bool help;
opts.ParseCmdLine(argc, argv);
opts.GetOption(inputDir, "", '-', "source-dir");
opts.GetOption(outputDir, "", '-', "output-dir");
opts.GetOption(config.precision, "5", '-', "precision");
opts.GetOption(config.numEvec, "7", '-', "num-evec");
opts.GetOption(config.doDebug, "false", '-', "debug-files");
opts.GetOption(config.compressionType, "delta", '-', "compression");
opts.GetOption(config.numFlows, "-1", '-', "num-flows");
opts.GetOption(config.numCores, "6", '-', "num-cores");
opts.GetOption(config.errCon,"0",'-',"err-con");
opts.GetOption(config.rankGood,"0",'-',"rank-good");
opts.GetOption(config.pivot,"0",'-',"pivot");
opts.GetOption(help, "false", 'h', "help");
opts.GetOption(config.isThumbnail, "false", '-', "thumbnail");
opts.GetOption(config.use_hard_est, "false",'-', "use-hard-est");
opts.GetOption(config.t0_hard, "0", '-', "t0-hard");
opts.GetOption(config.tmid_hard, "0", '-', "tmid-hard");
opts.GetOption(config.sigma_hard, "0", '-', "sigma-hard");
opts.GetOption(config.row_step, "100", '-', "row-step");
opts.GetOption(config.col_step, "100", '-', "col-step");
opts.GetOption(config.bg_param, "", '-', "region-param");
opts.GetOption(config.grind_acq_0, "0", '-', "grind-acq0");
if(help || inputDir.empty() || outputDir.empty()) {
usage();
}
char *explog_path = NULL;
explog_path = MakeExpLogPathFromDatDir(inputDir.c_str());
int numFlows = config.numFlows;
if (numFlows < 0) {
numFlows = GetTotalFlows(explog_path);
}
// Check and setup our compression type
TraceChunkSerializer serializer;
serializer.SetRecklessAbandon(true);
if (config.compressionType == "svd") {
SvdDatCompress *dc = new SvdDatCompress(config.precision, config.numEvec);
serializer.SetCompressor(dc);
cout << "Doing lossy svd compression. (" << serializer.GetCompressionType() << ")" << endl;
}
// else if (config.compressionType == "svd+") {
// SvdDatCompressPlus *dc = new SvdDatCompressPlus();
// serializer.SetCompressor(dc);
// cout << "Doing lossy svd compression. (" << serializer.GetCompressionType() << ")" << endl;
// }
// else if (config.compressionType == "svd++") {
// SvdDatCompressPlusPlus *dc = new SvdDatCompressPlusPlus();
// if (config.errCon >0 )
// dc->SetErrCon(config.errCon);
// if (config.rankGood > 0 )
// dc->SetRankGood(config.rankGood);
// if (config.pivot > 0)
// dc->SetPivot(config.pivot);
// serializer.SetCompressor(dc);
// cout << "Doing lossy svd compression for good traces and delta for bad ones. (" << serializer.GetCompressionType() << ")" << endl;
// }
else if (config.compressionType == "delta") {
VencoLossless *venco = new VencoLossless();
serializer.SetCompressor(venco);
cout << "Doing lossless delta compression. (" << serializer.GetCompressionType() << ")" << endl;
}
else if (config.compressionType == "delta-plain") {
DeltaComp *delta = new DeltaComp();
serializer.SetCompressor(delta);
cout << "Doing lossless delta plain compression. (" << serializer.GetCompressionType() << ")" << endl;
}
else if (config.compressionType == "delta-plain-fst") {
DeltaCompFst *delta = new DeltaCompFst();
serializer.SetCompressor(delta);
cout << "Doing lossless delta plain fast compression. (" << serializer.GetCompressionType() << ")" << endl;
}
else if (config.compressionType == "delta-plain-fst-smx") {
DeltaCompFstSmX *delta = new DeltaCompFstSmX();
serializer.SetCompressor(delta);
cout << "Doing lossless delta plain fast compression. (" << serializer.GetCompressionType() << ")" << endl;
}
else if (config.compressionType == "none") {
TraceCompressor *vanilla = new TraceNoCompress();
serializer.SetCompressor(vanilla);
cout << "Doing no compression. (" << serializer.GetCompressionType() << ")" << endl;
}
else {
ION_ABORT("Don't recognize compression type: " + config.compressionType);
}
const char *id = GetChipId(explog_path);
if (explog_path) free (explog_path);
ChipIdDecoder::SetGlobalChipId(id);
ImageTransformer::CalibrateChannelXTCorrection(inputDir.c_str(), "lsrowimage.dat");
Image bfImg1;
string bfFile = inputDir + "/beadfind_pre_0003.dat";
bfImg1.LoadRaw(bfFile.c_str());
//.........这里部分代码省略.........
示例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: main
int main(int argc, const char *argv[])
{
OptArgs opts;
opts.ParseCmdLine(argc, argv);
bool help, combineSffs;
string sffFile;
string bamFile;
vector<string> infiles;
opts.GetOption(help,"false", 'h', "help");
opts.GetOption(combineSffs,"false", 'c', "combine-sffs");
opts.GetOption(bamFile,"",'o',"out-filename");
opts.GetLeftoverArguments(infiles);
if(help || infiles.empty())
{
usage();
}
if((!combineSffs) && infiles.size() > 1)
{
cerr << "sff2bam ERROR: if you want to combine all sff files into a single bam file, please use option -c true." << endl;
usage();
}
sffFile= infiles.front();
if(bamFile.length() < 1)
{
bamFile = sffFile.substr(0, sffFile.length() - 3);
bamFile += "bam";
}
sff_file_t* sff_file = sff_fopen(sffFile.c_str(), "r", NULL, NULL);
if(!sff_file)
{
cerr << "sff2bam ERROR: fail to open " << sffFile << endl;
exit(1);
}
// All sff files must have the same flow and key
if(combineSffs && infiles.size() > 1)
{
for(size_t n = 1; n < infiles.size(); ++n)
{
sff_file_t* sff_file2 = sff_fopen(infiles[n].c_str(), "r", NULL, NULL);
if(!sff_file2)
{
sff_fclose(sff_file);
cerr << "sff2bam ERROR: fail to open " << infiles[n] << endl;
exit(1);
}
if(strcmp(sff_file2->header->flow->s, sff_file->header->flow->s) != 0 ||
strcmp(sff_file2->header->key->s, sff_file->header->key->s) != 0)
{
sff_fclose(sff_file);
sff_fclose(sff_file2);
cerr << "sff2bam ERROR: " << sffFile << " and " << infiles[n] << " have different flows or keys." << endl;
exit(1);
}
sff_fclose(sff_file2);
}
}
sff_t* sff = NULL;
// Open 1st read for read group name
sff = sff_read(sff_file);
if(!sff)
{
sff_fclose(sff_file);
cerr << "sff2bam ERROR: fail to read " << sffFile << endl;
exit(1);
}
// Set up BAM header
SamHeader sam_header;
sam_header.Version = "1.4";
sam_header.SortOrder = "unsorted";
SamProgram sam_program("sff2bam");
sam_program.Name = "sff2bam";
sam_program.Version = SFF2BAM_VERSION;
sam_program.CommandLine = "sff2bam";
sam_header.Programs.Add(sam_program);
string rgname = sff->rheader->name->s;
int index = rgname.find(":");
rgname = rgname.substr(0, index);
SamReadGroup read_group(rgname);
read_group.FlowOrder = sff->gheader->flow->s;
read_group.KeySequence = sff->gheader->key->s;
sam_header.ReadGroups.Add(read_group);
RefVector refvec;
BamWriter bamWriter;
bamWriter.SetCompressionMode(BamWriter::Compressed);
//.........这里部分代码省略.........
示例9: main
int main (int argc, const char *argv[])
{
if (argc == 1) {
printf ("BaseCallerLite - Bare bone basecaller\n");
printf ("\n");
printf ("Usage:\n");
printf ("BaseCallerLite [options]\n");
printf ("\tOptions:\n");
printf ("\t\tComing soon\n");
printf ("\n");
return 1;
}
string libKey = "TCAG";
string inputDirectory = ".";
string outputDirectory = ".";
bool singleCoreCafie = false;
BaseCallerLite basecaller;
basecaller.regionXSize = 50;
basecaller.regionYSize = 50;
basecaller.runId = "BCLTE";
basecaller.CF = 0.0;
basecaller.IE = 0.0;
basecaller.numWellsCalled = 0;
basecaller.nextRegionX = 0;
basecaller.nextRegionY = 0;
OptArgs opts;
opts.ParseCmdLine(argc, argv);
opts.GetOption(basecaller.CF, "0.0", '-', "cf");
opts.GetOption(basecaller.IE, "0.0", '-', "ie");
opts.GetOption(inputDirectory, ".", '-', "input-dir");
opts.GetOption(outputDirectory, ".", '-', "output-dir");
opts.GetOption(singleCoreCafie, "false", '-', "singlecorecafie");
int numWorkers = 2*numCores();
if (singleCoreCafie)
numWorkers = 1;
Mask mask (1, 1);
if (mask.SetMask ((inputDirectory + "/bfmask.bin").c_str()))
exit (EXIT_FAILURE);
RawWells wells (inputDirectory.c_str(),"1.wells");
//SetWellsToLiveBeadsOnly(wells,&mask);
wells.OpenForIncrementalRead();
basecaller.maskPtr = &mask;
basecaller.wellsPtr = &wells;
basecaller.rows = mask.H();
basecaller.cols = mask.W();
basecaller.flowOrder.SetFlowOrder(wells.FlowOrder(), wells.NumFlows());
basecaller.numFlows = wells.NumFlows();
basecaller.numRegionsX = (basecaller.cols + basecaller.regionXSize - 1) / basecaller.regionXSize;
basecaller.numRegionsY = (basecaller.rows + basecaller.regionYSize - 1) / basecaller.regionYSize;
basecaller.numRegions = basecaller.numRegionsX * basecaller.numRegionsY;
basecaller.libKeyFlows.assign(basecaller.numFlows,0);
basecaller.libNumKeyFlows = basecaller.flowOrder.BasesToFlows(libKey, &basecaller.libKeyFlows[0], basecaller.numFlows);
basecaller.libSFF.Open(outputDirectory+"/rawlib.sff", basecaller.numRegions,
basecaller.flowOrder, libKey);
time_t startBasecall;
time(&startBasecall);
pthread_mutex_init(&basecaller.wellsAccessMutex, NULL);
pthread_t worker_id[numWorkers];
for (int iWorker = 0; iWorker < numWorkers; iWorker++)
if (pthread_create(&worker_id[iWorker], NULL, BasecallerWorkerWrapper, &basecaller)) {
printf("*Error* - problem starting thread\n");
return 1;
}
for (int iWorker = 0; iWorker < numWorkers; iWorker++)
pthread_join(worker_id[iWorker], NULL);
pthread_mutex_destroy(&basecaller.wellsAccessMutex);
time_t endBasecall;
time(&endBasecall);
basecaller.libSFF.Close();
printf("\nBASECALLING: called %d of %d wells in %1.1f seconds with %d threads\n",
basecaller.numWellsCalled, basecaller.rows*basecaller.cols, difftime(endBasecall,startBasecall), numWorkers);
printf("Generated library SFF with %d reads\n", basecaller.libSFF.num_reads());
return 0;
}
示例10: main
int main(int argc, const char *argv[]) {
OptArgs opts;
opts.ParseCmdLine(argc, argv);
string regionFile;
vector<string> matchStrings;
vector<string> datFiles;
int maskCenter = MaskEmpty;
int maskMatch = MaskLive | MaskBead | MaskDud;
string maskFile;
string outPrefix;
bool setHex;
int frameStart,frameEnd;
bool help;
bool useDuds;
int optCenter, optMatch;
opts.GetOption(help, "false", 'h', "help");
opts.GetOption(regionFile, "", '-', "region-file");
opts.GetOption(datFiles, "", '-', "dat-files");
opts.GetOption(matchStrings, "", '-', "matches");
opts.GetOption(outPrefix, "", '-', "out-prefix");
opts.GetOption(useDuds, "", '-', "use-duds");
opts.GetOption(maskFile, "", '-', "mask-file");
opts.GetOption(frameStart, "14", '-', "frame-start");
opts.GetOption(frameEnd, "20", '-', "frame-end");
opts.GetOption(optCenter, "0", '-', "center");
opts.GetOption(optMatch, "0", '-', "match");
opts.GetOption(setHex, "false", '-', "set-hex");
if (useDuds) {
maskMatch = MaskDud;
}
else if (optMatch != 0) {
maskMatch = optMatch;
}
if (optCenter != 0) {
maskCenter = optCenter;
}
vector<Traces> flows;
vector<struct Region> regions;
cout << "Loading mask." << endl;
Mask mask(maskFile.c_str());
mask.SetHex(setHex);
for (size_t i = 0; i < matchStrings.size(); i++) {
ION_ASSERT(matchStrings[i].length() == matchStrings[0].length(), "Match strings must match in length.");
}
cout << "Loading regions." << endl;
LoadRegions(regionFile, regions);
cout << "Loading traces." << endl;
LoadTraces(mask, datFiles, flows);
for (size_t i = 0; i < matchStrings.size(); i++) {
cout << "Using frame num: " << frameStart << " to " << frameEnd << " for match string: " << matchStrings[i] << endl;
ParseMetrics(matchStrings[i], i, mask, maskCenter, maskMatch, regions, flows, outPrefix, frameStart, frameEnd);
}
cout << "Saw: " << centerSeen << " wells and: " << haystackNeg << " negatives." << endl;
}
示例11: RetrieveParameterVectorDouble
int RetrieveParameterVectorDouble(OptArgs &opts, Json::Value& json, char short_name, const string& long_name_hyphens, const string& default_value, vector<double>& ret_vector)
{
string long_name_underscores = GetRidOfDomainAndHyphens(long_name_hyphens);
string value = default_value;
if(value.length() > 0)
{
vector<string> words;
split(value,',',words);
ret_vector.clear();
for (size_t i = 0; i < words.size(); i++) {
char *end;
int err = errno;
errno = 0;
ret_vector.push_back(strtod(words[i].c_str(), &end));
if (errno != 0 || *end != '\0') {
cout << "Error converting: " + words[i] + " to an double for option: " + long_name_hyphens << endl;
return errno;
}
errno = err;
}
}
string source = "builtin default";
if (json.isMember(long_name_underscores)) {
ret_vector.clear();
size_t sz = json[long_name_underscores].size();
char buf[1000];
if(sz > 0)
{
if(sz == 1)
{
if(json[long_name_underscores][0].isString())
{
ret_vector.push_back(atof(json[long_name_underscores][0].asCString()));
value = json[long_name_underscores][0].asCString();
}
else
{
ret_vector.push_back(json[long_name_underscores][0].asDouble());
sprintf(buf, "%f", ret_vector[0]);
value = buf;
}
}
else
{
value = "";
for(int i = 0; i < (int)sz - 1; i++)
{
if(json[long_name_underscores][i].isString())
{
ret_vector.push_back(atof(json[long_name_underscores][i].asCString()));
value += json[long_name_underscores][i].asCString();
value += ",";
}
else
{
ret_vector.push_back(json[long_name_underscores][i].asDouble());
sprintf(buf, "%f,", ret_vector[i]);
string ss = buf;
value += ss;
}
}
if(json[long_name_underscores][(int)sz - 1].isString())
{
ret_vector.push_back(atof(json[long_name_underscores][(int)sz - 1].asCString()));
value += json[long_name_underscores][(int)sz - 1].asCString();
}
else
{
ret_vector.push_back(json[long_name_underscores][(int)sz - 1].asDouble());
sprintf(buf, "%f", ret_vector[(int)sz - 1]);
string ss = buf;
value += ss;
}
}
source = "parameters json file";
}
}
if (opts.HasOption(short_name, long_name_hyphens)) {
ret_vector.clear();
opts.GetOption(ret_vector, default_value, short_name, long_name_hyphens);
char buf[1000];
if(ret_vector.empty())
{
cout << "Error setting: there is no value set for option: " + long_name_hyphens << endl;
return 1;
}
else if(ret_vector.size() == 1)
{
sprintf(buf, "%f", ret_vector[0]);
value = buf;
}
else
{
value = "";
for(size_t i = 0; i < ret_vector.size() - 1; i++) {
//.........这里部分代码省略.........
示例12: main
int main(int argc, const char *argv[]) {
OptArgs opts;
string position_file;
string h5file_in;
string source;
string h5file_out;
string destination;
string positions_file;
bool help;
string flowlimit_arg;
unsigned int flowlimit;
vector<string>otherArgs;
DumpStartingStateOfExtractWells (argc,argv);
opts.ParseCmdLine(argc, argv);
opts.GetOption(h5file_in, "", 'i', "input");
opts.GetOption(source, "", 's', "source");
opts.GetOption(h5file_out, "", 'o', "output");
opts.GetOption(destination, "", 'd', "destination");
opts.GetOption(flowlimit_arg, "", 'f', "flowlimit");
opts.GetOption(positions_file, "", 'p', "positions");
opts.GetOption(help, "false", 'h', "help");
opts.GetLeftoverArguments(otherArgs);
// input data processing
string line;
vector<size_t> row_val;
vector<size_t> col_val;
ifstream filestream;
if ( ! positions_file.empty() )
filestream.open(&positions_file.At(0));
istream &input = ( filestream.is_open() ) ? filestream : cin;
while ( getline(input, line) )
{
int num = -1;
vector<size_t> ints;
istringstream ss(line);
while ( ss >> num && ints.size() < 2 ) {
if (num < 0) {
fprintf(stderr, "Found negative integer %d\n", num);
exit(-1);
}
else
ints.push_back((size_t)num);
}
if (ints.size() != 2) {
fprintf(stderr, "Found %d integers in %s, expected 2\n", (int)ints.size(), &line[0]);
continue;
}
row_val.push_back(ints.at(0));
col_val.push_back(ints.at(1));
}
if (row_val.size() == 0 ) {
fprintf(stdout, "No positions to extract, check input\n");
exit(0);
}
vector<size_t>input_positions(row_val.size(), 0);
int numCPU = (int)sysconf( _SC_NPROCESSORS_ONLN );
int numThreads = MAXTHREADS < numCPU ? MAXTHREADS : numCPU;
fprintf(stdout, "Using %d threads of %d cores\n", numThreads, numCPU);
if (source.empty())
source = source + SIGNAL_IN;
H5ReplayReader reader = H5ReplayReader(h5file_in, &source[0]);
if ( h5file_out.empty() )
h5file_out = h5file_out + H5FILE_OUT;
if ( destination.empty() )
destination = destination + SIGNAL_OUT;
reader.Open();
int rank = reader.GetRank();
vector<hsize_t>dims(rank);
vector<hsize_t>chunks(rank);
reader.GetDims(dims);
reader.GetChunkSize(chunks);
reader.Close();
// convert input row, col positions to indices
for (hsize_t i=0; i<input_positions.size(); i++)
input_positions.At(i) = RowColToIndex(row_val.At(i), col_val.At(i), dims.At(0), dims.At(1));
sort(input_positions.begin(), input_positions.end());
fprintf(stdout, "Opened for read %s:%s with rank %d, row x col x flow dims=[ ", &h5file_in[0], &source[0], rank);
for (int i=0; i<rank; i++)
fprintf(stdout, "%d ", (int)dims.At(i));
fprintf(stdout, "], chunksize=[ ");
for (int i=0; i<rank; i++)
fprintf(stdout, "%d ", (int)chunks.At(i));
fprintf(stdout, "]\n");
H5ReplayRecorder recorder = H5ReplayRecorder(h5file_out, &destination[0],reader.GetType(),2);
recorder.CreateFile();
//.........这里部分代码省略.........
示例13: 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;
}
}
}
//.........这里部分代码省略.........
示例14: 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);
}
//.........这里部分代码省略.........
示例15: main
int main(int argc, const char *argv[]) {
OptArgs opts;
string h5file;
string source;
string destination;
vector<string> infiles;
bool help;
string flowlimit_arg;
unsigned int flowlimit;
DumpStartingStateOfNormWells (argc,argv);
opts.ParseCmdLine(argc, argv);
opts.GetOption(h5file, "", '-', "h5file");
opts.GetOption(source, "", 's', "source");
opts.GetOption(destination, "", 'd', "destination");
opts.GetOption(flowlimit_arg, "", 'f', "flowlimit");
opts.GetOption(help, "false", 'h', "help");
opts.GetLeftoverArguments(infiles);
if(help || infiles.empty() || (infiles.size() > 1) ) {
usage();
}
h5file = infiles.front();
int numCPU = (int)sysconf( _SC_NPROCESSORS_ONLN );
int numThreads = MAXTHREADS < numCPU ? MAXTHREADS : numCPU;
fprintf(stdout, "Using %d threads of %d cores\n", numThreads, numCPU);
if (source.empty())
source = source + SIGNAL_IN;
H5ReplayReader reader = H5ReplayReader(h5file, &source[0]);
if ( destination.empty() )
destination = destination + SIGNAL_OUT;
H5ReplayRecorder recorder = (source.compare(destination)==0)
? H5ReplayRecorder(h5file, &destination[0])
: H5ReplayRecorder(h5file, &destination[0],reader.GetType(),reader.GetRank());
reader.Open();
int rank = reader.GetRank();
vector<hsize_t>dims(rank,0);
vector<hsize_t>chunks(rank,0);
reader.GetDims(dims);
reader.GetChunkSize(chunks);
reader.Close();
fprintf(stdout, "Opening for read %s:%s with rank %d, row x col x flow dims=[ ", &h5file[0], &source[0], rank);
for (int i=0; i<rank; i++)
fprintf(stdout, "%d ", (int)dims[i]);
fprintf(stdout, "], chunksize=[ ");
for (int i=0; i<rank; i++)
fprintf(stdout, "%d ", (int)chunks[i]);
fprintf(stdout, "]\n");
if (flowlimit_arg.empty())
flowlimit = dims[2];
else
flowlimit = atoi(flowlimit_arg.c_str());
flowlimit = (flowlimit < dims[2]) ? flowlimit : dims[2];
fprintf(stdout, "Using %u flows\n", flowlimit);
// hard code region size to be at least 100x100
chunks[0] = (chunks[0] < 100) ? 100 : chunks[0];
chunks[1] = (chunks[1] < 100) ? 100 : chunks[1];
recorder.CreateDataset(chunks);
int max_threads_ever = (dims[0]/chunks[0] +1)*(dims[1]/chunks[1] +1);
thread_flags.resize (max_threads_ever, 0);
// fprintf(stdout, "max_threads_ever = %d\n", max_threads_ever);
unsigned int thread_id = 0;
vector<compute_norm_args> my_args( max_threads_ever );
// layout is rows x cols x flows
for (hsize_t row=0; row<dims[0]; ) {
for (hsize_t col=0; col<dims[1]; ) {
pthread_t thread;
int thread_status;
assert( thread_id < thread_flags.size() );
my_args.at(thread_id).row = row;
my_args.at(thread_id).col = col;
my_args.at(thread_id).chunks = &chunks;
my_args.at(thread_id).dims = &dims;
my_args.at(thread_id).h5file = &h5file;
my_args.at(thread_id).source = &source;
my_args.at(thread_id).destination = &destination;
my_args.at(thread_id).thread_id = thread_id;
my_args.at(thread_id).flowlimit = flowlimit;
fprintf(stdout, "creating thread %d from row=%d (max %d), column=%d (max %d)\n", thread_id, (int)row, (int)dims[0], (int)col, (int)dims[1]);
while (accumulate(thread_flags.begin(), thread_flags.end(), 0) > numThreads) {
// only have to be approximate, don't worry about races
// fprintf(stdout, "Sleeping ...\n");
sleep(1);
}
thread_flags[thread_id] = 1;
thread_status = pthread_create(&thread, NULL, compute_norm, (void *)&my_args[thread_id]);
// compute_norm((void *)&my_args[thread_id]);
//.........这里部分代码省略.........