We will be offering an R workshop December 18-20, 2019. Learn more.

Contribute code

From mothur
Revision as of 13:00, 25 February 2010 by Westcott (Talk | contribs)

Jump to: navigation, search

Thanks for wanting to be a part of the mothur project! ...

Creating a command that can be added to mothur

All commands in mothur have the same basic structure inherited from the command class. Commands must have an execute and help function, and the constructor may only accept a string. Here are some template files to get you started Command Template .

Each command is responsible for error checking the inputs it receives, but there are several classes that can help with this, or you may create your own. OptionParser and ValidParameters will help parse the input and make sure input files can be opened.

To allow for the input/output redirect, mothur will add the parameters outputdir and inputdir to your option string if needed. You may want to take a look at readotucommand.cpp to get a feel for how we handled these.

Once you have created your command class, you will need to add a few lines to commandfactory.cpp to enable mothur to run it.

1. Include the c++ header file for your command.
2. In the CommandFactory::CommandFactory add your command to the list of valid command with a line like:  
    commands["yourAwesomeCommand"] = "yourAwesomeCommand"; 
3. In CommandFactory::getCommand add another elseif line like:
    else if(commandName == "yourAwesomeCommand") { command = new YourCommand(optionString);	}

Submitting your command

Adding a wiki page for your command