]> git.donarmstrong.com Git - mothur.git/blobdiff - sequence.cpp
added alignment code
[mothur.git] / sequence.cpp
index b59363e13cc92f969145434d1ba8c0fa64573778..f136426b327fdbd13d4143645b80cb060059325e 100644 (file)
@@ -24,6 +24,36 @@ Sequence::Sequence(string newName, string sequence) {
        }
        setUnaligned(sequence);
 }
+//********************************************************************************************************************
+
+Sequence::Sequence(ifstream& fastaFile){
+       
+       string accession;                               //      provided a file handle to a fasta-formatted sequence file, read in the next
+       fastaFile >> accession;                 //      accession number and sequence we find...
+       setName(accession);
+
+       char letter;
+       string sequence;
+       
+       while(fastaFile){
+               letter= fastaFile.get();
+               if(letter == '>'){
+                       fastaFile.putback(letter);
+                       break;
+               }
+               else if(isprint(letter)){
+                       letter = toupper(letter);
+                       if(letter == 'U'){letter = 'T';}
+                       sequence += letter;
+               }
+               
+       }
+
+       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
+}
 
 //********************************************************************************************************************
 
@@ -122,3 +152,18 @@ void Sequence::printSequence(ostream& out){
 }
 
 //********************************************************************************************************************
+
+int Sequence::getUnalignLength(){
+       return unaligned.length();
+}
+
+//********************************************************************************************************************
+
+int Sequence::getAlignLength(){
+       return aligned.length();
+}
+
+//********************************************************************************************************************
+
+
+