2 * secondarystructurecommand.cpp
5 * Created by westcott on 9/18/09.
6 * Copyright 2009 Schloss Lab. All rights reserved.
10 #include "secondarystructurecommand.h"
11 #include "sequence.hpp"
13 //**********************************************************************************************************************
15 AlignCheckCommand::AlignCheckCommand(string option){
19 //allow user to run help
20 if(option == "help") { help(); abort = true; }
23 //valid paramters for this command
24 string Array[] = {"fasta","map"};
25 vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
27 OptionParser parser(option);
28 map<string,string> parameters = parser.getParameters();
30 ValidParameters validParameter;
32 //check to make sure all parameters are valid for command
33 for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) {
34 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
37 //check for required parameters
38 mapfile = validParameter.validFile(parameters, "map", true);
39 if (mapfile == "not open") { abort = true; }
40 else if (mapfile == "not found") { mapfile = ""; mothurOut("You must provide an map file."); mothurOutEndLine(); abort = true; }
42 fastafile = validParameter.validFile(parameters, "fasta", true);
43 if (fastafile == "not open") { abort = true; }
44 else if (fastafile == "not found") { fastafile = ""; mothurOut("You must provide an fasta file."); mothurOutEndLine(); abort = true; }
50 errorOut(e, "AlignCheckCommand", "RemoveSeqsCommand");
54 //**********************************************************************************************************************
56 void AlignCheckCommand::help(){
58 //mothurOut("The remove.seqs command reads an .accnos file and one of the following file types: fasta, name, group or alignreport file.\n");
59 //mothurOut("It outputs a file containing the sequences NOT in the .accnos file.\n");
60 //mothurOut("The remove.seqs command parameters are accnos, fasta, name, group and alignreport. You must provide accnos and one of the other parameters.\n");
61 //mothurOut("The remove.seqs command should be in the following format: remove.seqs(accnos=yourAccnos, fasta=yourFasta).\n");
62 //mothurOut("Example remove.seqs(accnos=amazon.accnos, fasta=amazon.fasta).\n");
63 //mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
66 errorOut(e, "AlignCheckCommand", "help");
71 //**********************************************************************************************************************
73 int AlignCheckCommand::execute(){
76 if (abort == true) { return 0; }
78 //get secondary structure info.
87 errorOut(e, "AlignCheckCommand", "execute");
91 //**********************************************************************************************************************
92 void AlignCheckCommand::readMap(){
95 structMap.resize(1, 0);
98 openInputFile(mapfile, in);
103 structMap.push_back(position);
108 seqLength = structMap.size();
111 //check you make sure is structMap[10] = 380 then structMap[380] = 10.
112 for(int i=0;i<seqLength;i++){
113 if(structMap[i] != 0){
114 if(structMap[structMap[i]] != i){
115 mothurOut("Your map file contains an error: line " + toString(i) + " does not match line " + toString(structMap[i]) + "."); mothurOutEndLine();
122 catch(exception& e) {
123 errorOut(e, "AlignCheckCommand", "readFasta");
128 //**********************************************************************************************************************