]> git.donarmstrong.com Git - mothur.git/blobdiff - chimeracheckcommand.cpp
1.12.1
[mothur.git] / chimeracheckcommand.cpp
index 25f9c0fe4fa68425b9fcf6f407357fbc79027cfb..264eb4c4ade8cfa2fd9f56246436b799ecb9d709 100644 (file)
@@ -8,7 +8,6 @@
  */
 
 #include "chimeracheckcommand.h"
-#include "chimeracheckrdp.h"
 
 //***************************************************************************************************************
 
@@ -27,7 +26,7 @@ ChimeraCheckCommand::ChimeraCheckCommand(string option)  {
                        OptionParser parser(option);
                        map<string,string> parameters = parser.getParameters();
                        
-                       ValidParameters validParameter;
+                       ValidParameters validParameter("chimera.check");
                        map<string,string>::iterator it;
                        
                        //check to make sure all parameters are valid for command
@@ -73,7 +72,17 @@ ChimeraCheckCommand::ChimeraCheckCommand(string option)  {
                                                if (pid == 0) {
                                        #endif
 
-                                       ableToOpen = openInputFile(fastaFileNames[i], in);
+                                       ableToOpen = openInputFile(fastaFileNames[i], in, "noerror");
+                               
+                                       //if you can't open it, try default location
+                                       if (ableToOpen == 1) {
+                                               if (m->getDefaultPath() != "") { //default path is set
+                                                       string tryPath = m->getDefaultPath() + getSimpleName(fastaFileNames[i]);
+                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = openInputFile(tryPath, in, "noerror");
+                                                       fastaFileNames[i] = tryPath;
+                                               }
+                                       }
                                        in.close();
                                        
                                        #ifdef USE_MPI  
@@ -88,7 +97,7 @@ ChimeraCheckCommand::ChimeraCheckCommand(string option)  {
                                        #endif
 
                                        if (ableToOpen == 1) { 
-                                               m->mothurOut(fastaFileNames[i] + " will be disregarded."); m->mothurOutEndLine(); 
+                                               m->mothurOut("Unable to open " + fastaFileNames[i] +". It will be disregarded."); m->mothurOutEndLine(); 
                                                //erase from file list
                                                fastaFileNames.erase(fastaFileNames.begin()+i);
                                                i--;
@@ -130,7 +139,17 @@ ChimeraCheckCommand::ChimeraCheckCommand(string option)  {
                                                if (pid == 0) {
                                        #endif
 
-                                       ableToOpen = openInputFile(nameFileNames[i], in);
+                                       ableToOpen = openInputFile(nameFileNames[i], in, "noerror");
+                               
+                                       //if you can't open it, try default location
+                                       if (ableToOpen == 1) {
+                                               if (m->getDefaultPath() != "") { //default path is set
+                                                       string tryPath = m->getDefaultPath() + getSimpleName(nameFileNames[i]);
+                                                       m->mothurOut("Unable to open " + nameFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = openInputFile(tryPath, in, "noerror");
+                                                       nameFileNames[i] = tryPath;
+                                               }
+                                       }
                                        in.close();
                                        
                                        #ifdef USE_MPI  
@@ -145,7 +164,7 @@ ChimeraCheckCommand::ChimeraCheckCommand(string option)  {
                                        #endif
 
                                        if (ableToOpen == 1) { 
-                                               m->mothurOut(nameFileNames[i] + " will be disregarded."); m->mothurOutEndLine(); 
+                                               m->mothurOut("Unable to open " + nameFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); 
                                                //erase from file list
                                                nameFileNames.erase(nameFileNames.begin()+i);
                                                i--;
@@ -243,7 +262,7 @@ int ChimeraCheckCommand::execute(){
                
                                int pid, end, numSeqsPerProcessor; 
                                int tag = 2001;
-                               vector<long> MPIPos;
+                               vector<unsigned long int> MPIPos;
                                
                                MPI_Status status; 
                                MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
@@ -338,7 +357,7 @@ int ChimeraCheckCommand::execute(){
                                        }
                                                                        
                                }else{
-                                       vector<int> positions;
+                                       vector<unsigned long int> positions;
                                        processIDS.resize(0);
                                        
                                        ifstream inFASTA;
@@ -348,7 +367,7 @@ int ChimeraCheckCommand::execute(){
                                        while(!inFASTA.eof()){
                                                input = getline(inFASTA);
                                                if (input.length() != 0) {
-                                                       if(input[0] == '>'){    long int pos = inFASTA.tellg(); positions.push_back(pos - input.length() - 1);  }
+                                                       if(input[0] == '>'){    unsigned long int pos = inFASTA.tellg(); positions.push_back(pos - input.length() - 1); }
                                                }
                                        }
                                        inFASTA.close();
@@ -358,7 +377,7 @@ int ChimeraCheckCommand::execute(){
                                        int numSeqsPerProcessor = numSeqs / processors;
                                        
                                        for (int j = 0; j < processors; j++) {
-                                               long int startPos = positions[ j * numSeqsPerProcessor ];
+                                               unsigned long int startPos = positions[ j * numSeqsPerProcessor ];
                                                if(j == processors - 1){
                                                        numSeqsPerProcessor = numSeqs - j * numSeqsPerProcessor;
                                                }
@@ -471,7 +490,7 @@ int ChimeraCheckCommand::driver(linePair* line, string outputFName, string filen
 }
 //**********************************************************************************************************************
 #ifdef USE_MPI
-int ChimeraCheckCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& outMPI, vector<long>& MPIPos){
+int ChimeraCheckCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& outMPI, vector<unsigned long int>& MPIPos){
        try {
                MPI_File outAccMPI;
                MPI_Status status;