2 extract Zuker's p-optimal folds from subopt output.
3 prints p-optimal structures followed by the list of pairs
4 with respect to which they are optimal
6 input must be sorted by energy!
8 Ivo Hofacker, Walter Fontana
15 #define PRIVATE static
22 printf ("p-optimal filter to subopt output. usage:\n"
23 "RNAsubopt -s < seq | popt \n");
27 /*-------------------------------------------------------------------------*/
29 int main (int argc, char *argv[])
31 char *line, *sequence, *structure;
41 line = get_line (stdin);
44 line = get_line (stdin);
47 /* read the sequence */
48 sequence = (char *) space (sizeof (char) * (strlen(line)+1));
49 (void) sscanf(line, "%s", sequence);
51 length = (int) strlen(sequence);
53 iindx = (int *) space(sizeof(int)*(length+1));
54 for (i=1; i<=length; i++)
55 iindx[i] = ((length+1-i)*(length-i))/2 +length+1;
56 pair_seen = (char *) space(((length+1)*(length+2))/2 * sizeof(char));
58 structure = (char *) space (sizeof (char) * (length+1));
60 /* get of suboptimal structures */
62 while ((line = get_line (stdin))) {
65 r = sscanf(line, "%s %f", structure, &energy);
68 ptable = make_pair_table(structure);
71 for (i = 0; i < length; i++) {
73 if (pair_seen[iindx[i]-j]==0) {
74 pair_seen[iindx[i]-j]=(char) 1;
76 printf("%s %6.2f", structure, energy);
79 printf(" (%d,%d)", i,j);
82 if (popt==1) printf("\n");
85 free(sequence); free(structure); free(iindx); free(pair_seen);