]> git.donarmstrong.com Git - mothur.git/blobdiff - chimeracheckcommand.cpp
pat's updates on 7/19/10
[mothur.git] / chimeracheckcommand.cpp
index 25f9c0fe4fa68425b9fcf6f407357fbc79027cfb..f002a026d55d3787d045477e40c1ba8125ea04f8 100644 (file)
@@ -73,7 +73,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 +98,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 +140,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 +165,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--;
@@ -338,7 +358,7 @@ int ChimeraCheckCommand::execute(){
                                        }
                                                                        
                                }else{
-                                       vector<int> positions;
+                                       vector<unsigned long int> positions;
                                        processIDS.resize(0);
                                        
                                        ifstream inFASTA;
@@ -348,7 +368,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 +378,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;
                                                }