]> git.donarmstrong.com Git - mothur.git/blobdiff - sequence.cpp
fixed splash page citation
[mothur.git] / sequence.cpp
index 6a15eb5f7d23f93272811a975beedc649a0d9ce9..b2c2b53d0b4078e6e296312662dcdfe0ffe5fbec 100644 (file)
@@ -21,10 +21,10 @@ Sequence::Sequence(string newName, string sequence) {
 
        initialize();   
        name = newName;
-       if(sequence.find_first_of('-') != string::npos) {
-               setAligned(sequence);
-       }
+       
+       //setUnaligned removes any gap characters for us
        setUnaligned(sequence);
+       setAligned(sequence);
        
 }
 //********************************************************************************************************************
@@ -34,10 +34,9 @@ Sequence::Sequence(ifstream& fastaFile){
        initialize();
        fastaFile >> name;
        name = name.substr(1);
-       char c;
-       
-       while ((c = fastaFile.get()) != EOF)    {       if (c == 10){   break;  }       } // get rest of line if there's any crap there
        
+       while (!fastaFile.eof())        {       char c = fastaFile.get(); if (c == 10 || c == 13){      break;  }       } // get rest of line if there's any crap there
+
        char letter;
        string sequence;
        
@@ -54,10 +53,9 @@ Sequence::Sequence(ifstream& fastaFile){
                }
        }
 
-       if(sequence.find_first_of('-') != string::npos){        //      if there are any gaps in the sequence, assume that it is
-               setAligned(sequence);                                                   //      an alignment file
-       }
-       setUnaligned(sequence);                                                         //      also set the unaligned sequence file
+       setAligned(sequence);   
+       //setUnaligned removes any gap characters for us                                                
+       setUnaligned(sequence);                                                         
 }
 
 //********************************************************************************************************************
@@ -90,7 +88,7 @@ void Sequence::setName(string seqName) {
 
 void Sequence::setUnaligned(string sequence){
        
-       if(sequence.find_first_of('-') != string::npos) {
+       if(sequence.find_first_of('.') != string::npos || sequence.find_first_of('-') != string::npos) {
                string temp = "";
                for(int j=0;j<sequence.length();j++) {
                        if(isalpha(sequence[j]))        {       temp += sequence[j];    }
@@ -293,6 +291,7 @@ void Sequence::reverseComplement(){
                else                                            {       temp += 'N';    }
        }
        unaligned = temp;
+       aligned = temp;
        
 }