//the candidate stack
Stack S;
//check if P is prefix less than Q
//P=AC..T and Q=T.G, P is prefix less than Q.
//P=AC..TA and Q=AC..T, P is prefix less than Q.
bool PrefixLess(P,Q);
//check if P is suffix less than Q
//P=AC..T and Q=AC.GT, Q is suffix less than P.
//P=C.GT and Q=AC.GT, Q is suffix less than P.
bool SuffixLess(P,Q);
//check if P and Q are convolutable
bool isConvolutable(P,Q);
//convolute P and Q
Sequence Convolute(P,Q);
//check from the result list, judge if P is maximal
bool isMaximal(P);
//add P to result list
bool AddToResultList(P);
Teiresias(){
P=S.top();
for Q=S.Location(P).next() to S.bottom(){
if isConvolutable(P,Q){
R=Convolute(P,Q);
S.push(R);
Teiresias();
}
}
for Q=S.Location(P).next() to S.bottom(){
if isConvolutable(Q,P){
R=Convolute(Q,P);
S.push(R);
Teiresias();
}
}
if isMaximal(P){
AddToResultList(P);
}
}
Stack S;
//check if P is prefix less than Q
//P=AC..T and Q=T.G, P is prefix less than Q.
//P=AC..TA and Q=AC..T, P is prefix less than Q.
bool PrefixLess(P,Q);
//check if P is suffix less than Q
//P=AC..T and Q=AC.GT, Q is suffix less than P.
//P=C.GT and Q=AC.GT, Q is suffix less than P.
bool SuffixLess(P,Q);
//check if P and Q are convolutable
bool isConvolutable(P,Q);
//convolute P and Q
Sequence Convolute(P,Q);
//check from the result list, judge if P is maximal
bool isMaximal(P);
//add P to result list
bool AddToResultList(P);
Teiresias(){
P=S.top();
for Q=S.Location(P).next() to S.bottom(){
if isConvolutable(P,Q){
R=Convolute(P,Q);
S.push(R);
Teiresias();
}
}
for Q=S.Location(P).next() to S.bottom(){
if isConvolutable(Q,P){
R=Convolute(Q,P);
S.push(R);
Teiresias();
}
}
if isMaximal(P){
AddToResultList(P);
}
}
Comments