# include "Seq.h" void ReadSelection(TokenizeData * d, int select[]) { int i = 0; InitLexer(d); while (TokenizeLine(d)) { if (OnBetwStrgs(d,"_BEG_SELECT_","_END_SELECT_")) { if (i>MAX_SEQ_SELECTION) STDERR("ERROR: i>MAX_SEQ_SELECTION"); select[i] = d->D[1] ; i++ ; } } select[i] = 0; } bool ReadSelectionOneLine (TokenizeData * d, int select[],char * key,int SeqStartPos) { InitLexer(d); while (TokenizeLine(d)) { if (Begins2With1P(key,d->T[0])) { int i=1, j=0; char * p = &(d->T[0][SeqStartPos]) ; while (*p != '#') { if (*p == '*' || *p == 'x' || *p == '$') { select[j]=i; j++; } i++; p++; } select[j] = 0; return true; } } return false; } void ReadSelectionWNames(TokenizeData * d, int select[], char * CannonicalNames[]) { int i = 0; InitLexer(d); while (TokenizeLine(d)) { if (OnBetwStrgs(d,"_BEG_SELECT_","_END_SELECT_")) { if (i>MAX_SEQ_SELECTION) STDERR("ERROR: i>MAX_SEQ_SELECTION"); select[i] = d->D[1] ; CannonicalNames[i] = SaveString(d->T[2]); i++ ; } } select[i] = 0; } bool InSelectionP(int i, int *select) { if (select == NULL || *select == 0) return false; else if (i == *select) return true; else return InSelectionP(i,++select); } int * InvertSelection(int *select, int *out, int SeqSz) { int i,j,k=0; for (j=1; j<= SeqSz; j++) { if (!InSelectionP(j,select)) { out[k] = j; k++ ; } } out[k]=0; return out ; } void RemoveSel3FromSel2To(int *NewSel,int *CoreSel,int *select) { int * SP ; while (*CoreSel) { int match = 0; for (SP = select; *SP ; SP++) if (*SP == *CoreSel) { match = 1; break ; } if (!match) { *NewSel = *CoreSel ; NewSel++ ; } CoreSel++ ; } } int IntMemberOf(int query, int * SetOfInt) { if (*SetOfInt == 0) return NOT_A_MEMBER ; else if (*SetOfInt == query) return 0 ; else { int i = IntMemberOf(query, SetOfInt + 1) ; if (i == NOT_A_MEMBER) return NOT_A_MEMBER ; else return (i + 1) ; } } void PrintSetOfInt(int * SetOfInt) { int i; for (i=0; SetOfInt[i] != 0 ; i++) printf("%d ",SetOfInt[i]); printf("\n"); } int SizeSetOfInt(int * SetOfInt) { if (SetOfInt == NULL || *SetOfInt == 0) return 0 ; else { int i; for (i=0; SetOfInt[i] !=0 ; i++) ; return i; } } int * ReadSetOfInt(TokenizeData * d) { int *retval, i; if (!TokenizeLine(d)) STDERR("You are at the end of the number line."); retval = ivector(0,d->NF+1); for (i=0; iNF; i++) retval[i] = d->D[i+1]; retval[d->NF] = 0; return retval ; } int * NotIntersect(int * s1, int *s2) { int i, j=0; int size = SizeSetOfInt(s1) + SizeSetOfInt(s2); int * s3 = ivector(0,size); for (i=0; s1[i] != 0; i++) if (IntMemberOf(s1[i],s2) == NOT_A_MEMBER) { s3[j++] = s1[i] ; } for (i=0; s2[i] != 0; i++) if (IntMemberOf(s2[i],s1) == NOT_A_MEMBER) { s3[j++] = s2[i] ; } s3[j] = 0; return s3; }