We will be offering mothur and R workshops throughout 2019. Learn more.

Difference between revisions of "Contribute code"

From mothur
Jump to: navigation, search
Line 1: Line 1:
==Creating a command that can be added to mothur==
 
  
 
Thanks for wanting to be a part of the mothur project! ...
 
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 [[Media:Command.zip | Command Template ]].
 
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 [[Media:Command.zip | 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.
 +
 +
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==
 
==Submitting your command==
  
 
==Adding a wiki page for your command==
 
==Adding a wiki page for your command==

Revision as of 12:54, 25 February 2010

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.

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