tags:

views:

125

answers:

0

One Class object, GeneSeqs, creates an array of objects, Sequence, of class type Sequence. The GeneSeqs then cycles through each Sequence and calls certain functions that modify Sequence::aaSeq of type string. In the end the aaSeq strings are == the

GeneSeqs::GeneSeqs(char * originalSeq,Limits * originalLimits, int length){
    codingSegments = new Sequence[numOfSeqs];
    fetchCodingSegments();
}

void GeneSeqs::fetchCodingSegments(){

    for (int i = 0; i < numOfSeqs; i++){
        subSeqLength = codingLimits->getSubSeqLength(i);
        if (subSeqLength != 0){

            codingSegments[i].translateToAA(1);
            codingSegments[i].printAA();
        }else{

            numOfSeqs--;
            codingLimits->decNumOfLimits();
        }
    }


void Sequence::translateToAA(int code){
    if (aaSeqTranslated == false){
        if (positiveStrand == false){
            codonSeq2AASeq2();
        }else{
            codonSeq2AASeq();
        }
        if (code == 1) aaSeq[0] = 'M'; 
        aaSeqTranslated = true;
    }
}


void Sequence::codonSeq2AASeq(){
    int z = 0;
    for (int i = 0; i < seqLen; i = i + 3){
        if ((i + 2) < seqLen) aaSeq[z] = codon2AA(&(seq[i])); 
        z++; 
    }
    aaSeqTranslated = true;
}

aaSeq is declared as a string in the private section of Sequence.h. The value of string aaSeq is not as expected after the method translateToAA(int code) is called. It seems to be the value of the aaSeq of each object is the value of the final Sequence object that called the translation method.

What is going wrong?