1 /*****************************************************************
2 * HMMER - Biological sequence analysis with profile HMMs
3 * Copyright (C) 1992-1999 Washington University School of Medicine
6 * This source code is distributed under the terms of the
7 * GNU General Public License. See the files COPYING and LICENSE
9 *****************************************************************/
13 * Routines for creating and manipulating encoded sequence strings.
14 * RCS $Id: seqencode.c,v 1.1.1.1 2005/03/22 08:34:29 cmzmasek Exp $
27 mismatch number otherwise */
29 seqcmp(char *s1, char *s2, int allow)
33 while ((*s1 != NTEND) && (*s2 != NTEND) && (mmat <= allow))
35 if (!(ntmatch(*s1, *s2)))
40 while ((*s1++ != NTEND) && (mmat <= allow))
45 same as seqcmp but it looks at,
46 at most, n positions */
48 seqncmp(char *s1, char *s2, int n, int allow)
52 while ((*s2 != NTEND) &&
55 if ((!(ntmatch(*s1, *s2))) &&
61 while ((n-- != 0) && (*s1++ != NTEND) && (mmat <= allow))
67 given a character text string str (A,C,G,T),
68 convert to an encoded seq string;
69 return 1 for success, 0 if fail */
71 seqencode(char *codeseq, /* pre-allocated space for answer */
72 char *str) /* character string to convert */
80 if (islower((int) (*str))) *str = (char) toupper((int) (*str));
81 for (idx = 0; *str != iupac[idx].sym && idx <= IUPACSYMNUM; idx++)
83 if (idx > IUPACSYMNUM)
89 *ptr = iupac[idx].code;
99 coded_revcomp(char *comp, char *seq)
109 bckp = seq + bases -1;
110 for (pos = 0; pos < bases; pos++)
112 for (idx = 0; *bckp != iupac[idx].code && idx < IUPACSYMNUM; idx++);
113 if (idx > IUPACSYMNUM)
119 *fwdp = iupac[idx].comp;
128 seqdecode(char *str, char *codeseq)
134 while (*codeseq != NTEND)
136 for (idx = 0; *codeseq != iupac[idx].code && idx < IUPACSYMNUM; idx++)
138 if (idx > IUPACSYMNUM)
144 str[pos] = iupac[idx].sym;
154 char *str, /* pre-allocated string to write into */
155 char *codeseq, /* sequence to decode */
156 int n) /* how many bases to decode */
163 for (idx = 0; *codeseq != iupac[idx].code && idx < IUPACSYMNUM; idx++);
164 if (idx > IUPACSYMNUM)
170 str[pos] = iupac[idx].sym;