New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make a List of Reusable Classes/Functions from Mothur #4
Comments
You could also outline what functions you'll need and then see how many of them already exist. You'll want to talk to Sarah (https://github.com/mothur-westcott) about this. |
@kdiverson: That is a good idea. I'm going to create more issues to break down the complex tasks to atomic ones. Right now trying to create new issues/updating them according to the chat's that we had for the last month so that we do not have to go through our chat history and just come to this github issue tracker and get a summary of all that is happening. |
Yup, I am getting these. I can certainly help you find some functions and classes to reuse. Here's a few to get you started as well as some background. A little background on mothur's container classes. Here are the 5 most commonly used types,
The |
You may also want to make a issue tracker for mothur's common practices, like the error catching mechanisms, signal captures and logging functions? |
@kdiverson @mothur-westcott Created Issue #5 for that. Also, if you think the other members of the community would be helpful, please let them know, they have to bear the trouble of signing into github, most of them might be interested in using a Wiki or blog where it's easier to comment, but I think using an issue tracker like this would be a lot better solution as it has more developer friendly tools to get us organized. |
There are three type of Command* command = cFactory->getCommand(commandName, options); So we'd need to add our new command in the We'd just need to override the following virtual string getCommandName() = 0;
virtual string getCommandCategory() = 0;
virtual string getHelpString() = 0;
virtual string getCitation() = 0;
virtual string getDescription() = 0;
virtual map<string, vector<string> > getOutputFiles() { return outputTypes; }
virtual vector<string> setParameters() = 0; //to fill parameters
virtual vector<CommandParameter> getParameters() { return parameters; }
virtual int execute() = 0;
virtual void help() = 0;
virtual ~Command() { } |
You can't override those functions. Doing so, would make your new command unable to work with certain parts of mothur as well as a GUI we have in the works. The execute function is where you will do most of your work, it is similar to the main function in a stand alone program. The command name, description, help and citation are fairly straightforward. The category is mostly likely |
@mothur-westcott Some of this functions are pretty straight forward, no? For example this is an excerpt from class SharedCommand : public Command {
public:
SharedCommand(string);
SharedCommand();
~SharedCommand();
vector<string> setParameters();
string getCommandName() { return "make.shared"; }
string getCommandCategory() { return "OTU-Based Approaches"; }
string getHelpString();
string getCitation() { return "http://www.mothur.org/wiki/Make.shared"; }
string getDescription() { return "make a shared file from a list and group file"; }
int execute();
void help() { m->mothurOut(getHelpString()); } Aren't we overriding these functions effectively? What's wrong with these? What are the challenges that we might face if I want to create a new vector<string> SharedCommand::setParameters(){
try {
CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pgroup);
//CommandParameter pordergroup("ordergroup", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pordergroup);
CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
vector<string> myArray;
for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); }
return myArray;
}
catch(exception& e) {
m->errorOut(e, "SharedCommand", "setParameters");
exit(1);
}
} |
I'm sorry, I thought when you said override, you meant to change the command class so that the functions were not pure. Your CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);
CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
CommandParameter pisalwaystogether("isalwaystogether", "String", "", "", "", "", "",false,false); parameters.push_back(pisalwaystogether);
CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
CommandParameter pmethod("method", "Multiple", "randomforest", "randomforest", "", "", "",false,false); parameters.push_back(pmethod); We may add others as the questions we want to ask with this command become more clear. |
So just to make sure we are on the same page, by the term Overriding we want to denote the Object Oriented Programming concept of Function Overriding, so basically there are not complex issues, I just create a new class the extends Command class and Override the functions just as they have been in the other classes like SharedCommand right? |
Right, :) |
I added 2 new files to the mothur repository, newcommandtemplate.h and newcommandtemplate.cpp. They should help with the integration into mothur. |
Mothur is a complex software and has a lot of Classes and Functions can be re-used rather than reinventing them again and again. We'd need to make a list of them and decide how these can be reused.
Child Issues: #5
The text was updated successfully, but these errors were encountered: