1 | #include "mltaln.h" |
---|
2 | |
---|
3 | #define DEBUG 0 |
---|
4 | |
---|
5 | char *regfile; |
---|
6 | char *eregfile; |
---|
7 | |
---|
8 | void arguments( int argc, char *argv[] ) |
---|
9 | { |
---|
10 | int c; |
---|
11 | |
---|
12 | outnumber = 0; |
---|
13 | inputfile = NULL; |
---|
14 | regfile = NULL; |
---|
15 | eregfile = NULL; |
---|
16 | |
---|
17 | while( --argc > 0 && (*++argv)[0] == '-' ) |
---|
18 | { |
---|
19 | while ( (c = *++argv[0]) ) |
---|
20 | { |
---|
21 | switch( c ) |
---|
22 | { |
---|
23 | case 'e': |
---|
24 | eregfile = *++argv; |
---|
25 | fprintf( stderr, "eregfile = %s\n", eregfile ); |
---|
26 | --argc; |
---|
27 | goto nextoption; |
---|
28 | case 'r': |
---|
29 | regfile = *++argv; |
---|
30 | fprintf( stderr, "regfile = %s\n", regfile ); |
---|
31 | --argc; |
---|
32 | goto nextoption; |
---|
33 | case 'i': |
---|
34 | inputfile = *++argv; |
---|
35 | fprintf( stderr, "inputfile = %s\n", inputfile ); |
---|
36 | --argc; |
---|
37 | goto nextoption; |
---|
38 | case 'n' : |
---|
39 | outnumber = 1; |
---|
40 | break; |
---|
41 | default: |
---|
42 | fprintf( stderr, "illegal option %c\n", c ); |
---|
43 | argc = 0; |
---|
44 | break; |
---|
45 | } |
---|
46 | } |
---|
47 | nextoption: |
---|
48 | ; |
---|
49 | } |
---|
50 | if( argc != 0 ) |
---|
51 | { |
---|
52 | fprintf( stderr, "options: Check source file !\n" ); |
---|
53 | exit( 1 ); |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | void readereg( FILE *regfp, int **regtable, char **revtable, int *outtable, int *noutpt, int *loutpt ) |
---|
58 | { |
---|
59 | char gett[1000]; |
---|
60 | int j; |
---|
61 | int mem; |
---|
62 | char cmem; |
---|
63 | char reg[5][100]; |
---|
64 | char out[100]; |
---|
65 | int startpos, endpos; |
---|
66 | |
---|
67 | *noutpt = 0; |
---|
68 | *loutpt = 0; |
---|
69 | fgets( gett, 999, regfp ); |
---|
70 | sscanf( gett, "%c %s %s %s %s %s", &cmem, reg[0], reg[1], reg[2], reg[3], reg[4] ); |
---|
71 | if( cmem != 'e' ) |
---|
72 | { |
---|
73 | fprintf( stderr, "Format error\n" ); |
---|
74 | exit( 1 ); |
---|
75 | } |
---|
76 | for( j=0; j<5; j++ ) |
---|
77 | { |
---|
78 | sscanf( reg[j], "%d-%d-%c", regtable[0]+(j*2), regtable[0]+(j*2)+1, revtable[0]+j ); |
---|
79 | fprintf( stderr, "%d %d-%d\n", 0, regtable[0][j*2], regtable[0][j*2+1] ); |
---|
80 | startpos = regtable[0][j*2]; |
---|
81 | endpos = regtable[0][j*2+1]; |
---|
82 | if( startpos > endpos ) |
---|
83 | { |
---|
84 | endpos = regtable[0][j*2]; |
---|
85 | startpos = regtable[0][j*2+1]; |
---|
86 | } |
---|
87 | if( startpos != -1 && endpos != -1 ) |
---|
88 | *loutpt += endpos - startpos + 1; |
---|
89 | } |
---|
90 | |
---|
91 | while( 1 ) |
---|
92 | { |
---|
93 | fgets( gett, 999, regfp ); |
---|
94 | if( feof( regfp ) ) break; |
---|
95 | sscanf( gett, "%d o=%s", &mem, out ); |
---|
96 | if( mem >= njob ) |
---|
97 | { |
---|
98 | fprintf( stderr, "Out of range\n" ); |
---|
99 | exit( 1 ); |
---|
100 | } |
---|
101 | outtable[mem] = atoi( out ); |
---|
102 | if( outtable[mem] ) *noutpt += 1; |
---|
103 | } |
---|
104 | } |
---|
105 | |
---|
106 | void readreg( FILE *regfp, int **regtable, char **revtable, int *outtable ) |
---|
107 | { |
---|
108 | char gett[1000]; |
---|
109 | int j; |
---|
110 | int mem; |
---|
111 | char reg[5][100]; |
---|
112 | char out[100]; |
---|
113 | |
---|
114 | while( 1 ) |
---|
115 | { |
---|
116 | fgets( gett, 999, regfp ); |
---|
117 | if( feof( regfp ) ) break; |
---|
118 | sscanf( gett, "%d %s %s %s %s %s o=%s", &mem, reg[0], reg[1], reg[2], reg[3], reg[4], out ); |
---|
119 | if( mem >= njob ) |
---|
120 | { |
---|
121 | fprintf( stderr, "Out of range\n" ); |
---|
122 | exit( 1 ); |
---|
123 | } |
---|
124 | for( j=0; j<5; j++ ) |
---|
125 | { |
---|
126 | sscanf( reg[j], "%d-%d-%c", regtable[mem]+(j*2), regtable[mem]+(j*2)+1, revtable[mem]+j ); |
---|
127 | fprintf( stderr, "%d %d-%d\n", mem, regtable[mem][j*2], regtable[mem][j*2+1] ); |
---|
128 | } |
---|
129 | outtable[mem] = atoi( out ); |
---|
130 | } |
---|
131 | } |
---|
132 | |
---|
133 | int main( int argc, char *argv[] ) |
---|
134 | { |
---|
135 | FILE *infp; |
---|
136 | FILE *regfp; |
---|
137 | int nlenmin; |
---|
138 | int **regtable; |
---|
139 | char **revtable; |
---|
140 | int *outtable; |
---|
141 | int i, nout, lout; |
---|
142 | char **outseq; |
---|
143 | char **name; |
---|
144 | |
---|
145 | arguments( argc, argv ); |
---|
146 | |
---|
147 | if( inputfile ) |
---|
148 | { |
---|
149 | infp = fopen( inputfile, "r" ); |
---|
150 | if( !infp ) |
---|
151 | { |
---|
152 | fprintf( stderr, "Cannot open %s\n", inputfile ); |
---|
153 | exit( 1 ); |
---|
154 | } |
---|
155 | } |
---|
156 | else |
---|
157 | infp = stdin; |
---|
158 | |
---|
159 | dorp = NOTSPECIFIED; |
---|
160 | getnumlen_nogap( infp, &nlenmin ); |
---|
161 | |
---|
162 | if( regfile ) |
---|
163 | { |
---|
164 | regfp = fopen( regfile, "r" ); |
---|
165 | if( !regfp ) |
---|
166 | { |
---|
167 | fprintf( stderr, "Cannot open %s\n", regfile ); |
---|
168 | exit( 1 ); |
---|
169 | } |
---|
170 | regtable = AllocateIntMtx( njob, 5*2 ); |
---|
171 | revtable = AllocateCharMtx( njob, 5 ); |
---|
172 | outtable = AllocateIntVec( njob ); |
---|
173 | readreg( regfp, regtable, revtable, outtable ); |
---|
174 | cutData( infp, regtable, revtable, outtable ); |
---|
175 | } |
---|
176 | else if( eregfile ) |
---|
177 | { |
---|
178 | regfp = fopen( eregfile, "r" ); |
---|
179 | if( !regfp ) |
---|
180 | { |
---|
181 | fprintf( stderr, "Cannot open %s\n", eregfile ); |
---|
182 | exit( 1 ); |
---|
183 | } |
---|
184 | regtable = AllocateIntMtx( 1, 5*2 ); |
---|
185 | revtable = AllocateCharMtx( 1, 5 ); |
---|
186 | outtable = AllocateIntVec( njob ); |
---|
187 | readereg( regfp, regtable, revtable, outtable, &nout, &lout ); |
---|
188 | fprintf( stderr, "nout = %d, lout = %d\n", nout, lout ); |
---|
189 | |
---|
190 | outseq = AllocateCharMtx( nout, lout+1 ); |
---|
191 | name = AllocateCharMtx( nout, B ); |
---|
192 | |
---|
193 | cutAlignment( infp, regtable, revtable, outtable, name, outseq ); |
---|
194 | fprintf( stderr, "gappick! nout = %d\n", nout ); |
---|
195 | commongappick( nout, outseq ); |
---|
196 | for( i=0; i<nout; i++ ) |
---|
197 | { |
---|
198 | fprintf( stdout, "%s\n", name[i] ); |
---|
199 | fprintf( stdout, "%s\n", outseq[i] ); |
---|
200 | } |
---|
201 | } |
---|
202 | else |
---|
203 | { |
---|
204 | catData( infp ); |
---|
205 | } |
---|
206 | |
---|
207 | fprintf( stderr, "Strategy:\n" ); |
---|
208 | fprintf( stderr, " Not-Aligned\n" ); |
---|
209 | |
---|
210 | // fprintf( stdout, "%d x %d - %d %c\n", njob, nlenmax, nlenmin, dorp ); |
---|
211 | return( 0 ); |
---|
212 | } |
---|