]> git.donarmstrong.com Git - mothur.git/blobdiff - filterseqscommand.cpp
pat's slight modifications to trim.seqs
[mothur.git] / filterseqscommand.cpp
index 33790fe97632525cbb6c155ab953da531f770078..3784c3deab49a0c4302101372247f48f5ec3e89b 100644 (file)
@@ -72,11 +72,22 @@ FilterSeqsCommand::FilterSeqsCommand(string option)  {
                                                if (path == "") {       fastafileNames[i] = inputDir + fastafileNames[i];               }
                                        }
 
-                                       int ableToOpen;
                                        ifstream in;
-                                       ableToOpen = openInputFile(fastafileNames[i], in);
+                                       int 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();
+                                       
                                        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--;
@@ -872,7 +883,7 @@ int FilterSeqsCommand::createProcessesCreateFilter(Filters& F, string filename)
 int FilterSeqsCommand::setLines(string filename) {
        try {
                
-               vector<long int> positions;
+               vector<unsigned long int> positions;
                bufferSizes.clear();
                
                ifstream inFASTA;
@@ -883,7 +894,7 @@ int FilterSeqsCommand::setLines(string filename) {
                        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();
@@ -891,7 +902,7 @@ int FilterSeqsCommand::setLines(string filename) {
                int numFastaSeqs = positions.size();
        
                FILE * pFile;
-               long size;
+               unsigned long int size;
                
                //get num bytes in file
                pFile = fopen (filename.c_str(),"rb");
@@ -908,12 +919,12 @@ int FilterSeqsCommand::setLines(string filename) {
                
                for (int i = 0; i < processors; i++) {
 
-                       long int startPos = positions[ i * numSeqsPerProcessor ];
+                       unsigned long int startPos = positions[ i * numSeqsPerProcessor ];
                        if(i == processors - 1){
                                numSeqsPerProcessor = numFastaSeqs - i * numSeqsPerProcessor;
                                bufferSizes.push_back(size - startPos);
                        }else{  
-                               long int myEnd = positions[ (i+1) * numSeqsPerProcessor ];
+                               unsigned long int myEnd = positions[ (i+1) * numSeqsPerProcessor ];
                                bufferSizes.push_back(myEnd-startPos);
                        }
                        lines.push_back(new linePair(startPos, numSeqsPerProcessor));