bool OctreePacketData::appendValue(const QByteArray& bytes) { // TODO: make this a ByteCountCoded leading byte uint16_t length = bytes.size(); bool success = appendValue(length); if (success) { success = appendRawData((const unsigned char*)bytes.constData(), bytes.size()); } return success; }
bool OctreePacketData::appendValue(const QString& string) { // TODO: make this a ByteCountCoded leading byte uint16_t length = string.size() + 1; // include NULL bool success = appendValue(length); if (success) { success = appendRawData((const unsigned char*)qPrintable(string), length); } return success; }
bool Table::readFromStream(std::istream *dataStream) { std::string inputLine; size_t left = 0, right = 0; unsigned int rowIndex, columnIndex; // First, determine the number of columns: std::getline(*dataStream, inputLine, '\n'); m_columnCount = (unsigned int)(std::count(inputLine.begin(), inputLine.end(), '\t') + 1); // Create column objects: for (columnIndex = 0; columnIndex < m_columnCount; columnIndex++) { push_back(new Column(columnIndex)); } // Jump to the beginning of the file: dataStream->seekg(0); for (rowIndex = 0; !dataStream->eof(); rowIndex++) { //if (rowIndex % 1000 == 0) // std::cout << "Reading row: " << rowIndex << std::endl; // Read next input line: std::getline(*dataStream, inputLine, '\n'); if (dataStream->eof()) break; left = 0; for (columnIndex = 0; (right = inputLine.find('\t', left)) != std::string::npos && columnIndex < m_columnCount; columnIndex++) { appendValue(inputLine.substr(left, right-left), columnIndex); left = right+1; } appendValue(inputLine.substr(left, std::string::npos), columnIndex); } m_rowCount = rowIndex; return true; }
int getSVLen(seqan::CharString const & str) { seqan::DirectionIterator<seqan::CharString const, seqan::Input>::Type inputIter = directionIterator(str, seqan::Input()); // Parse out key/value pairs and interpret SVLEN. seqan::CharString key, val; enum { IN_KEY, IN_VALUE } state = IN_KEY; for (; !atEnd(inputIter); ++inputIter) { if (*inputIter == '=') { state = IN_VALUE; continue; } else if (*inputIter == ';') { if (key == "SVLEN") return seqan::lexicalCast<int>(val); clear(val); clear(key); state = IN_KEY; continue; } else if (state == IN_KEY) { appendValue(key, *inputIter); } else // (state == IN_VALUE) { appendValue(val, *inputIter); } } if (key == "SVLEN") return seqan::lexicalCast<int>(val); SEQAN_FAIL("Missing INFO SVLEN %s", toCString(str)); return 0; }
bool OctreePacketData::appendValue(const QVector<float>& value) { uint16_t qVecSize = value.size(); bool success = appendValue(qVecSize); if (success) { success = append((const unsigned char*)value.constData(), qVecSize * sizeof(float)); if (success) { _bytesOfValues += qVecSize * sizeof(float); _totalBytesOfValues += qVecSize * sizeof(float); } } return success; }
void CLIPSExtractValueInstructionBuilder::addFields(ExtractValueInst* inst, KnowledgeConstruction *kc, char* parent) { CLIPSUnaryInstructionBuilder::addFields((UnaryInstruction*)inst, kc, parent); addField("AggregateOperand", kc->route(inst->getAggregateOperand(), getNamer())); openField("Indices"); for(ExtractValueInst::idx_iterator i = inst->idx_begin(), e = inst->idx_end(); i != e; ++i) { char* buf = CharBuffer(32); sprintf(buf, "%d", *i); appendValue(buf); free(buf); } closeField(); }
void CLIPSBasicBlockBuilder::addFields(BasicBlock* bb, KnowledgeConstructor *kc, char* parent, bool constructInstructions) { CLIPSValueBuilder::addFields((Value*)bb, kc, parent); char* name = (char*)bb->getName().data(); FunctionNamer& namer = getNamer(); namer.registerBasicBlock(name); if(bb->isLandingPad()) addTrueField("IsLandingPad"); if(bb->hasAddressTaken()) addTrueField("HasAddressTaken"); pred_iterator pi = pred_begin(bb), pe = pred_end(bb); if(pi != pe) { openField("Predecessors"); for(; pi != pe; ++pi) { BasicBlock* pred = *pi; appendValue(pred->getName()); } closeField(); } succ_iterator si = succ_begin(bb), se = succ_end(bb); if(si != se) { openField("Successors"); for(; si != se; ++si) { BasicBlock* succ = *si; appendValue(succ->getName()); } closeField(); } if(constructInstructions && !bb->empty()) { std::string tmp; raw_string_ostream data(tmp); openField("contents"); for(BasicBlock::iterator i = bb->begin(), e = bb->end(); i != e; ++i) { Instruction* inst = i; std::string res = kc->route(inst, namer, name); appendValue(res); data << " " << res; } closeField(); addField("Produces", data.str()); } }
void print(TText const & score, MaxOnly const & /*tag*/) { int maxScore = score[0]; seqan::String<int> output; appendValue(output, 0); for (unsigned i = 1; i < seqan::length(score); ++i) { if (score[i] > maxScore) { maxScore = score[i]; clear(output); resize(output, 1, i); } else if (score[i] == maxScore) { appendValue(output, i); } } for (unsigned i = 0; i < seqan::length(output); ++i) std::cout << output[i] << " "; std::cout << std::endl; }
void IntersectBed::writeEmptyBed(seqan::BedRecord<seqan::Bed6> const & bedRecord) { seqan::RoiRecord roiRecord; roiRecord.ref = bedRecord.ref; roiRecord.beginPos = bedRecord.beginPos; roiRecord.endPos = bedRecord.endPos; roiRecord.strand = bedRecord.strand; roiRecord.name = bedRecord.name; roiRecord.len = roiRecord.endPos - roiRecord.beginPos; roiRecord.countMax = 0; for (int i = 0; i < (int)roiRecord.len; ++i) appendValue(roiRecord.count, 0); writeRecord(roiFileOut, roiRecord); }
/***************************************************************************** Clone this linked list of values and return the new one. @param { ValueP } list to the first Value in the list @return { ValueP } new list of clones *****************************************************************************/ ValueP cloneValues( ValueP list ){ ValueP newList; /* pointer to the currect value */ newList = NULL; ValueP newNode; /* pointer to the result, found or created */ newNode = NULL; /* search the list first */ while( list ){ newNode = newValue( list->letter, list->attribute ); newNode->count = list->count; newList = appendValue( newList, newNode ); list = list->next; } return newList; } /* end cloneValues */
String SVGParsingError::format(const String& tagName, const QualifiedName& name, const AtomicString& value) const { StringBuilder builder; appendErrorContextInfo(builder, tagName, name); builder.append(": "); if (hasLocus() && locus() == value.length()) builder.append("Unexpected end of attribute. "); auto message = messageForStatus(status()); builder.append(message.first); appendValue(builder, *this, value); builder.append(message.second); return builder.toString(); }
/**Moves the entry in the line edit new2Add_edit to the * listbox toAdd_List, expanding any run number lists */ void SANSAddFiles::add2Runs2Add() { // split comma separated file names or run numbers into a list ArrayProperty<std::string> commaSep( "unusedName", m_SANSForm->new2Add_edit->text().toStdString()); const std::vector<std::string> nam = commaSep; for (std::vector<std::string>::const_iterator i = nam.begin(); i != nam.end(); ++i) { // each comma separated item could be a range of run numbers // specified with a ':' or '-' QStringList ranges; std::vector<int> runNumRanges; try { // if the entry is in the form 454:456, runNumRanges will be filled // with the integers ({454, 455, 456}) otherwise it will throw appendValue(*i, runNumRanges); std::vector<int>::const_iterator num = runNumRanges.begin(); for (; num != runNumRanges.end(); ++num) { ranges.append(QString::number(*num)); } } catch (boost::bad_lexical_cast &) { // this means that we don't have a // list of integers, treat it as full // (and valid) filename ranges.append(QString::fromStdString(*i)); } for (QStringList::const_iterator k = ranges.begin(); k != ranges.end(); ++k) { // Don't display the full file path in the box, it's too long QListWidgetItem *newL = insertListFront(QFileInfo(*k).fileName()); newL->setData(Qt::WhatsThisRole, QVariant(*k)); // Put the full path in the tooltip so people can see it if they want to // do this with the file finding functionality of the FileProperty FileProperty search("dummy", k->toStdString(), FileProperty::Load, std::vector<std::string>(), Direction::Input); if (search.isValid() == "") { // this means the file was found newL->setToolTip(QString::fromStdString(search.value())); // If we don't have an event workspace data set, then we disable the // event options if (!isEventWorkspace(QString::fromStdString(search.value()))) { setBinningOptions(false); } } } } m_SANSForm->new2Add_edit->clear(); }
bool getGappedParamsRecords(seqan::String<GappedParamsRecord> & records, unsigned n, char errorModel) { if (n < 15u || n > 75u) return false; // We do not have parameter for these settings. if (errorModel != 'L' && errorModel != 'H') return false; // Invalid error model. // We can iterate until readLength == 0 since the generator script creates // a terminator record with this property and read length 0 does not make // sense otherwise. for (unsigned i = 0; RECORDS[i].readLength != 0; ++i) if (RECORDS[i].readLength == n && RECORDS[i].type == errorModel) appendValue(records, RECORDS[i]); return true; }
void ProjectSplicedRoi::_updateRanges(seqan::GffRecord const & record, seqan::Segment<seqan::CharString, seqan::InfixSegment> const & name) { if (verbosity >= 3) std::cerr << "Updating " << name << "\t" << record.beginPos << "\t" << record.endPos << "\n"; unsigned idx = 0; if (getIdByName(groupNames, name, idx, groupNamesCache)) { ranges[idx].i1 = std::min(ranges[idx].i1, (int)record.beginPos); ranges[idx].i2 = std::max(ranges[idx].i2, (int)record.endPos); } else { idx = length(groupNames); appendName(groupNames, name, groupNamesCache); appendValue(ranges, TIntPair(record.beginPos, record.endPos)); } }
bool OctreePacketData::appendValue(const QVector<glm::quat>& value) { uint16_t qVecSize = value.size(); bool success = appendValue(qVecSize); if (success) { QByteArray dataByteArray(udt::MAX_PACKET_SIZE, 0); unsigned char* start = reinterpret_cast<unsigned char*>(dataByteArray.data()); unsigned char* destinationBuffer = start; for (int index = 0; index < value.size(); index++) { destinationBuffer += packOrientationQuatToBytes(destinationBuffer, value[index]); } int quatsSize = destinationBuffer - start; success = append(start, quatsSize); if (success) { _bytesOfValues += quatsSize; _totalBytesOfValues += quatsSize; } } return success; }
/***************************************************************************** Find an Value with the given attribute [column] and letter [class value] in the list or create a new Value and append it to the list. @param { ValueP, char, int, int } list, letter, attribute pointer to the first Value in the list, boolean for whether it is in the target class @return { ValueP } found the matching Value *****************************************************************************/ ValueP updateValue( ValueP list, char letter, int attribute, int isClass ){ ValueP current; /* pointer to the currect value */ current = list; ValueP found; /* pointer to the result, found or created */ found = NULL; /* search the list first */ while( current && !found ){ if( ( current->letter == letter ) && ( current->attribute == attribute ) ){ found = current; } current = current->next; } if( !found ){ found = newValue( letter, attribute ); list = appendValue( list, found ); } found->count = found->count++; found->classCount += isClass; return( list ); } /* end findValue */
// inserts field into the dataLine at the current position void CSVFile::insertValue (const char *field) { if (curPos == lineLength) { appendValue (field); return; } int size = strlen (field); if (size + lineLength >= LARGE) return; lineLength += size; char temp[LARGE]; strcpy (temp, dataLine+curPos); memcpy (dataLine+curPos, field, size); curPos += size; strcpy (dataLine+curPos, temp); }
void SangerSequencingSimulator::_simulateQualities( TQualities & quals, TCigarString const & cigar, unsigned sampleLength) { clear(quals); unsigned pos = 0; // Position in result. unsigned rPos = 0; // Position in fragment. for (unsigned i = 0; i < length(cigar); ++i) { for (unsigned j = 0; j < cigar[i].count; ++j, ++pos) { double mean = 0.0, stdDev = 0.0; double relPos = 1.0 * rPos / (1.0 * sampleLength); rPos += (cigar[i].operation != 'D'); if (cigar[i].operation == 'D') { continue; // No quality to give out. } else if (cigar[i].operation == 'I' || cigar[i].operation == 'X') { mean = sangerOptions.qualityMatchStartMean + relPos * (sangerOptions.qualityMatchEndMean - sangerOptions.qualityMatchStartMean); stdDev = sangerOptions.qualityMatchStartStdDev + relPos * (sangerOptions.qualityMatchEndStdDev - sangerOptions.qualityMatchStartStdDev); } else // cigar[i].operation == 'M' { mean = sangerOptions.qualityErrorStartMean + relPos * (sangerOptions.qualityErrorEndMean - sangerOptions.qualityErrorStartMean); stdDev = sangerOptions.qualityErrorStartStdDev + relPos * (sangerOptions.qualityErrorEndStdDev - sangerOptions.qualityErrorStartStdDev); } std::normal_distribution<double> dist(mean, stdDev); int q = static_cast<int>(dist(rng)); q = std::max(0, std::min(40, q)); appendValue(quals, (char)('!' + q)); } } }
void CXMLConfig::processTinyXMLOutput(TiXmlNode* node, String path, bool useAsDefault) { if ( !node ) return; switch ( node->Type() ) { case TiXmlNode::DOCUMENT: rmTrailingSlash(path); break; case TiXmlNode::TEXT: rmTrailingSlash(path); appendValue(path, node->ToText()->Value(), useAsDefault); break; default: break; } TiXmlNode* childNode; for ( childNode = node->FirstChild(); childNode != 0; childNode = childNode->NextSibling() ) processTinyXMLOutput(childNode, path + String(node->Value()) + '/', useAsDefault); }
int main() { seqan::StringSet<seqan::CharString> ids; appendValue(ids, "id1"); appendValue(ids, "id2"); seqan::StringSet<seqan::Dna5String> seqs; appendValue(seqs, "CGATCGATCGAT"); appendValue(seqs, "AAAAAAAAAAAA"); seqan::StringSet<seqan::CharString> quals; appendValue(quals, "IIIIIIIIIHII"); appendValue(quals, "IIIIIIIIIHII"); for (unsigned i = 0; i < length(ids); ++i) if (seqan::writeRecord(std::cout, ids[i], seqs[i], quals[i], seqan::Fastq()) != 0) return 1; // Error writing. return 0; }
//initialize List of contingency tables (one for every kmer) void initializeCont (seqan::StringSet<seqan::DnaString> kmers, Contingency & allContigs){ // //Contingeny table for finding of one single kmer to store intermediate results // Contingency oneContig; unsigned l; l=length(kmers); //mock vector for mRNA IDs std::vector<int> mock; mock.push_back(-1); //reserve space allContigs.kmerDN.reserve(l); allContigs.kmerNoDN.reserve(l); allContigs.noKmerDN.reserve(l); allContigs.noKmerNoDN.reserve(l); allContigs.idNoDN.reserve(l); allContigs.idDN.reserve(l); //Initialize list of Contingency table for all the kmers for (unsigned i=0; i<l; i++){ appendValue(allContigs.kmerSeq, ""); allContigs.kmerDN.push_back(0); allContigs.kmerNoDN.push_back(0); allContigs.noKmerDN.push_back(0); allContigs.noKmerNoDN.push_back(0); //initialize ID Lists for the mRNAs, in which the kmer was found with -1, since there is no mRNA with rank -1 allContigs.idNoDN.push_back(mock); allContigs.idDN.push_back(mock); } //assign the kmer to the position in the Contingencies Table for (unsigned j=0; j<l; j++){ if (length(getValue(allContigs.kmerSeq, kmerToID(getValue(kmers, j))))>0){ std::cerr << "kmer already set" << '\n'; std::cerr << getValue(allContigs.kmerSeq, kmerToID(getValue(kmers, j)))<< '\n'; return; } else {assignValue(allContigs.kmerSeq, kmerToID(getValue(kmers, j)), getValue(kmers, j));} } }
int main() { seqan::GffStream out("-", seqan::GffStream::WRITE); // Add sequence names. addSequenceName(out, "ctg123"); // Write out the records. seqan::GffRecord record; record.rID = 0; record.source = ""; record.type = "gene"; record.beginPos = 999; record.endPos = 9000; record.strand = '+'; record.score = seqan::GffRecord::INVALID_SCORE(); appendValue(record.tagName, "ID"); appendValue(record.tagValue, "gene0001"); appendValue(record.tagName, "Name"); appendValue(record.tagValue, "EDEN"); if (writeRecord(out, record) != 0) std::cerr << "ERROR: Problem writing output file."; clear(record.tagName); clear(record.tagValue); record.rID = 0; record.source = ""; record.type = "TF_binding_site"; record.beginPos = 999; record.endPos = 1012; record.strand = '+'; record.score = seqan::GffRecord::INVALID_SCORE(); appendValue(record.tagName, "Parent"); appendValue(record.tagValue, "gene0001"); if (writeRecord(out, record) != 0) std::cerr << "ERROR: Problem writing output file."; return 0; }
void CBWinProject::addLibrary(string libraryName, LibType libType) { ofLogNotice() << "adding library " << libraryName; appendValue(doc, "Add", "library", libraryName, true); // overwriteMultiple for a lib if it's there (so libsorder.make will work) // this is because we might need to say libosc, then ws2_32 }
void CBWinProject::addInclude(string includeName) { ofLogNotice() << "adding include " << includeName; appendValue(doc, "Add", "directory", includeName); }
void CBWinProject::addSrc(string srcName, string folder, SrcType type) { pugi::xml_node node = appendValue(doc, "Unit", "filename", srcName); if(!node.empty()) { node.child("Option").attribute("virtualFolder").set_value(folder.c_str()); } }
void OptionsAssigner::appendValue(const std::string &value) { appendValue(Variant(value)); }
void CBWinProject::addLibrary(const LibraryBinary & lib){ appendValue(doc, "Add", "library", lib.path, true); // overwriteMultiple for a lib if it's there (so libsorder.make will work) // this is because we might need to say libosc, then ws2_32 }
void IntersectBed::writeRois(seqan::String<bool> const & bitmap, seqan::String<int> const & counts, int beginPos, // position of bitmap[0] and counts[0] seqan::BedRecord<seqan::Bed6> const & bedRecord) { // We will build a string of ranges in bitmap/counts for writing out. The bitmap is used depending on the // combination mode. typedef seqan::Pair<int, int> TIntPair; seqan::String<TIntPair> pairs; // We also generate the names of the new regions. seqan::StringSet<seqan::CharString> names; switch (options.mode) { case IntersectBedOptions::PROJECTION: // Use BED range only. appendValue(pairs, TIntPair(bedRecord.beginPos - beginPos, bedRecord.endPos - beginPos)); break; case IntersectBedOptions::INTERSECTION: // Search for 0/1 and 1/0 flanks. { bool state = bitmap[0]; int lastFlank = 0; for (unsigned i = 1; i < length(bitmap); ++i) { if (state) { if (!bitmap[i]) // Found a 1/0 flank. { appendValue(pairs, TIntPair(lastFlank, i)); state = false; lastFlank = i; } } else { if (bitmap[i]) // Found a 0/1 flank. { state = true; lastFlank = i; } } } if (state) appendValue(pairs, TIntPair(lastFlank, length(bitmap))); } break; case IntersectBedOptions::UNION: // Use whole range, including overlaps to the left of right. appendValue(pairs, TIntPair(0, length(counts))); break; case IntersectBedOptions::DIFF: SEQAN_FAIL("Difference does not implemented yet!"); break; default: SEQAN_FAIL("Cannot reach here!"); } if (options.verbosity >= 2) std::cerr << "Adding " << length(pairs) << " for BED " << bedRecord.name << "\n"; for (unsigned i = 0; i < length(pairs); ++i) { std::stringstream ss; ss << bedRecord.name << "_" << i; appendValue(names, ss.str()); } seqan::RoiRecord record; for (unsigned i = 0; i < length(pairs); ++i) { clear(record); record.ref = bedRecord.ref; record.beginPos = beginPos + pairs[i].i1; record.endPos = beginPos + pairs[i].i2; record.len = record.endPos - record.beginPos; record.name = names[i]; record.strand = bedRecord.strand; record.countMax = 0; resize(record.count, pairs[i].i2 - pairs[i].i1, 0); for (int k = 0, j = pairs[i].i1; j != pairs[i].i2; ++j, ++k) { record.countMax = std::max(record.countMax, (unsigned)counts[j]); record.count[k] = counts[j]; } writeRecord(roiFileOut, record); } }
int main(int argc, char const ** argv) { double startTime = 0; // Parse command line. FxFaidxOptions options; seqan::ArgumentParser::ParseResult res = parseArgs(options, argc, argv); if (res != seqan::ArgumentParser::PARSE_OK) return res == seqan::ArgumentParser::PARSE_ERROR; // 1 on errors, 0 otherwise // --------------------------------------------------------------------------- // Index I/O // --------------------------------------------------------------------------- // Load index, create if necessary. startTime = sysTime(); seqan::FaiIndex faiIndex; if (load(faiIndex, toCString(options.inFastaPath), toCString(options.inFaiPath)) != 0) { if (options.verbosity >= 2) std::cerr << "Building Index " << options.inFaiPath << " ..."; if (buildIndex(toCString(options.inFastaPath), toCString(options.inFaiPath), seqan::Fai()) != 0) { std::cerr << "Could not build FAI index at " << options.inFaiPath << " for FASTA file " << options.inFastaPath << "\n"; return 1; } if (load(faiIndex, toCString(options.inFastaPath), toCString(options.inFaiPath)) != 0) { std::cerr << "Could not load FAI index we just build.\n"; return 1; } } if (options.verbosity >= 3) std::cerr << "Took " << (startTime - sysTime()) << " s\n"; // --------------------------------------------------------------------------- // Parse and Fetch Regions. // --------------------------------------------------------------------------- if (empty(options.regions)) return 0; // Parse out regions. seqan::String<Region> regions; for (unsigned i = 0; i < length(options.regions); ++i) { Region region; if (!parseRegion(region, options.regions[i])) { std::cerr << "Could not parse region " << options.regions[i] << "\n"; return 1; } unsigned seqId; if (!getIdByName(faiIndex, region.seqName, seqId)) { std::cerr << "Unknown sequence for region " << options.regions[i] << "\n"; return 1; } region.seqId = seqId; if (region.seqId < 0 || (unsigned)region.seqId >= length(faiIndex.indexEntryStore)) { std::cerr << "Invalid region " << options.regions[i] << "\n"; return 1; } appendValue(regions, region); } // Open output file. std::ostream * outPtr = &std::cout; std::ofstream outF; if (!empty(options.outFastaPath)) { outF.open(toCString(options.outFastaPath), std::ios::binary | std::ios::out); if (!outF.good()) { std::cerr << "Could not open output file " << options.outFastaPath << "\n"; return 1; } } // Retrieve output infixes and write to result. for (unsigned i = 0; i < length(regions); ++i) { Region const & region = regions[i]; seqan::CharString id = options.regions[i]; seqan::CharString seq; unsigned beginPos = 0; if (region.beginPos > 0) beginPos = region.beginPos; unsigned endPos = sequenceLength(faiIndex, (unsigned)region.seqId); if (region.endPos > 0 && (unsigned)region.endPos < endPos) endPos = region.endPos; if (beginPos > endPos) endPos = beginPos; getSequenceInfix(seq, faiIndex, region.seqId, beginPos, endPos); if (writeRecord(*outPtr, id, seq, seqan::Fasta()) != 0) { std::cerr << "Could not write infix for region " << options.regions[i] << " to output.\n"; return 1; } } return 0; }
seqan::ArgumentParser::ParseResult parseArgs(SakOptions & options, int argc, char ** argv) { seqan::ArgumentParser parser("sak"); setShortDescription(parser, "Slicing and dicing of FASTA/FASTQ files.."); setVersion(parser, SEQAN_APP_VERSION " [" SEQAN_REVISION "]"); setDate(parser, SEQAN_DATE); setCategory(parser, "Utilities"); addUsageLine(parser, "[\\fIOPTIONS\\fP] [\\fB-o\\fP \\fIOUT.{fa,fq}\\fP] \\fIIN.{fa,fq}\\fP"); addDescription(parser, "\"It slices, it dices and it makes the laundry!\""); addDescription(parser, "Original SAK tool by David Weese. Rewrite by Manuel Holtgrewe."); // The only argument is the input file. addArgument(parser, seqan::ArgParseArgument(seqan::ArgParseArgument::INPUT_FILE, "IN")); // Only FASTA and FASTQ files are allowed as input. setValidValues(parser, 0, seqan::SeqFileIn::getFileExtensions()); // TODO(holtgrew): I want a custom help text! // addOption(parser, seqan::ArgParseOption("h", "help", "This helpful screen.")); addOption(parser, seqan::ArgParseOption("v", "verbose", "Verbose, log to STDERR.")); hideOption(parser, "verbose"); addOption(parser, seqan::ArgParseOption("vv", "very-verbose", "Very verbose, log to STDERR.")); hideOption(parser, "very-verbose"); addSection(parser, "Output Options"); addOption(parser, seqan::ArgParseOption("o", "out-path", "Path to the resulting file. If omitted, result is printed to stdout in FastQ format.", seqan::ArgParseOption::OUTPUT_FILE, "FASTX")); setValidValues(parser, "out-path", seqan::SeqFileOut::getFileExtensions()); addOption(parser, seqan::ArgParseOption("rc", "revcomp", "Reverse-complement output.")); addOption(parser, seqan::ArgParseOption("l", "max-length", "Maximal number of sequence characters to write out.", seqan::ArgParseOption::INTEGER, "LEN")); addSection(parser, "Filter Options"); addOption(parser, seqan::ArgParseOption("s", "sequence", "Select the given sequence for extraction by 0-based index.", seqan::ArgParseOption::INTEGER, "NUM", true)); addOption(parser, seqan::ArgParseOption("sn", "sequence-name", "Select sequence with name prefix being \\fINAME\\fP.", seqan::ArgParseOption::STRING, "NAME", true)); addOption(parser, seqan::ArgParseOption("ss", "sequences", "Select sequences \\fIfrom\\fP-\\fIto\\fP where \\fIfrom\\fP and \\fIto\\fP " "are 0-based indices.", seqan::ArgParseArgument::STRING, "RANGE", true)); addOption(parser, seqan::ArgParseOption("i", "infix", "Select characters \\fIfrom\\fP-\\fIto\\fP where \\fIfrom\\fP and \\fIto\\fP " "are 0-based indices.", seqan::ArgParseArgument::STRING, "RANGE", true)); addOption(parser, seqan::ArgParseOption("ll", "line-length", "Set line length in output file. See section \\fILine Length\\fP for details.", seqan::ArgParseArgument::INTEGER, "LEN", false)); setMinValue(parser, "line-length", "-1"); addTextSection(parser, "Line Length"); addText(parser, "You can use the setting \\fB--line-length\\fP for setting the resulting line length. By default, " "sequences in FASTA files are written with at most 70 characters per line and sequences in FASTQ files are " "written without any line breaks. The quality sequence in FASTQ file is written in the same way as the " "residue sequence."); addText(parser, "The default is selected with a \\fB--line-length\\fP value of \\fI-1\\fP and line breaks can be disabled " "with a value of \\fI0\\fP."); addTextSection(parser, "Usage Examples"); addListItem(parser, "\\fBsak\\fP \\fB-s\\fP \\fI10\\fP \\fIIN.fa\\fP", "Cut out 11th sequence from \\fIIN.fa\\fP and write to stdout as FASTA."); addListItem(parser, "\\fBsak\\fP \\fB-ss\\fP \\fI10-12\\fP \\fB-ss\\fP \\fI100-200\\fP \\fIIN.fq\\fP", "Cut out 11th up to and including 12th and 101th up to and including 199th sequence from \\fIIN.fq\\fP " "and write to stdout as FASTA."); seqan::ArgumentParser::ParseResult res = parse(parser, argc, argv); if (res != seqan::ArgumentParser::PARSE_OK) return res; getArgumentValue(options.inFastxPath, parser, 0); seqan::CharString tmp; getOptionValue(tmp, parser, "out-path"); if (isSet(parser, "out-path")) getOptionValue(options.outPath, parser, "out-path"); if (isSet(parser, "verbose")) options.verbosity = 2; if (isSet(parser, "very-verbose")) options.verbosity = 3; if (isSet(parser, "sequence")) { std::vector<std::string> sequenceIds = getOptionValues(parser, "sequence"); for (unsigned i = 0; i < seqan::length(sequenceIds); ++i) { unsigned idx = 0; if (!seqan::lexicalCast(idx, sequenceIds[i])) { std::cerr << "ERROR: Invalid sequence index " << sequenceIds[i] << "\n"; return seqan::ArgumentParser::PARSE_ERROR; } appendValue(options.seqIndices, idx); } } if (isSet(parser, "sequences")) { std::vector<std::string> sequenceRanges = getOptionValues(parser, "sequences"); seqan::CharString buffer; for (unsigned i = 0; i < seqan::length(sequenceRanges); ++i) { seqan::Pair<uint64_t> range; if (!parseRange(range.i1, range.i2, sequenceRanges[i])) { std::cerr << "ERROR: Invalid range " << sequenceRanges[i] << "\n"; return seqan::ArgumentParser::PARSE_ERROR; } appendValue(options.seqIndexRanges, range); } } if (isSet(parser, "infix")) { seqan::CharString buffer; getOptionValue(buffer, parser, "infix"); if (!parseRange(options.seqInfixBegin, options.seqInfixEnd, buffer)) { std::cerr << "ERROR: Invalid range " << buffer << "\n"; return seqan::ArgumentParser::PARSE_ERROR; } } options.reverseComplement = isSet(parser, "revcomp"); if (isSet(parser, "max-length")) getOptionValue(options.maxLength, parser, "max-length"); if (isSet(parser, "sequence-name")) getOptionValue(options.readPattern, parser, "sequence-name"); getOptionValue(options.seqOutOptions.lineLength, parser, "line-length"); return res; }