}
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
+}
//********************************************************************************************************************
string processed;
for(int i=0;i<unaligned.length();i++) {
- if(toupper(unaligned[i]) == 'A') { processed += '0'; }
+ if(toupper(unaligned[i]) == 'A') { processed += '0'; }
else if(toupper(unaligned[i]) == 'C') { processed += '1'; }
else if(toupper(unaligned[i]) == 'G') { processed += '2'; }
else if(toupper(unaligned[i]) == 'T') { processed += '3'; }
//********************************************************************************************************************
void Sequence::setAligned(string sequence){
+
+ //if the alignment starts or ends with a gap, replace it with a period to indicate missing data
+
+ if(sequence[0] == '-'){
+ for(int i=0;i<sequence.length();i++){
+ if(sequence[i] == '-'){
+ sequence[i] = '.';
+ }
+ else{
+ break;
+ }
+ }
+ for(int i=sequence.length()-1;i>=0;i--){
+ if(sequence[i] == '-'){
+ sequence[i] = '.';
+ }
+ else{
+ break;
+ }
+ }
+ }
aligned = sequence;
}
}
//********************************************************************************************************************
+
+int Sequence::getUnalignLength(){
+ return unaligned.length();
+}
+
+//********************************************************************************************************************
+
+int Sequence::getAlignLength(){
+ return aligned.length();
+}
+
+//********************************************************************************************************************
+
+
+