]> git.donarmstrong.com Git - mothur.git/blobdiff - trimseqscommand.cpp
added chimera.uchime
[mothur.git] / trimseqscommand.cpp
index 9ff75df7dc98571ec8585f50ff4cf3de0b4f5fed..6d87f89c88b1055e033f3cce1cc18e0700377ff1 100644 (file)
@@ -80,7 +80,7 @@ string TrimSeqsCommand::getHelpString(){
                helpString += "maxhomop=yourMaxhomop, minlength=youMinlength, maxlength=yourMaxlength)  \n";    
                helpString += "Example trim.seqs(fasta=abrecovery.fasta, flip=..., oligos=..., maxambig=..., maxhomop=..., minlength=..., maxlength=...).\n";
                helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               helpString += "For more details please check out the wiki http://www.mothur.org/wiki/Trim.seqs .\n\n";
+               helpString += "For more details please check out the wiki http://www.mothur.org/wiki/Trim.seqs .\n";
                return helpString;
        }
        catch(exception& e) {
@@ -116,6 +116,7 @@ TrimSeqsCommand::TrimSeqsCommand(string option)  {
                
                //allow user to run help
                if(option == "help") { help(); abort = true; calledHelp = true; }
+               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
                
                else {
                        vector<string> myArray = setParameters();
@@ -497,7 +498,7 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string
                        int currentSeqsDiffs = 0;
 
                        Sequence currSeq(inFASTA); m->gobble(inFASTA);
-
+                       
                        QualityScores currQual;
                        if(qFileName != ""){
                                currQual = QualityScores(qFile);  m->gobble(qFile);
@@ -546,7 +547,7 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string
                                        else if(qRollAverage != 0)      {       success = currQual.stripQualRollingAverage(currSeq, qRollAverage);      }
                                        else if(qWindowAverage != 0){   success = currQual.stripQualWindowAverage(currSeq, qWindowStep, qWindowSize, qWindowAverage);   }
                                        else                                            {       success = 1;                            }
-                                       
+                               
                                        //you don't want to trim, if it fails above then scrap it
                                        if ((!qtrim) && (origLength != currSeq.getNumBases())) {  success = 0; }
                                        
@@ -583,7 +584,7 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string
                                        
                                        if(barcodes.size() != 0){
                                                string thisGroup = barcodeNameVector[barcodeIndex];
-                                               if (primers.size() != 0) {  if (primerNameVector[primerIndex] != "") { thisGroup += "." + primerNameVector[primerIndex]; } }
+                                               if (primers.size() != 0) { if (primerNameVector[primerIndex] != "") { thisGroup += "." + primerNameVector[primerIndex]; } }
                                                
                                                outGroupsFile << currSeq.getName() << '\t' << thisGroup << endl;
                                                
@@ -797,7 +798,7 @@ int TrimSeqsCommand::createProcessesCreateTrim(string filename, string qFileName
 
 int TrimSeqsCommand::setLines(string filename, string qfilename, vector<unsigned long int>& fastaFilePos, vector<unsigned long int>& qfileFilePos) {
        try {
-               
+               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
                //set file positions for fasta file
                fastaFilePos = m->divideFile(filename, processors);
                
@@ -870,6 +871,40 @@ int TrimSeqsCommand::setLines(string filename, string qfilename, vector<unsigned
                qfileFilePos.push_back(size);
                
                return processors;
+               
+               #else
+               
+                       fastaFilePos.push_back(0); qfileFilePos.push_back(0);
+                       //get last file position of fastafile
+                       FILE * pFile;
+                       unsigned long int size;
+                       
+                       //get num bytes in file
+                       pFile = fopen (filename.c_str(),"rb");
+                       if (pFile==NULL) perror ("Error opening file");
+                       else{
+                               fseek (pFile, 0, SEEK_END);
+                               size=ftell (pFile);
+                               fclose (pFile);
+                       }
+                       fastaFilePos.push_back(size);
+                       
+                       //get last file position of fastafile
+                       FILE * qFile;
+                       
+                       //get num bytes in file
+                       qFile = fopen (qfilename.c_str(),"rb");
+                       if (qFile==NULL) perror ("Error opening file");
+                       else{
+                               fseek (qFile, 0, SEEK_END);
+                               size=ftell (qFile);
+                               fclose (qFile);
+                       }
+                       qfileFilePos.push_back(size);
+               
+                       return 1;
+               
+               #endif
        }
        catch(exception& e) {
                m->errorOut(e, "TrimSeqsCommand", "setLines");
@@ -893,12 +928,14 @@ void TrimSeqsCommand::getOligos(vector<vector<string> >& fastaFileNames, vector<
                
                while(!inOligos.eof()){
 
-                       inOligos >> type; m->gobble(inOligos);
+                       inOligos >> type; 
                                        
                        if(type[0] == '#'){
-                               while (!inOligos.eof()) {       char c = inOligos.get(); if (c == 10 || c == 13){       break;  }       } // get rest of line if there's any crap there
+                               while (!inOligos.eof()) {       char c = inOligos.get();  if (c == 10 || c == 13){      break;  }       } // get rest of line if there's any crap there
+                               m->gobble(inOligos);
                        }
                        else{
+                               m->gobble(inOligos);
                                //make type case insensitive
                                for(int i=0;i<type.length();i++){       type[i] = toupper(type[i]);  }