]> git.donarmstrong.com Git - mothur.git/blobdiff - sequence.cpp
final commit before testing 1.11
[mothur.git] / sequence.cpp
index 71dd3a925fab8eb7771803c6db557dfb9d10200b..0afe3a971dcb1884160cd25f6c3d1b1d7012fa68 100644 (file)
@@ -129,31 +129,37 @@ Sequence::Sequence(ifstream& fastaFile){
                m = MothurOut::getInstance();
                initialize();
                fastaFile >> name;
-               name = name.substr(1);
-               string sequence;
+
+               if (name.length() != 0) { 
                
-               //read comments
-               while ((name[0] == '#') && fastaFile) { 
-                       while (!fastaFile.eof())        {       char c = fastaFile.get(); if (c == 10 || c == 13){      break;  }       } // get rest of line if there's any crap there
-                       sequence = getCommentString(fastaFile);
+                       name = name.substr(1); 
                        
-                       if (fastaFile) {  
-                               fastaFile >> name;  
-                               name = name.substr(1);  
-                       }else { 
-                               name = "";
-                               break;
-                       }
-               }
+                       string sequence;
                
-               //read real sequence
-               while (!fastaFile.eof())        {       char c = fastaFile.get(); if (c == 10 || c == 13){      break;  }       } // get rest of line if there's any crap there
+                       //read comments
+                       while ((name[0] == '#') && fastaFile) { 
+                               while (!fastaFile.eof())        {       char c = fastaFile.get(); if (c == 10 || c == 13){      break;  }       } // get rest of line if there's any crap there
+                               sequence = getCommentString(fastaFile);
+                               
+                               if (fastaFile) {  
+                                       fastaFile >> name;  
+                                       name = name.substr(1);  
+                               }else { 
+                                       name = "";
+                                       break;
+                               }
+                       }
+                       
+                       //read real sequence
+                       while (!fastaFile.eof())        {       char c = fastaFile.get(); if (c == 10 || c == 13){      break;  }       } // get rest of line if there's any crap there
+                       
+                       sequence = getSequenceString(fastaFile);                
                
-               sequence = getSequenceString(fastaFile);                
+                       setAligned(sequence);   
+                       //setUnaligned removes any gap characters for us                                                
+                       setUnaligned(sequence); 
+               }
                
-               setAligned(sequence);   
-               //setUnaligned removes any gap characters for us                                                
-               setUnaligned(sequence); 
        }
        catch(exception& e) {
                m->errorOut(e, "Sequence", "Sequence");