]> git.donarmstrong.com Git - mothur.git/blobdiff - screenseqscommand.cpp
pat's mods to morisitahorn and pre.cluster
[mothur.git] / screenseqscommand.cpp
index 4b267b532ae1a19be791c380339b928212477edd..32426f3092d17468aa2f2599528f915423954376 100644 (file)
@@ -131,24 +131,27 @@ int ScreenSeqsCommand::execute(){
                
                while(!inFASTA.eof()){
                        Sequence currSeq(inFASTA);
-                       bool goodSeq = 1;               //      innocent until proven guilty
-                       if(goodSeq == 1 && startPos != -1 && startPos < currSeq.getStartPos())                  {       goodSeq = 0;    }
-                       if(goodSeq == 1 && endPos != -1 && endPos > currSeq.getEndPos())                                {       goodSeq = 0;    }
-                       if(goodSeq == 1 && maxAmbig != -1 && maxAmbig < currSeq.getAmbigBases())                {       goodSeq = 0;    }
-                       if(goodSeq == 1 && maxHomoP != -1 && maxHomoP < currSeq.getLongHomoPolymer())   {       goodSeq = 0;    }
-                       if(goodSeq == 1 && minLength != -1 && minLength > currSeq.getNumBases())                {       goodSeq = 0;    }
-                       if(goodSeq == 1 && maxLength != -1 && maxLength < currSeq.getNumBases())                {       goodSeq = 0;    }
-                       
-                       if(goodSeq == 1){
-                               currSeq.printSequence(goodSeqOut);      
-                       }
-                       else{
-                               currSeq.printSequence(badSeqOut);       
-                               badSeqNames.insert(currSeq.getName());
+                       if (currSeq.getName() != "") {
+                               bool goodSeq = 1;               //      innocent until proven guilty
+                               if(goodSeq == 1 && startPos != -1 && startPos < currSeq.getStartPos())                  {       goodSeq = 0;    }
+                               if(goodSeq == 1 && endPos != -1 && endPos > currSeq.getEndPos())                                {       goodSeq = 0;    }
+                               if(goodSeq == 1 && maxAmbig != -1 && maxAmbig < currSeq.getAmbigBases())                {       goodSeq = 0;    }
+                               if(goodSeq == 1 && maxHomoP != -1 && maxHomoP < currSeq.getLongHomoPolymer())   {       goodSeq = 0;    }
+                               if(goodSeq == 1 && minLength != -1 && minLength > currSeq.getNumBases())                {       goodSeq = 0;    }
+                               if(goodSeq == 1 && maxLength != -1 && maxLength < currSeq.getNumBases())                {       goodSeq = 0;    }
+                               
+                               if(goodSeq == 1){
+                                       currSeq.printSequence(goodSeqOut);      
+                               }
+                               else{
+                                       currSeq.printSequence(badSeqOut);       
+                                       badSeqNames.insert(currSeq.getName());
+                               }
                        }
                        gobble(inFASTA);
                }       
                if(namefile != "" && groupfile != "")   {       screenNameGroupFile(badSeqNames);       }       // this screens both names and groups
+               else if(namefile != "")                                 {       screenNameGroupFile(badSeqNames);       }
                else if(groupfile != "")                                {       screenGroupFile(badSeqNames);           }       // this screens just the groups
                if(alignreport != "")                                   {       screenAlignReport(badSeqNames);         }
                
@@ -206,6 +209,14 @@ void ScreenSeqsCommand::screenNameGroupFile(set<string> badSeqNames){
        goodNameOut.close();
        badNameOut.close();
        
+       //we were unable to remove some of the bad sequences
+       if (badSeqNames.size() != 0) {
+               for (it = badSeqNames.begin(); it != badSeqNames.end(); it++) {  
+                       mothurOut("Your namefile does not include the sequence " + *it + " please correct."); 
+                       mothurOutEndLine();
+               }
+       }
+
        if(groupfile != ""){
                
                ifstream inputGroups;
@@ -234,6 +245,14 @@ void ScreenSeqsCommand::screenNameGroupFile(set<string> badSeqNames){
                inputGroups.close();
                goodGroupOut.close();
                badGroupOut.close();
+               
+               //we were unable to remove some of the bad sequences
+               if (badSeqGroups.size() != 0) {
+                       for (it = badSeqGroups.begin(); it != badSeqGroups.end(); it++) {  
+                               mothurOut("Your namefile does not include the sequence " + *it + " please correct."); 
+                               mothurOutEndLine();
+                       }
+               }
        }
 }
 
@@ -265,6 +284,15 @@ void ScreenSeqsCommand::screenGroupFile(set<string> badSeqNames){
                }
                gobble(inputGroups);
        }
+       
+       //we were unable to remove some of the bad sequences
+       if (badSeqNames.size() != 0) {
+               for (it = badSeqNames.begin(); it != badSeqNames.end(); it++) {  
+                       mothurOut("Your groupfile does not include the sequence " + *it + " please correct."); 
+                       mothurOutEndLine();
+               }
+       }
+       
        inputGroups.close();
        goodGroupOut.close();
        badGroupOut.close();
@@ -312,6 +340,15 @@ void ScreenSeqsCommand::screenAlignReport(set<string> badSeqNames){
                }
                gobble(inputAlignReport);
        }
+       
+       //we were unable to remove some of the bad sequences
+       if (badSeqNames.size() != 0) {
+               for (it = badSeqNames.begin(); it != badSeqNames.end(); it++) {  
+                       mothurOut("Your file does not include the sequence " + *it + " please correct."); 
+                       mothurOutEndLine();
+               }
+       }
+
        inputAlignReport.close();
        goodAlignReportOut.close();
        badAlignReportOut.close();