source: tags/initial/CONVERTALN/macke.c

Last change on this file was 2, checked in by oldcode, 24 years ago

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 19.5 KB
Line 
1/* -------------------- Macke related subroutines -------------- */
2
3#include <stdio.h>
4#include "convert.h"
5#include "global.h"
6
7#define MACKELIMIT 10000
8
9/* ------------------------------------------------------------- */
10/*      Function init_mache().
11/*      Initialize macke entry.
12*/
13void
14init_macke()    {
15
16        void    Freespace();
17        char    *Dupstr();
18        int     indi;
19
20/* initialize macke format */
21        Freespace(&(data.macke.seqabbr));
22        Freespace(&(data.macke.name));
23        Freespace(&(data.macke.atcc));
24        Freespace(&(data.macke.rna));
25        Freespace(&(data.macke.date));
26        Freespace(&(data.macke.nbk));
27        Freespace(&(data.macke.acs));
28        Freespace(&(data.macke.who));
29        for(indi=0; indi<data.macke.numofrem; indi++)   {
30                Freespace(&(data.macke.remarks[indi]));
31        }
32        Freespace(&(data.macke.remarks));
33        Freespace(&(data.macke.journal));
34        Freespace(&(data.macke.title));
35        Freespace(&(data.macke.author));
36        Freespace(&(data.macke.strain));
37        Freespace(&(data.macke.subspecies));
38
39        data.macke.seqabbr=Dupstr("");
40        data.macke.name=Dupstr("\n");
41        data.macke.atcc=Dupstr("\n");
42        data.macke.rna=Dupstr("\n");
43        data.macke.date=Dupstr("\n");
44        data.macke.nbk=Dupstr("\n");
45        data.macke.acs=Dupstr("\n");
46        data.macke.who=Dupstr("\n");
47        data.macke.numofrem=0;
48        data.macke.rna_or_dna='d';
49        data.macke.journal=Dupstr("\n");
50        data.macke.title=Dupstr("\n");
51        data.macke.author=Dupstr("\n");
52        data.macke.strain=Dupstr("\n");
53        data.macke.subspecies=Dupstr("\n");
54}
55/* ------------------------------------------------------------- */
56/*      Function macke_in().
57/*              Read in one sequence data from Macke file.
58*/
59char
60macke_in(fp1, fp2, fp3)
61FILE    *fp1, *fp2, *fp3;
62{
63        static  char    line1[LINENUM];
64        static  char    line2[LINENUM];
65        static  char    line3[LINENUM];
66        static  int     first_time = 1;
67        char    oldname[TOKENNUM], name[TOKENNUM];
68        char    seq[LINENUM], key[TOKENNUM], temp[LINENUM];
69        char    *eof1, *eof2, *eof3, *Reallocspace(), *Dupstr();
70        char    *Fgetline(), *macke_origin();
71        char    *macke_one_entry_in();
72        int     numofrem = 0, seqnum;
73        int     index, indj;
74        int     Cmpstr(), macke_abbrev();
75        void    Freespace(), warning();
76
77        /* file 1 points to seq. information */
78        /* file 2 points to seq. data */
79        /* file 3 points to seq. names */
80        if(first_time)  {
81                /* skip to next "#:" line */
82                for(eof1=Fgetline(line1, LINENUM, fp1); 
83                eof1!=NULL&&(line1[0]!='#'||line1[1]!=':'); 
84                eof1=Fgetline(line1, LINENUM, fp1)) ;
85
86                /* skip all "#" lines to where seq. data is */
87                for(eof2=Fgetline(line2, LINENUM, fp2); 
88                eof2!=NULL
89                &&(line2[0]=='\n'||line2[0]==' '||line2[0]=='#'); 
90                eof2=Fgetline(line2, LINENUM, fp2)) ;
91
92                /* skip to "#=" lines */
93                for(eof3=Fgetline(line3, LINENUM, fp3); 
94                eof3!=NULL&&(line3[0]!='#'||line3[1]!='='); 
95                eof3=Fgetline(line3, LINENUM, fp3)) ;
96       
97                first_time = 0;
98        } else 
99                eof3=Fgetline(line3, LINENUM, fp3);
100
101        /* end of reading seq names */
102        if(line3[0]!='#'||line3[1]!='=') return(EOF);
103
104        /* skip to next "#:" line or end of file */
105        if(line1[0]!='#'||line1[1]!=':')        {
106                for( ;eof1!=NULL&&(line1[0]!='#'||line1[1]!=':'); 
107                eof1=Fgetline(line1, LINENUM, fp1)) ;
108        }
109
110        /* read in seq name */
111        index = macke_abbrev(line3, oldname, 2);
112        Freespace(&data.macke.seqabbr);
113        data.macke.seqabbr=Dupstr(oldname);
114
115        /* read seq. information */
116        for(index=macke_abbrev(line1, name, 2);
117        eof1!=NULL&&line1[0]=='#'&&line1[1]==':'
118        &&Cmpstr(name, oldname)==EQ; )
119        {
120                index = macke_abbrev(line1, key, index);
121                if(Cmpstr(key, "name")==EQ)     {
122                        eof1 = macke_one_entry_in(fp1, "name", oldname,
123                                &(data.macke.name), line1, index);
124                } else if(Cmpstr(key, "atcc")==EQ)      {
125                        eof1 = macke_one_entry_in(fp1, "atcc", oldname,
126                                &(data.macke.atcc), line1, index);
127                } else if(Cmpstr(key, "rna")==EQ)       {
128                        /* old version entry */
129                        eof1 = macke_one_entry_in(fp1, "rna", oldname,
130                                &(data.macke.rna), line1, index);
131                } else if(Cmpstr(key, "date")==EQ)      {
132                        eof1 = macke_one_entry_in(fp1, "date", oldname,
133                                &(data.macke.date), line1, index);
134                } else if(Cmpstr(key, "nbk")==EQ)       {
135                        /* old version entry */
136                        eof1 = macke_one_entry_in(fp1, "nbk", oldname,
137                                &(data.macke.nbk), line1, index);
138                } else if(Cmpstr(key, "acs")==EQ)       {
139                        eof1 = macke_one_entry_in(fp1, "acs", oldname,
140                                &(data.macke.acs), line1, index);
141                } else if(Cmpstr(key, "subsp")==EQ)     {
142                        eof1 = macke_one_entry_in(fp1, "subsp", oldname,
143                                &(data.macke.subspecies), line1, index);
144                } else if(Cmpstr(key, "strain")==EQ)    {
145                        eof1 = macke_one_entry_in(fp1, "strain", oldname,
146                                &(data.macke.strain), line1, index);
147                } else if(Cmpstr(key, "auth")==EQ)      {
148                        eof1 = macke_one_entry_in(fp1, "auth", oldname,
149                                &(data.macke.author), line1, index);
150                } else if(Cmpstr(key, "title")==EQ)     {
151                        eof1 = macke_one_entry_in(fp1, "title", oldname,
152                                &(data.macke.title), line1, index);
153                } else if(Cmpstr(key, "jour")==EQ)      {
154                        eof1 = macke_one_entry_in(fp1, "jour", oldname,
155                                &(data.macke.journal), line1, index);
156                } else if(Cmpstr(key, "who")==EQ)       {
157                        eof1 = macke_one_entry_in(fp1, "who", oldname,
158                                &(data.macke.who), line1, index);
159                } else if(Cmpstr(key, "rem")==EQ)       {
160                        data.macke.remarks = (char**)Reallocspace(
161                                data.macke.remarks, (unsigned)
162                                (sizeof(char*)*(numofrem+1)));
163                        data.macke.remarks[numofrem++] 
164                                = Dupstr(line1+index);
165                        eof1=Fgetline(line1, LINENUM, fp1);
166                } else {
167                        sprintf(temp,
168                        "Unidentified AE2 key word #%s#\n", key);
169                        warning(144, temp);
170                        eof1=Fgetline(line1, LINENUM, fp1);
171                }
172                if(eof1!=NULL&&line1[0]=='#'&&line1[1]==':')   
173                        index=macke_abbrev(line1, name, 2);
174                else index = 0; 
175        }
176        data.macke.numofrem = numofrem;
177
178        /* read in sequence data */
179        eof2=macke_origin(oldname, line2, fp2);
180
181        return(EOF+1);
182}
183/* ----------------------------------------------------------------- */
184/*      Function macke_one_entry_in().
185/*              Get one Macke entry.
186*/
187char
188*macke_one_entry_in(fp, key, oldname, var, line, index)
189FILE    *fp;
190char    *key, *oldname, **var, *line;
191int     index;
192{
193        void    replace_entry(), Append_rp_eoln();
194        char    *Dupstr(), *eof, *macke_continue_line();
195
196        if(Lenstr((*var))>1)
197                Append_rp_eoln(var, line+index);
198        else replace_entry(var, line+index);
199        eof = (char*)macke_continue_line(key, oldname, var, line, fp);
200
201        return(eof);
202
203}
204/* -------------------------------------------------------------- */
205/*      Function macke_continue_line().
206/*              Append macke continue line.
207*/
208char
209*macke_continue_line(key, oldname, var, line, fp)
210char    *key, *oldname, **var, *line;
211FILE    *fp;
212{
213        char    *eof, *Fgetline(), name[TOKENNUM], newkey[TOKENNUM];
214        int     index, Cmpstr(), Lenstr();
215        int     macke_abbrev();
216        void    Append_rp_eoln();
217
218        for(eof=Fgetline(line, LINENUM, fp);
219        eof!=NULL; eof=Fgetline(line, LINENUM, fp))     {
220                if(Lenstr(line)<=1)     continue;
221
222                index = macke_abbrev(line, name, 0);
223                if(Cmpstr(name, oldname)!=EQ)   break;
224
225                index = macke_abbrev(line, newkey, index);
226                if(Cmpstr(newkey, key)!=EQ)     break;
227
228                Append_rp_eoln(var, line+index);
229        }
230
231        return(eof);
232}
233/* ---------------------------------------------------------------- */
234/*      Function macke_origin().
235/*              Read in sequence data in macke file.
236*/
237char
238*macke_origin(key, line, fp)
239char    *key, *line;
240FILE    *fp;
241{
242        int     index, indj, Cmpstr(), seqnum;
243        int     macke_abbrev();
244        char    *eof, *Fgetline(), name[TOKENNUM], seq[LINENUM];
245        char    *Reallocspace();
246
247        /* read in seq. data */
248        data.seq_length=0;
249        /* read in line by line */
250
251        index=macke_abbrev(line, name, 0);
252        eof=line;
253        for(; eof!=NULL&&Cmpstr(key, name)==EQ; ){
254                sscanf(line+index, "%d%s", &seqnum, seq);
255                for(indj=data.seq_length; indj<seqnum; indj++)
256                        if(indj<data.max)
257                                data.sequence[data.seq_length++]
258                                        = '.';
259                        else    {
260                                data.max += 100;
261                                data.sequence = (char*)Reallocspace
262                                (data.sequence, (unsigned)
263                                        (sizeof(char)*data.max));
264                                data.sequence[data.seq_length++]
265                                        = '.';
266                        }
267                for(indj=0; seq[indj]!='\n'&&seq[indj]!='\0'; indj++)
268                        if(data.seq_length<data.max)
269                                data.sequence[data.seq_length++]
270                                        = seq[indj];
271                        else    {
272                                data.max += 100;
273                                data.sequence = (char*)Reallocspace
274                                (data.sequence, (unsigned)
275                                        (sizeof(char)*data.max));
276                                data.sequence[data.seq_length++]
277                                        = seq[indj];
278                        }
279                data.sequence[data.seq_length] = '\0';
280                eof=Fgetline(line, LINENUM, fp);
281                if(eof!=NULL) index = macke_abbrev(line, name, 0);
282
283        }       /* reading seq loop */
284
285        return(eof);
286}
287/* -------------------------------------------------------------- */
288/*      Function macke_abbrev().
289/*              Find the key in Macke line.
290*/
291int     
292macke_abbrev(line, key, index)
293char    *line, *key;
294int     index;
295{
296        int     indi, Skip_white_space();
297
298        /* skip white space */
299        index = Skip_white_space(line, index);
300
301        for(indi=index; line[indi]!=' '&&line[indi]!=':'
302        &&line[indi]!='\t'&&line[indi]!='\n'&&line[indi]!='\0';
303        indi++)
304                key[indi-index]=line[indi];
305
306        key[indi-index]='\0';
307        return(indi+1);
308}
309/* -------------------------------------------------------------- */
310/*      Function macke_rem_continue_line().
311/*              If there is 3 blanks at the beginning of the line,
312/*                      it is continued line.
313*/
314int
315macke_rem_continue_line(strings, index)
316char    **strings;
317int     index;
318{
319        if(strings[index][0]==':'&&strings[index][1]==' '
320        &&strings[index][2]==' ') 
321                return(1);
322        else return(0);
323}
324/* ------------------------------------------------------------- */
325/*      Function macke_in_name().
326/*              Read in next sequence name and data only.
327*/
328char
329macke_in_name(fp)
330FILE    *fp;
331{
332        static  char    line[LINENUM];
333        static  int     first_time = 1;
334        char    oldname[TOKENNUM], name[TOKENNUM];
335        char    seq[LINENUM], key[TOKENNUM];
336        char    *eof, *Reallocspace(), *Dupstr();
337        char    *Fgetline();
338        int     numofrem = 0, seqnum;
339        int     index, indj;
340        int     Cmpstr(), macke_abbrev();
341        void    Freespace();
342
343/* skip other information, file index points to seq. data */
344        if(first_time)  {
345
346                /* skip all "#" lines to where seq. data is */
347                for(eof=Fgetline(line, LINENUM, fp); 
348                eof!=NULL&&line[0]=='#'; 
349                eof=Fgetline(line, LINENUM, fp)) ;
350
351                first_time = 0;
352
353        } else if(line[0]==EOF) {
354
355                line[0]=EOF+1; 
356                first_time = 1;
357                return(EOF);   
358        }
359
360        /* read in seq. data */
361        data.macke.numofrem = numofrem;
362        data.seq_length=0;
363
364        /* read in line by line */
365        Freespace(&(data.macke.seqabbr));
366        for(index=macke_abbrev(line, name, 0),
367        data.macke.seqabbr=Dupstr(name);
368        line[0]!=EOF&&Cmpstr(data.macke.seqabbr, name)==EQ; )
369        {
370                sscanf(line+index, "%d%s", &seqnum, seq);
371                for(indj=data.seq_length; indj<seqnum; indj++)
372                        if(data.seq_length<data.max) 
373                                data.sequence[data.seq_length++]
374                                        = '.';
375                        else    {
376                                data.max += 100;
377                                data.sequence = (char*)Reallocspace
378                                (data.sequence, (unsigned)
379                                        (sizeof(char)*data.max));
380                                data.sequence[data.seq_length++]
381                                        = '.';
382                        }
383                for(indj=0; seq[indj]!='\n'&&seq[indj]!='\0';
384                indj++)
385                {
386                        if(data.seq_length<data.max)
387                                data.sequence[data.seq_length++]
388                                        = seq[indj];
389                        else    {
390                                data.max += 100;
391                                data.sequence = (char*)Reallocspace
392                                (data.sequence, (unsigned)
393                                        (sizeof(char)*data.max));
394                                data.sequence[data.seq_length++]
395                                        = seq[indj];
396                        }
397                }
398                data.sequence[data.seq_length] = '\0';
399
400                if((eof=Fgetline(line, LINENUM, fp))!=NULL) 
401                        index = macke_abbrev(line, name, 0);
402                else line[0] = EOF;
403
404        }       /* reading seq loop */
405
406        return(EOF+1);
407}
408/* ------------------------------------------------------------ */
409/*      Fucntion macke_out_header().
410/*              Output the Macke format header.
411*/
412void
413macke_out_header(fp)
414FILE    *fp;
415{
416        char    *date, *today_date();
417        void    Freespace(), Cypstr();
418
419        fprintf(fp, "#-\n#-\n#-\teditor\n");
420        date = today_date();
421        fprintf(fp, "#-\t%s#-\n#-\n", date);
422        Freespace(&date);
423}
424/* ------------------------------------------------------------ */
425/*      Fucntion macke_out0().
426/*              Output the Macke format each sequence format.
427*/
428void
429macke_out0(fp, format)
430FILE    *fp;
431int     format;
432{
433        int     Lenstr();
434        char    token[TOKENNUM], direction[TOKENNUM];
435        void    Cpystr();
436
437        if(format==PROTEIN)     {
438                Cpystr(token, "pro");
439                Cpystr(direction, "n>c");
440        } else {
441                Cpystr(direction, "5>3");
442                if(data.macke.rna_or_dna=='r')  Cpystr(token, "rna");
443                else Cpystr(token, "dna");
444        }
445        if(data.numofseq==1) {
446                fprintf(fp, "#-\tReference sequence:  %s\n", 
447                        data.macke.seqabbr);
448                fprintf(fp, "#-\tAttributes:\n");
449
450                if(Lenstr(data.macke.seqabbr)<8)
451                        fprintf(fp, 
452        "#=\t\t%s\t \tin  out  vis  prt   ord  %s  lin  %s  func ref\n", 
453                        data.macke.seqabbr, token, direction);
454                else
455                        fprintf(fp, 
456        "#=\t\t%s\tin  out  vis  prt   ord  %s  lin  %s  func ref\n", 
457                        data.macke.seqabbr, token, direction);
458
459        } else
460                if(Lenstr(data.macke.seqabbr)<8)
461                        fprintf(fp, 
462        "#=\t\t%s\t\tin  out  vis  prt   ord  %s  lin  %s  func\n", 
463                        data.macke.seqabbr, token, direction);
464                else
465                        fprintf(fp, 
466        "#=\t\t%s\tin  out  vis  prt   ord  %s  lin  %s  func\n", 
467                        data.macke.seqabbr, token, direction);
468}
469/* --------------------------------------------------------------- */
470/*      Fucntion macke_out1().
471/*              Output sequences information.
472*/
473void
474macke_out1(fp)
475FILE    *fp;
476{
477        void    macke_print_line_78(), macke_print_keyword_rem();
478        char    temp[LINENUM];
479        int     indi, indj, indk, indl, len, maxc;
480        int     last_word(), Lenstr();
481        int     lineno, macke_in_one_line();
482
483        if(Lenstr(data.macke.name)>1)   {
484                sprintf(temp, "#:%s:name:", data.macke.seqabbr);
485                macke_print_line_78(fp, temp, data.macke.name);
486        }
487        if(Lenstr(data.macke.strain)>1) {
488                sprintf(temp, "#:%s:strain:", data.macke.seqabbr);
489                macke_print_line_78(fp, temp, data.macke.strain);
490        }
491        if(Lenstr(data.macke.subspecies)>1)     {
492                sprintf(temp, "#:%s:subsp:", data.macke.seqabbr);
493                macke_print_line_78
494                        (fp, temp, data.macke.subspecies);
495        }
496        if(Lenstr(data.macke.atcc)>1)   {
497                sprintf(temp, "#:%s:atcc:", data.macke.seqabbr);
498                macke_print_line_78(fp, temp, data.macke.atcc);
499        }
500        if(Lenstr(data.macke.rna)>1)    {
501                /* old version entry */
502                sprintf(temp, "#:%s:rna:", data.macke.seqabbr);
503                macke_print_line_78(fp, temp, data.macke.rna);
504        }
505        if(Lenstr(data.macke.date)>1)   {
506                sprintf(temp, "#:%s:date:", data.macke.seqabbr);
507                macke_print_line_78(fp, temp, data.macke.date);
508        }
509        if(Lenstr(data.macke.acs)>1)    {
510                sprintf(temp, "#:%s:acs:", data.macke.seqabbr);
511                macke_print_line_78(fp, temp, data.macke.acs);
512        }
513        else    if(Lenstr(data.macke.nbk)>1)    {
514                /* old version entry */
515                sprintf(temp, "#:%s:acs:", data.macke.seqabbr);
516                macke_print_line_78(fp, temp, data.macke.nbk);
517        }
518        if(Lenstr(data.macke.author)>1) {
519                sprintf(temp, "#:%s:auth:", data.macke.seqabbr);
520                macke_print_line_78(fp, temp, data.macke.author);
521        }
522        if(Lenstr(data.macke.journal)>1)        {
523                sprintf(temp, "#:%s:jour:", data.macke.seqabbr);
524                macke_print_line_78(fp, temp, data.macke.journal);
525        }
526        if(Lenstr(data.macke.title)>1)  {
527                sprintf(temp, "#:%s:title:", data.macke.seqabbr);
528                macke_print_line_78(fp, temp, data.macke.title);
529        }
530        if(Lenstr(data.macke.who)>1)    {
531                sprintf(temp, "#:%s:who:", data.macke.seqabbr);
532                macke_print_line_78(fp, temp, data.macke.who);
533        }
534
535        /* print out remarks, wrap around if more than 78 columns */
536        for(indi=0; indi<data.macke.numofrem; indi++)   
537        {
538        /* Check if it is general comment or GenBank entry */
539        /* if general comment, macke_in_one_line return(1). */
540                if(macke_in_one_line(data.macke.remarks[indi])) 
541                {
542                        sprintf(temp,"#:%s:rem:", data.macke.seqabbr);
543                        macke_print_line_78
544                                (fp, temp, data.macke.remarks[indi]);
545                        continue;
546                }
547
548                /* if GenBank entry comments */
549                macke_print_keyword_rem(indi, fp);
550
551        }       /* for each remark */
552}
553/* ---------------------------------------------------------------- */
554/*      Function macke_print_keyword_rem().
555/*              Print out keyworded remark line in Macke file with
556/*                      wrap around functionality.
557/*              (Those keywords are defined in GenBank COMMENTS by
558/*                      RDP group)
559*/
560void
561macke_print_keyword_rem(index, fp)
562int     index;
563FILE    *fp;
564{
565        int     indj, indk, indl, lineno, len, Lenstr(), maxc;
566
567        lineno = 0;
568        len = Lenstr(data.macke.remarks[index])-1;
569        for(indj=0; indj<len; indj+=(indk+1)) {
570                indk= maxc =MACKEMAXCHAR-7
571                        -Lenstr(data.macke.seqabbr);
572                if(lineno!=0) indk = maxc = maxc - 3;
573                if((Lenstr(data.macke.remarks[index]+indj)-1)
574                > maxc) {
575                        /* Search the last word */
576                        for(indk=maxc-1; indk>=0&&
577                        !last_word(data.macke.remarks
578                        [index][indk+indj]); indk--) ; 
579
580                        if(lineno==0)   {
581                                fprintf(fp,"#:%s:rem:", 
582                                        data.macke.seqabbr); 
583                                lineno++;
584                        } else
585                                fprintf(fp,"#:%s:rem::  ", 
586                                        data.macke.seqabbr); 
587
588                        for(indl=0; indl<indk; indl++)
589                                fprintf(fp,"%c", 
590                                data.macke.remarks[index][indj+indl]);
591
592                        if(data.macke.remarks[index][indj+indk]!=' ')
593                                fprintf(fp,"%c", 
594                                data.macke.remarks[index][indj+indk]);
595                        fprintf(fp, "\n");
596
597                } else if(lineno==0)
598                        fprintf(fp,"#:%s:rem:%s", data.macke.seqabbr, 
599                                data.macke.remarks[index]+indj);
600                       else 
601                        fprintf(fp,"#:%s:rem::  %s",
602                                data.macke.seqabbr, 
603                                data.macke.remarks[index]+indj);
604        }       /* for every MACKEMAXCHAR columns */
605}
606/* --------------------------------------------------------------- */
607/*      Function macke_print_line_78().
608/*              print a macke line and wrap around line after
609/*                      78(MACKEMAXCHAR) column.
610*/
611void
612macke_print_line_78(fp, line1, line2)
613FILE    *fp;
614char    *line1, *line2;
615{
616        int     len, Lenstr(), indi, indj, indk, ibuf, last_word();
617
618        for(indi=0, len=Lenstr(line2); indi<len; indi+=indj)    {
619
620                indj=78-Lenstr(line1);
621
622                if((Lenstr(line2+indi))>indj)   {
623
624                        ibuf = indj;
625
626                        for(; indj>0&&!last_word(line2[indi+indj]);
627                        indj--) ;
628
629                        if(indj==0) indj=ibuf;
630                        else if(line2[indi+indj+1]==' ') indj++;
631
632                        fprintf(fp, "%s", line1);
633
634                        for(indk=0; indk<indj; indk++)
635                                fprintf(fp, "%c", line2[indi+indk]);
636
637                        /* print out the last char if it is not blank */
638                        if(line2[indi+indj]==' ')
639                                indj++;
640
641                        fprintf(fp, "\n");
642
643                } else fprintf(fp, "%s%s", line1, line2+indi);
644
645        }       /* for loop */
646}
647/* ----------------------------------------------------------- */
648/*      Function macke_key_word().
649/*              Find the key in Macke line.
650*/
651int     
652macke_key_word(line, index, key, length)
653char    *line;
654int     index;
655char    *key;
656int     length;
657{
658        int     indi, Skip_white_space();
659
660        if(line==NULL)  { key[0]='\0'; return(index);   }
661
662        /* skip white space */
663        index = Skip_white_space(line, index);
664
665        for(indi=index; (indi-index)<(length-1)&&line[indi]!=':'
666        &&line[indi]!='\n'&&line[indi]!='\0'; indi++)
667                key[indi-index]=line[indi];
668
669        key[indi-index]='\0';
670
671        return(indi+1);
672}
673/* ------------------------------------------------------------ */
674/*      Function macke_in_one_line().
675/*              Check if string should be in one line.
676*/
677int
678macke_in_one_line(string)
679char    *string;
680{
681        char    keyword[TOKENNUM];
682        int     macke_key_word(), iskey, Cmpstr();
683
684        macke_key_word(string, 0, keyword, TOKENNUM);
685        iskey=0;
686        if(Cmpstr(keyword, "KEYWORDS")==EQ)
687                iskey=1;
688        else if(Cmpstr(keyword, "GenBank ACCESSION")==EQ)
689                iskey=1;
690        else if(Cmpstr(keyword, "auth")==EQ)
691                iskey = 1;
692        else if(Cmpstr(keyword, "title")==EQ)
693                iskey = 1;
694        else if(Cmpstr(keyword, "jour")==EQ)
695                iskey = 1;
696        else if(Cmpstr(keyword, "standard")==EQ)
697                iskey = 1;
698        else if(Cmpstr(keyword, "Source of strain")==EQ)
699                iskey=1;
700        else if(Cmpstr(keyword, "Former name")==EQ)
701                iskey = 1;
702        else if(Cmpstr(keyword, "Alternate name")==EQ)
703                iskey = 1;
704        else if(Cmpstr(keyword, "Common name")==EQ)
705                iskey = 1;
706        else if(Cmpstr(keyword, "Host organism")==EQ)
707                iskey = 1;
708        else if(Cmpstr(keyword, "RDP ID")==EQ)
709                iskey = 1;
710        else if(Cmpstr(keyword, "Sequencing methods")==EQ)
711                iskey = 1;
712        else if(Cmpstr(keyword, "3' end complete")==EQ)
713                iskey = 1;
714        else if(Cmpstr(keyword, "5' end complete")==EQ)
715                iskey = 1;
716
717        /* is-key then could be more than one line */
718        /* otherwise, must be in one line */
719        if(iskey) return(0);
720        else return(1);
721}
722/* -------------------------------------------------------------- */
723/*      Function macke_out2().
724/*              Output Macke format sequences data.
725*/
726void
727macke_out2(fp)
728FILE    *fp;
729{
730        int     indj, indk;
731        char    temp[LINENUM];
732        void    warning();
733
734        if(data.seq_length>MACKELIMIT)
735                sprintf(temp, 
736        "Lenght of sequence data is %d over AE2's limit %d.\n", 
737                data.seq_length, MACKELIMIT);
738                warning(145, temp);
739
740        for(indk=indj=0; indk<data.seq_length; indk++) 
741        {
742                if(indj==0)
743                        fprintf(fp,"%s%6d ", 
744                        data.macke.seqabbr, indk);
745
746                fprintf(fp, "%c", 
747                        data.sequence[indk]);
748
749                indj++;
750
751                if(indj==50) { indj=0; fprintf(fp, "\n"); }
752
753        } /* every line */
754
755        if(indj!=0) fprintf(fp, "\n");
756                /* every sequence */
757}
Note: See TracBrowser for help on using the repository browser.