seqan::ArgumentParser::ParseResult parseCommandLine(ModifyStringOptions & options, int argc, char const ** argv) { seqan::ArgumentParser parser("fixed_len_trim"); addOption(parser, seqan::ArgParseOption("i", "input-file", "Path to the input file. Supported input: fq, fq.gz, fastq, fastq.gz, fasta, fasta.gz, fa and fa.gz.", seqan::ArgParseArgument::INPUT_FILE, "IN")); setRequired(parser, "input-file"); setShortDescription(parser, "Methylation Tools"); setVersion(parser, "0.0.1"); setDate(parser, "July 2016"); addUsageLine(parser, "-i [input file] -o [output file] -l [trim length]"); addOption(parser, seqan::ArgParseOption("l", "length", "Length to trim to.",seqan::ArgParseArgument::INTEGER, "INT")); setRequired(parser, "l"); addOption(parser, seqan::ArgParseOption("o", "output-file", "Path to the output file. You must include a file extension. Supported output types: fq, fastq, fasta and fa.", seqan::ArgParseArgument::OUTPUT_FILE, "OUT")); setRequired(parser, "o"); addDescription(parser, "Trims your fasta files to a fixed length."); seqan::ArgumentParser::ParseResult res = seqan::parse(parser, argc, argv); // Extract options ONLY if the args are parsed correctly if (res != seqan::ArgumentParser::PARSE_OK) return res; getOptionValue(options.inputFileName, parser, "input-file"); getOptionValue(options.length, parser, "length"); getOptionValue(options.outputFileName, parser, "output-file"); return seqan::ArgumentParser::PARSE_OK; }
seqan::ArgumentParser::ParseResult parseCommandLine(ModifyStringOptions & options, int argc, char const ** argv) { seqan::ArgumentParser parser("w1/(soon w50)_creator"); addOption(parser, seqan::ArgParseOption("i", "input-file", "Path to the input file", seqan::ArgParseArgument::INPUT_FILE, "IN")); setRequired(parser, "input-file"); setShortDescription(parser, "Methylation Tools"); setVersion(parser, "0.0.6"); setDate(parser, "November 2017"); addUsageLine(parser, "-i CX_report.txt [\\fIOPTIONS\\fP] "); addOption(parser, seqan::ArgParseOption("l", "window-length", "Size of window",seqan::ArgParseArgument::INTEGER, "INT")); setDefaultValue(parser, "window-length", "50"); addDescription(parser, "Create a w1 (and soon w50) file from a CX report."); seqan::ArgumentParser::ParseResult res = seqan::parse(parser, argc, argv); // If parsing was not successful then exit with code 1 if there were errors. // Otherwise, exit with code 0 (e.g. help was printed). if (res != seqan::ArgumentParser::PARSE_OK) return res; getOptionValue(options.inputFileName, parser, "input-file"); getOptionValue(options.window_length, parser, "window-length"); return seqan::ArgumentParser::PARSE_OK; }
RKPluginBrowser::RKPluginBrowser (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) { RK_TRACE (PLUGIN); // get xml-helper XMLHelper *xml = XMLHelper::getStaticHelper (); // create and add property addChild ("selection", selection = new RKComponentPropertyBase (this, true)); connect (selection, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (textChanged (RKComponentPropertyBase *))); setRequired (xml->getBoolAttribute (element, "required", true, DL_INFO)); connect (requirednessProperty (), SIGNAL (valueChanged(RKComponentPropertyBase*)), this, SLOT (requirednessChanged(RKComponentPropertyBase*))); QVBoxLayout *vbox = new QVBoxLayout (this, RKGlobals::spacingHint ()); int intmode = xml->getMultiChoiceAttribute (element, "type", "file;dir;savefile", 0, DL_INFO); GetFileNameWidget::FileType mode; if (intmode == 0) { mode = GetFileNameWidget::ExistingFile; } else if (intmode == 0) { mode = GetFileNameWidget::ExistingDirectory; } else { mode = GetFileNameWidget::SaveFile; } selector = new GetFileNameWidget (this, mode, xml->getStringAttribute (element, "label", i18n ("Enter filename"), DL_INFO), i18n ("Select"), xml->getStringAttribute (element, "initial", QString::null, DL_INFO)); selector->setFilter (xml->getStringAttribute (element, "filter", QString::null, DL_INFO)); connect (selector, SIGNAL (locationChanged ()), SLOT (textChanged ())); vbox->addWidget (selector); // initialize updating = false; textChanged (); }
void WebAppletPackage::pathChanged() { KDesktopFile config(path() + "/metadata.desktop"); KConfigGroup cg = config.desktopGroup(); QString mainScript = cg.readEntry("X-Plasma-MainScript", QString()); if (!mainScript.isEmpty()) { addFileDefinition("mainscript", mainScript, i18n("Main Script File")); setRequired("mainscript", true); } }
RKVarSlot::RKVarSlot (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) { RK_TRACE (PLUGIN); XMLHelper *xml = XMLHelper::getStaticHelper (); // basic layout QGridLayout *g_layout = new QGridLayout (this, 4, 3, RKGlobals::spacingHint ()); QLabel *label = new QLabel (xml->getStringAttribute (element, "label", i18n ("Variable:"), DL_INFO), this); g_layout->addWidget (label, 0, 2); select = new QPushButton (QString::null, this); setSelectButton (false); connect (select, SIGNAL (clicked ()), this, SLOT (selectPressed ())); g_layout->addWidget (select, 1, 0); g_layout->addColSpacing (1, 5); list = new QListView (this); list->setSelectionMode (QListView::Extended); list->addColumn (" "); // for counter list->addColumn (i18n ("Name")); list->setSorting (2); g_layout->addWidget (list, 1, 2); // initialize properties addChild ("source", source = new RKComponentPropertyRObjects (this, false)); addChild ("available", available = new RKComponentPropertyRObjects (this, true)); addChild ("selected", selected = new RKComponentPropertyRObjects (this, false)); // find out about options if (multi = xml->getBoolAttribute (element, "multi", false, DL_INFO)) { available->setListLength (xml->getIntAttribute (element, "min_vars", 1, DL_INFO), xml->getIntAttribute (element, "min_vars_if_any", 1, DL_INFO), xml->getIntAttribute (element, "max_vars", 0, DL_INFO)); connect (list, SIGNAL (selectionChanged ()), this, SLOT (listSelectionChanged ())); } else { available->setListLength (1, 1, 1); // make it look like a line-edit list->header ()->hide (); list->setFixedHeight (list->fontMetrics ().height () + 2*list->itemMargin () + 4); // the height of a single line including margins list->setColumnWidthMode (0, QListView::Manual); list->setColumnWidth (0, 0); list->setHScrollBarMode (QScrollView::AlwaysOff); list->setVScrollBarMode (QScrollView::AlwaysOff); g_layout->setRowStretch (3, 1); // so the label does not get separated from the view } // initialize filters available->setClassFilter (QStringList::split (" ", xml->getStringAttribute (element, "classes", QString::null, DL_INFO))); setRequired (xml->getBoolAttribute (element, "required", false, DL_INFO)); available->setTypeFilter (QStringList::split (" ", xml->getStringAttribute (element, "types", QString::null, DL_INFO))); available->setDimensionFilter (xml->getIntAttribute (element, "num_dimensions", 0, DL_INFO), xml->getIntAttribute (element, "min_length", 0, DL_INFO), xml->getIntAttribute (element, "max_length", INT_MAX, DL_INFO)); connect (available, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (availablePropertyChanged (RKComponentPropertyBase *))); availablePropertyChanged (available); // initialize }
WebAppletPackage::WebAppletPackage(QObject *parent, QVariantList args) : Plasma::PackageStructure(parent, "Web") { Q_UNUSED(args) // copy the main applet structure Plasma::PackageStructure::operator=(*Plasma::Applet::packageStructure()); addFileDefinition("mainscript", "code/main.html", i18n("Main Script File")); setRequired("mainscript", true); // For Webapplet::init() addDirectoryDefinition("html", "code/", i18n("Root HTML directory")); }
seqan::ArgumentParser::ParseResult parseArgs(FxSamCoverageOptions & options, int argc, char const ** argv) { seqan::ArgumentParser parser("fx_sam_coverage"); setShortDescription(parser, "Read Coverage Computation."); setVersion(parser, "0.1"); setDate(parser, "August 2012"); addUsageLine(parser, "[\\fIOPTIONS\\fP] \\fB-o\\fP \\fIOUT.tsv\\fP \\fIGENOME.fa\\fP \\fIMAPPING.sam\\fP"); addDescription(parser, "Compute read coverage and C+G content for a genome."); // Two input files: Genome, and mapping. addArgument(parser, seqan::ArgParseArgument(seqan::ArgParseArgument::INPUTFILE)); setValidValues(parser, 0, "fasta fa"); addArgument(parser, seqan::ArgParseArgument(seqan::ArgParseArgument::INPUTFILE)); setValidValues(parser, 1, "sam"); // 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, "Main Options"); addOption(parser, seqan::ArgParseOption("w", "window-size", "Set the size of the non-overlapping windows in base pairs.", seqan::ArgParseArgument::INTEGER, "NUM")); setDefaultValue(parser, "window-size", "10000"); addSection(parser, "Output Options"); addOption(parser, seqan::ArgParseOption("o", "out-path", "Path to the resulting file. If omitted, result is printed to stdout.", seqan::ArgParseArgument::OUTPUTFILE, "TSV")); setRequired(parser, "out-path"); setValidValues(parser, "out-path", "sam.coverage.tsv"); seqan::ArgumentParser::ParseResult res = parse(parser, argc, argv); if (res == seqan::ArgumentParser::PARSE_OK) { getArgumentValue(options.inGenomePath, parser, 0); getArgumentValue(options.inSamPath, parser, 1); getOptionValue(options.outPath, parser, "out-path"); if (isSet(parser, "verbose")) options.verbosity = 2; if (isSet(parser, "very-verbose")) options.verbosity = 3; } return res; }
RKInput::RKInput (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) { RK_TRACE (PLUGIN); textedit = 0; lineedit = 0; // get xml-helper XMLHelper *xml = parent_component->xmlHelper (); // create and add property addChild ("text", text = new RKComponentPropertyBase (this, false)); connect (text, SIGNAL (valueChanged(RKComponentPropertyBase*)), this, SLOT (textChanged(RKComponentPropertyBase*))); setRequired (xml->getBoolAttribute (element, "required", false, DL_INFO)); connect (requirednessProperty (), SIGNAL (valueChanged(RKComponentPropertyBase*)), this, SLOT (requirednessChanged(RKComponentPropertyBase*))); // do all the layouting QVBoxLayout *vbox = new QVBoxLayout (this); vbox->setContentsMargins (0, 0, 0, 0); label_string = xml->i18nStringAttribute (element, "label", i18n ("Enter text"), DL_INFO); if (!label_string.isEmpty ()) { QLabel *label = new QLabel (label_string, this); vbox->addWidget (label); } int size = xml->getMultiChoiceAttribute (element, "size", "small;medium;large", 1, DL_INFO); if (size == 2) { textedit = new QTextEdit (this); QFontMetrics fm = QFontMetrics (textedit->currentFont ()); int lheight = fm.lineSpacing (); int margin = fm.descent () + 2; textedit->setMinimumSize (250, lheight * 4 + margin); vbox->addWidget (textedit); connect (textedit, SIGNAL (textChanged()), SLOT (textChanged())); } else { lineedit = new QLineEdit (this); vbox->addWidget (lineedit); connect (lineedit, SIGNAL (textChanged(QString)), SLOT (textChanged(QString))); } vbox->addStretch (1); // to keep the label attached // initialize updating = false; // DO NOT replace "" with QString (), here! it is important, that this is actually an empty string, not a null string. text->setValue (xml->getStringAttribute (element, "initial", "", DL_INFO)); }
RKPluginSaveObject::RKPluginSaveObject (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) { RK_TRACE (PLUGIN); // read settings XMLHelper *xml = XMLHelper::getStaticHelper (); bool checkable = xml->getBoolAttribute (element, "checkable", false, DL_INFO); bool checked = xml->getBoolAttribute (element, "checked", false, DL_INFO); bool required = xml->getBoolAttribute (element, "required", true, DL_INFO); QString label = xml->getStringAttribute (element, "label", i18n ("Save to:"), DL_INFO); QString initial = xml->getStringAttribute (element, "initial", i18n ("my.data"), DL_INFO); // create and add properties addChild ("selection", selection = new RKComponentPropertyBase (this, required)); connect (selection, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (externalChange ())); selection->setInternal (true); // the two separate properties "parent" and "objectname" are used for (re-)storing. addChild ("parent", parent = new RKComponentPropertyRObjects (this, false)); connect (parent, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (externalChange ())); addChild ("objectname", objectname = new RKComponentPropertyBase (this, false)); connect (objectname, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (externalChange ())); addChild ("active", active = new RKComponentPropertyBool (this, false, false, "1", "0")); connect (active, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (externalChange ())); if (!checkable) active->setInternal (true); // create GUI groupbox = new QGroupBox (label, this); groupbox->setCheckable (checkable); if (checkable) groupbox->setChecked (checked); connect (groupbox, SIGNAL (toggled(bool)), this, SLOT (internalChange ())); selector = new RKSaveObjectChooser (groupbox, initial); connect (selector, SIGNAL (changed (bool)), SLOT (internalChange ())); QVBoxLayout *vbox = new QVBoxLayout (this); vbox->setContentsMargins (0, 0, 0, 0); QVBoxLayout *vbox_b = new QVBoxLayout (groupbox); vbox_b->setContentsMargins (0, 0, 0, 0); vbox_b->addWidget (selector); vbox->addWidget (groupbox); // initialize setRequired (required); updating = false; internalChange (); }
void AbstractParam::readParameters(const YAML::Node &yamlNode) { for ( YAML::const_iterator it = yamlNode.begin(); it != yamlNode.end(); ++it ) { std::string key = READ_NODE_AS_STRING(it->first); if (key == Keys::Description) setDescription(READ_NODE_AS_STRING(it->second)); else if (key == Keys::Default) setDefaultValue(READ_NODE_AS_STRING(it->second)); else if (key == Keys::DisplayName) setDisplayName(READ_NODE_AS_STRING(it->second)); else if (key == Keys::Example) setExample(READ_NODE_AS_STRING(it->second)); else if (key == Keys::Maximum) setMaximum(READ_NODE_AS_LONG(it->second)); else if (key == Keys::Minimum) setMinimum(READ_NODE_AS_LONG(it->second)); else if (key == Keys::MaxLength) setMaxLength(READ_NODE_AS_INT(it->second)); else if (key == Keys::MinLength) setMinLength(READ_NODE_AS_INT(it->second)); else if (key == Keys::Pattern) setPattern(READ_NODE_AS_STRING(it->second)); else if (key == Keys::Repeat) setRepeat(READ_NODE_AS_BOOL(it->second)); else if (key == Keys::Required) setRequired(READ_NODE_AS_BOOL(it->second)); else if (key == Keys::Type) setType(READ_NODE_AS_STRING(it->second)); else if (key == Keys::Enum) { YAML::Node enumNode = it->second; for ( YAML::const_iterator tt = enumNode.begin(); tt != enumNode.end(); ++tt ) setEnumeration(READ_NODE_AS_STRING(*tt)); } } }
seqan::ArgumentParser::ParseResult parseArgs(FxFaidxOptions & options, int argc, char const ** argv) { seqan::ArgumentParser parser("fx_faidx"); setShortDescription(parser, "Indexing FASTA and indexed FASTA access."); setVersion(parser, "0.1"); setDate(parser, "May 2012"); addUsageLine(parser, "[\\fIOPTIONS\\fP] [\\fB-f\\fP \\fIFASTA\\fP] [\\fB-r\\fP \\fIREGION\\fP]+"); addDescription(parser, "Equivalent program to samtools faidx."); // 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.")); addOption(parser, seqan::ArgParseOption("vv", "very-verbose", "Very verbose, log to STDERR.")); hideOption(parser, "very-verbose"); addSection(parser, "FASTA / FAIDX Files"); addOption(parser, seqan::ArgParseOption("f", "fasta-file", "Path to the FASTA file.", seqan::ArgParseArgument::STRING, false, "FASTA")); setRequired(parser, "fasta-file"); addOption(parser, seqan::ArgParseOption("i", "index-file", "Path to the .fai index file. Defaults to FASTA.fai", seqan::ArgParseArgument::STRING, false, "FASTA")); addOption(parser, seqan::ArgParseOption("o", "out-file", "Path to the resulting file. If omitted, result is printed to stdout.", seqan::ArgParseArgument::STRING, false, "FASTA")); addSection(parser, "Regions"); addOption(parser, seqan::ArgParseOption("r", "region", "Region to retrieve from FASTA file. You can specify multiple regions with multiple \\fB-r\\fP \\fIREGION\\fP. Note that regions are one-based, see below for detailed information about the format.", seqan::ArgParseArgument::STRING, true, "REGION")); addTextSection(parser, "Regions"); addText(parser, "Regions can be specified in the formats \\fICHR\\fP, \\fICHR\\fP:\\fISTART\\fP, \\fICHR\\fP:\\fISTART\\fP:\\fIEND\\fP. \\fICHR\\fP is the id of the reference sequence in the FASTA file, \\fISTART\\fP and \\fIEND\\fP are the start end end positions of the region. These positions are one-based."); addTextSection(parser, "Region Examples"); addListItem(parser, "\\fIchr1\\fP", "All of the sequence with the identifier \"chr1\"."); addListItem(parser, "\\fIchrX\\fP:\\fI1,000\\fP", "The characters in the X chromsome, starting with the 1,000th base."); addListItem(parser, "\\fIchr2\\fP:\\fI1,500,000\\fP-\\fI2,000,000\\fP", "The character 1,500,000 up to and including character 2,000,000 in the same chromosome."); addTextSection(parser, "Usage Examples"); addListItem(parser, "\\fBfx_faidx\\fP \\fB-f\\fP \\fIREF.fa\\fP", "Create index for file \\fIREF.fa\\fP, index is written to \\fIREF.fa.fai\\fP"); addListItem(parser, "\\fBfx_faidx\\fP \\fB-f\\fP \\fIREF.fa\\fP \\fB-i\\fP \\fIINDEX.fai\\fP", "Create index for file \\fIREF.fa\\fP, index is written to \\fIINDEX.fai\\fP"); addListItem(parser, "\\fBfx_faidx\\fP \\fB-f\\fP \\fIREF.fa\\fP \\fB-r\\fP \\fIchr1\\fP", "Retrieve sequence named \"chr1\" from file \\fIREF.fa\\fP using the index with the default name \\fIREF.fa.fai\\fP. The index file name is created if it does not exist."); addListItem(parser, "\\fBfx_faidx\\fP \\fB-f\\fP \\fIREF.fa\\fP \\fB-r\\fP \\fIchr1:100-1100\\fP", "Retrieve characters 100 to 1,100 from the sequence named \"chr1\" from file \\fIREF.fa\\fP using the index with the default name \\fIREF.fa.fai\\fP."); addListItem(parser, "\\fBfx_faidx\\fP \\fB-f\\fP \\fIREF.fa\\fP \\fB-r\\fP \\fIchr1:100-1100\\fP \\fB-r\\fP \\fIchr2:2,000\\fP", "Retrieve characters 100-1,000 from \"chr1\" and all characters from 2,000 of \"chr2\"."); seqan::ArgumentParser::ParseResult res = parse(parser, argc, argv); if (res == seqan::ArgumentParser::PARSE_OK) { getOptionValue(options.inFastaPath, parser, "fasta-file"); // Set default FAI file name. options.inFaiPath = options.inFastaPath; append(options.inFaiPath, ".fai"); // Get FAI file name from parser if set. if (isSet(parser, "index-file")) getOptionValue(options.inFaiPath, parser, "index-file"); if (isSet(parser, "region")) options.regions = getOptionValues(parser, "region"); if (isSet(parser, "out-file")) getOptionValue(options.outFastaPath, parser, "out-file"); if (isSet(parser, "verbose")) options.verbosity = 2; if (isSet(parser, "very-verbose")) options.verbosity = 3; } return res; }
seqan::ArgumentParser::ParseResult parseCommandLine(Options & options, int argc, char const ** argv) { // Setup ArgumentParser. seqan::ArgumentParser parser("roiGFF"); // Set short description, version, and date. setShortDescription(parser, "get ROIs based on GFF annotation"); setVersion(parser, VERSION); setDate(parser, "March 2013"); // Define usage line and long description. addUsageLine(parser, "[\\fIOPTIONS\\fP] \\fB-if\\fP \\fIIN.roi\\fP" "\\fB-ig\\fP \\fIIN.gff\fP" "\\fB-of\\fP \\fIOUT.roi\\fP" "[\\fB-ss\\fP] [\\fB-t\\fP \\fItype\\fP] " "[\\fB-p\\fP \\fIparent attribute\\fP]]"); addDescription(parser, "Takes regions from GFF file, calculates the overlap with the ROI file" "and creates a new ROI file based on the GFF regions."); // General Options addOption(parser, seqan::ArgParseOption("v", "verbose", "Verbose mode.")); addOption(parser, seqan::ArgParseOption("vv", "vverbose", "Very verbose mode.")); // Input / Output Options addSection(parser, "Input / Output Parameters"); addOption(parser, seqan::ArgParseOption("if", "roi-file", "roi file", seqan::ArgParseOption::INPUTFILE)); setValidValues(parser, "roi-file", "roi"); setRequired(parser, "roi-file"); addOption(parser, seqan::ArgParseOption("ig", "gff-file", "gff file", seqan::ArgParseOption::INPUTFILE)); setValidValues(parser, "gff-file", "gff"); setRequired(parser, "gff-file"); addOption(parser, seqan::ArgParseOption("of", "output-file", "Output file", seqan::ArgParseOption::OUTPUTFILE)); setValidValues(parser, "output-file", "roi"); setRequired(parser, "output-file"); // Optional Parameter addOption(parser, seqan::ArgParseOption("ss", "strandspecific", "calculate strandspecific stats (only position sorted)")); addOption(parser, seqan::ArgParseOption("t", "type", "Type to used (3. column in GFF file). If not set all types will be used." "There can only be one or none set.", seqan::ArgParseOption::STRING)); setDefaultValue(parser, "type", ""); addOption(parser, seqan::ArgParseOption("p", "parent", "tag to used to identify regions that should be concatednated." "They are sorted by start position and then concatenated. If empty/not set" "there will be no concatenation performed", seqan::ArgParseOption::STRING)); setDefaultValue(parser, "parent", ""); // Parse command line. seqan::ArgumentParser::ParseResult res = seqan::parse(parser, argc, argv); // Extract option values. if (isSet(parser, "verbose")) options.verbosity = 1; if (isSet(parser, "vverbose")) options.verbosity = 2; getOptionValue(options.roiFileName, parser, "roi-file"); getOptionValue(options.gffFileName, parser, "gff-file"); getOptionValue(options.outputFileName, parser, "output-file"); getOptionValue(options.strandSpecific, parser, "strandspecific"); getOptionValue(options.type, parser, "type"); getOptionValue(options.parent, parser, "parent"); return seqan::ArgumentParser::PARSE_OK; }
seqan::ArgumentParser::ParseResult parseCommandLine(SeqConsOptions & options, int argc, char const ** argv) { // Setup ArgumentParser. seqan::ArgumentParser parser("seqcons2"); // Set short description, version, and date. setShortDescription(parser, "Compute consensus from sequences."); setVersion(parser, SEQAN_APP_VERSION " [" SEQAN_REVISION "]"); setDate(parser, SEQAN_DATE); // Define usage line and long description. addUsageLine(parser, "\\fB-i\\fP \\fIINPUT.{fa,sam}\\fP [\\fB-oa\\fP \\fIOUT_ALIGN.{fa,sam}\\fP] " "[\\fB-oc\\fP \\fIOUT_CONSENSUS.fa\\fP]"); addDescription(parser, "Compute consensus from sequences with and without approximate alignment information."); // Overall Program Options addOption(parser, seqan::ArgParseOption("q", "quiet", "Set verbosity to a minimum.")); addOption(parser, seqan::ArgParseOption("v", "verbose", "Enable verbose output.")); addOption(parser, seqan::ArgParseOption("vv", "very-verbose", "Enable very verbose output.")); addOption(parser, seqan::ArgParseOption("m", "method", "Method to perform. See section \\fIMethods\\fP " "below for details.", seqan::ArgParseOption::STRING, "METHOD")); setValidValues(parser, "method", "nop realign align_consensus overlap_consensus contig_consensus pos_consensus"); setDefaultValue(parser, "method", "pos_consensus"); // I/O Options addSection(parser, "I/O Options"); addOption(parser, seqan::ArgParseOption("i", "input-file", "Input file.", seqan::ArgParseOption::INPUT_FILE, "INPUT")); setRequired(parser, "input-file", true); setValidValues(parser, "input-file", "sam fa fasta"); addOption(parser, seqan::ArgParseOption("oa", "output-alignment-file", "Output file with alignment.", seqan::ArgParseOption::OUTPUT_FILE, "OUT_ALIGNMENT")); setRequired(parser, "output-alignment-file", false); setValidValues(parser, "output-alignment-file", "sam txt"); addOption(parser, seqan::ArgParseOption("oc", "output-consensus-file", "Output file with consensus sequence.", seqan::ArgParseOption::OUTPUT_FILE, "OUT_CONSENSUS")); setRequired(parser, "output-consensus-file", false); setValidValues(parser, "output-consensus-file", "fa fasta"); // Alignment Quality Filter Options addSection(parser, "Alignment Quality Filter Options"); addOption(parser, seqan::ArgParseOption("", "overlap-min-length", "Minimal overlap length.", seqan::ArgParseOption::INTEGER, "LENGTH")); setMinValue(parser, "overlap-min-length", "0"); setDefaultValue(parser, "overlap-min-length", "20"); addOption(parser, seqan::ArgParseOption("", "overlap-max-error", "Maximal error rate in overlap as percentage.", seqan::ArgParseOption::DOUBLE, "RATE")); setMinValue(parser, "overlap-max-error", "0.0"); setDefaultValue(parser, "overlap-max-error", "5.0"); addOption(parser, seqan::ArgParseOption("", "overlap-min-count", "Minimal overlap count.", seqan::ArgParseOption::INTEGER, "COUNT")); setMinValue(parser, "overlap-min-count", "0"); setDefaultValue(parser, "overlap-min-count", "3"); addOption(parser, seqan::ArgParseOption("", "overlap-window-size", "Window size to look for alignments.", seqan::ArgParseOption::INTEGER, "SIZE")); setMinValue(parser, "overlap-window-size", "0"); setDefaultValue(parser, "overlap-window-size", "20"); // K-mer Filter Options addSection(parser, "K-Mer Filter Options"); addOption(parser, seqan::ArgParseOption("", "k-mer-size", "The k-mer size to use.", seqan::ArgParseOption::INTEGER, "LENGTH")); setMinValue(parser, "k-mer-size", "5"); setDefaultValue(parser, "k-mer-size", "20"); addOption(parser, seqan::ArgParseOption("", "k-mer-max-occ", "Ignore k-mer with higher occurence count, 0 to disable.", seqan::ArgParseOption::INTEGER, "COUNT")); setMinValue(parser, "k-mer-max-occ", "0"); setDefaultValue(parser, "k-mer-max-occ", "200"); // Realignment Options addSection(parser, "Realignment Options"); addOption(parser, seqan::ArgParseOption("", "realign-bandwidth", "Bandwidth to use for pairwise alignments in realignment.", seqan::ArgParseOption::INTEGER, "LENGTH")); setMinValue(parser, "realign-bandwidth", "5"); setDefaultValue(parser, "realign-bandwidth", "10"); addOption(parser, seqan::ArgParseOption("", "realign-environment", "Environment for extraction in realignment.", seqan::ArgParseOption::INTEGER, "COUNT")); setMinValue(parser, "realign-environment", "5"); setDefaultValue(parser, "realign-environment", "20"); // Add Methods Section addTextSection(parser, "Methods"); addListItem(parser, "\\fBnop\\fP", "Perform no action, just perform file conversion if possible."); addListItem(parser, "\\fBrealign\\fP", "Perform realignment, requires input to be a SAM file to provide approximate position " "information, creates consensus sequence after realignment."); addListItem(parser, "\\fBoverlap_consensus\\fP", "Perform MSA with overlap alignments of the input ignoring any given coordinates, then realign. " "This is most suited when computing the consensus of reads where the underlying sequence is very " "similar and most differences stem from sequencing errors and not genomic variation. All " "pairwise alignments computed here are banded."); addListItem(parser, "\\fBalign_consensus\\fP", "Perform MSA with global alignments of the input ignoring any given coordinates, then realign. " "This will computed unbanded global ends-gap free pairwise alignments. This is also suitable " "when aligning different sequences, e.g. clustered transcripts. Using this method, seqcons " "will be similar to calling SeqAn::T-Coffee, followed by realignment and consensus computation."); addListItem(parser, "\\fBcontig_consensus\\fP", "Perform MSA of the input, contig by contig, requires contig information, then realign. Input " "must be SAM."); addListItem(parser, "\\fBpos_consensus\\fP", "Perform consensus of the input, then realign. Requires approximate coordinate information in " "SAM file."); // Add Output Section addTextSection(parser, "Output Formats"); addText(parser, "The program can write out the consensus sequence in FASTA format and optionally the alignment of the " "input sequences against the consensus in SAM/BAM format. When using the extension \\fI.txt\\fP, seqcons " "will write out the MSA as a plain text visualization."); // Add Examples Section addTextSection(parser, "Examples"); addListItem(parser, "\\fBseqcons\\fP \\fB-m\\fP \\fIovl_consensus\\fP \\fB-i\\fP \\fIreads.fa\\fP \\fB-oa\\fP " "\\fIout.sam\\fP \\fB-oc\\fP \\fIcons.fa\\fP", "Compute MSA of the sequences in \\fIreads.fa\\fP. The consensus sequence is written to " "\\fIcons.fa\\fP and the alignment of the sequences in \\fIreads.fa\\fP is written to " "\\fIout.sam\\fP."); addListItem(parser, "\\fBseqcons\\fP \\fB-m\\fP \\fIrealign\\fP \\fB-i\\fP \\fIin.sam\\fP \\fB-oa\\fP \\fIout.sam\\fP", "Read in multi-read alignment from \\fIin.sam\\fP, refine it using Anson-Myers realignment and " "write out the refined alignment to \\fIout.sam\\fP"); // Parse command line. seqan::ArgumentParser::ParseResult res = seqan::parse(parser, argc, argv); // Only extract options if the program will continue after parseCommandLine() if (res != seqan::ArgumentParser::PARSE_OK) return res; // Extract option values. if (isSet(parser, "quiet")) options.verbosity = 0; if (isSet(parser, "verbose")) options.verbosity = 2; if (isSet(parser, "very-verbose")) options.verbosity = 3; std::string opStr; getOptionValue(opStr, parser, "method"); options.operation = strToMethod(opStr.c_str()); getOptionValue(options.inputFile, parser, "input-file"); getOptionValue(options.outputFileAlignment, parser, "output-alignment-file"); getOptionValue(options.outputFileConsensus, parser, "output-consensus-file"); getOptionValue(options.overlapMinLength, parser, "overlap-min-length"); getOptionValue(options.overlapMaxErrorRate, parser, "overlap-max-error"); getOptionValue(options.overlapWindowSize, parser, "overlap-window-size"); getOptionValue(options.kMerSize, parser, "k-mer-size"); getOptionValue(options.kMerMaxOcc, parser, "k-mer-max-occ"); getOptionValue(options.reAlignmentBandwidth, parser, "realign-bandwidth"); getOptionValue(options.reAlignmentEnvironment, parser, "realign-environment"); return seqan::ArgumentParser::PARSE_OK; }
seqan::ArgumentParser::ParseResult parseCommandLine(MasonGenomeOptions & options, int argc, char const ** argv) { // Setup ArgumentParser. seqan::ArgumentParser parser("mason_genome"); // Set short description, version, and date. setShortDescription(parser, "Random Genome Simulation"); setVersion(parser, "2.1"); setDate(parser, "March 2013"); setCategory(parser, "Simulators"); // Define usage line and long description. addUsageLine(parser, "[\\fIOPTIONS\\fP] [\\fB-l\\fP \\fILEN\\fP]+ \\fB-o\\fP \\fIOUT.fa\\fP"); addDescription(parser, "Simulate a random genome to the output file. For each \\fB-l\\fP/\\fB--contig-length\\fP " "entry, a contig with the given length will be simulated."); // We require one argument. addOption(parser, seqan::ArgParseOption("q", "quiet", "Set verbosity to a minimum.")); addOption(parser, seqan::ArgParseOption("v", "verbose", "Enable verbose output.")); addOption(parser, seqan::ArgParseOption("vv", "very-verbose", "Enable very verbose output.")); addSection(parser, "Simulation Configuration"); addOption(parser, seqan::ArgParseOption("l", "contig-length", "Length of the contig to simulate. Give one \\fB-l\\fP " "value for each contig to simulate.", seqan::ArgParseOption::INTEGER, "LENGTH", true)); setMinValue(parser, "contig-length", "1"); setRequired(parser, "contig-length"); addOption(parser, seqan::ArgParseOption("s", "seed", "The seed to use for the random number generator.", seqan::ArgParseOption::INTEGER, "INT")); setDefaultValue(parser, "seed", 0); addSection(parser, "Output Options"); addOption(parser, seqan::ArgParseOption("o", "out-file", "Output file.", seqan::ArgParseOption::OUTPUTFILE, "FILE")); setValidValues(parser, "out-file", "fa fasta"); setRequired(parser, "out-file"); // Add Examples Section. addTextSection(parser, "Examples"); addListItem(parser, "\\fBmason_genome\\fP \\fB-l\\fP 1000 \\fB-l\\fP 4000 \\fB-o\\fP \\fIgenome.fa\\fP", "Simulate a genome with two contigs of lengths 1000 and 4000 and write it to genome.fa."); // Parse command line. seqan::ArgumentParser::ParseResult res = seqan::parse(parser, argc, argv); // Only extract options if the program will continue after parseCommandLine() if (res != seqan::ArgumentParser::PARSE_OK) return res; // Extract option values. if (isSet(parser, "quiet")) options.verbosity = 0; if (isSet(parser, "verbose")) options.verbosity = 2; if (isSet(parser, "very-verbose")) options.verbosity = 3; getOptionValue(options.outputFilename, parser, "out-file"); getOptionValue(options.seed, parser, "seed"); for (unsigned i = 0; i < getOptionValueCount(parser, "contig-length"); ++i) { int len = 0; getOptionValue(len, parser, "contig-length", i); appendValue(options.contigLengths, len); } return seqan::ArgumentParser::PARSE_OK; }