~ubuntu-branches/ubuntu/warty/ncbi-tools6/warty

« back to all changes in this revision

Viewing changes to desktop/prtgene.c

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2002-04-04 22:13:09 UTC
  • Revision ID: james.westby@ubuntu.com-20020404221309-vfze028rfnlrldct
Tags: upstream-6.1.20011220a
ImportĀ upstreamĀ versionĀ 6.1.20011220a

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <prtgene.h>
 
2
 
 
3
/*functions to print everything between two genes */
 
4
#include <tofile.h>
 
5
 
 
6
 
 
7
#define GENE_MARKER     1
 
8
#define SEQ_SEGMENT     2
 
9
typedef struct print_gene {
 
10
        GeneDataPtr g_data;
 
11
        FILE *fp;
 
12
        Boolean html;
 
13
        Boolean found;
 
14
        Uint1 print_loc;
 
15
        NumberingPtr np;
 
16
        Uint1 prev_type;        /*the type of the previously recorded marker*/
 
17
}PrintGene, PNTR PrintGenePtr;
 
18
 
 
19
 
 
20
static  ColData prt_col = {0, 0, 0, 'l', TRUE, TRUE, FALSE};
 
21
static  ParData prt_par = {FALSE};
 
22
 
 
23
#define MAX_HTML_SIZE 1000
 
24
static Char HTML_buffer[MAX_HTML_SIZE];
 
25
 
 
26
static void print_store_for_html PROTO((CharPtr temp, CharPtr html_buf, Int4Ptr c_pos, Int4 width, FILE *fp));
 
27
 
 
28
static void print_store_buf(CharPtr temp, CharPtr buf, Int4 buf_size, Int4Ptr cur_len, 
 
29
                                                        FILE *fp)
 
30
{
 
31
        Int4 len;
 
32
 
 
33
        len = StringLen(temp);
 
34
        if(len + (*cur_len) > buf_size)
 
35
        {
 
36
                StringCat(buf, "\n");
 
37
                SendTextToFile (fp, buf, &prt_par, &prt_col);
 
38
                *cur_len = 0;
 
39
                StringCpy(buf, temp);
 
40
        }
 
41
        else
 
42
        {
 
43
                if(*cur_len == 0)
 
44
                        StringCpy(buf, temp);
 
45
                else
 
46
                        StringCat(buf, temp);
 
47
        }
 
48
        *cur_len += len;
 
49
}
 
50
 
 
51
 
 
52
 
 
53
/**********************************************************
 
54
*
 
55
*       functions to print a feature to a FILE
 
56
*
 
57
**********************************************************/
 
58
static Boolean PrintQual(GBQualPtr qdata, FILE *fp, CharPtr buf, Int4 buf_size)
 
59
{
 
60
        Int4 len;
 
61
        Char temp[101];
 
62
 
 
63
 
 
64
        if(qdata == NULL)
 
65
                return FALSE;
 
66
        sprintf(buf, "Qualifier ");
 
67
        len = StringLen(buf);
 
68
        while(qdata)
 
69
        {
 
70
                sprintf (temp, "%s=%s ", qdata->qual, qdata->val);
 
71
                print_store_buf(temp, buf, buf_size, &len, fp);
 
72
            qdata = qdata->next;
 
73
        }
 
74
 
 
75
        if(len > 0)
 
76
        {
 
77
                StringCat(buf, "\n");
 
78
                SendTextToFile (fp, buf, &prt_par, &prt_col);
 
79
        }
 
80
 
 
81
        return TRUE;
 
82
}
 
83
 
 
84
static Boolean print_sfp_ext (SeqFeatPtr sfp, FILE *fp, CharPtr buf, Int4 buf_size)
 
85
{
 
86
        ObjectIdPtr oip;
 
87
        UserObjectPtr uop;
 
88
        UserFieldPtr ufp;
 
89
        Char temp[101];
 
90
        Int4 len;
 
91
 
 
92
        if(sfp->ext == NULL)
 
93
                return FALSE;
 
94
        uop = sfp->ext;
 
95
        len = 0;
 
96
        buf[0] = '\0';
 
97
        while(uop)
 
98
        {
 
99
                oip = uop->type;
 
100
                if(StringCmp(oip->str, "MapMarkerInfo") == 0)
 
101
                {
 
102
                        ufp = uop->data;
 
103
                        while (ufp)
 
104
                        {
 
105
                                oip = ufp->label;
 
106
                                if(StringCmp(oip->str, "Bin Order") == 0)
 
107
                                {       /* the order of the 1000:1 bin */
 
108
                                        if(ufp->choice == 2)    /*integer */
 
109
                                                sprintf(temp, "Bin Order is %ld\n", (long) ufp->data.intvalue);
 
110
                                                print_store_buf(temp, buf, buf_size, &len, fp);
 
111
                                }
 
112
                                else if(StringCmp(oip->str, "Marker Type" ) == 0)
 
113
                                {
 
114
                                        if(ufp->choice == 2)
 
115
                                        {
 
116
                                                switch (ufp->data.intvalue)
 
117
                                                {
 
118
                                                case 1:
 
119
                                                        sprintf(temp, "Framework Marker\n");
 
120
                                                        break;
 
121
                                                case 2:
 
122
                                                        sprintf(temp, "Recombination Mimimum Marker\n");
 
123
                                                        break;
 
124
                                                case 3:
 
125
                                                        sprintf(temp, "Likely Loci Marker\n");
 
126
                                                        break;
 
127
                                                case 4:
 
128
                                                        sprintf(temp, "Duplicated Marker\n");
 
129
                                                        break;
 
130
                                                case 5:
 
131
                                                        sprintf(temp, "Multiple Duplicated Marker\n");
 
132
                                                        break;
 
133
                                                case 6:
 
134
                                                        sprintf(temp, "STS Marker on YAC Contig\n");
 
135
                                                        break;
 
136
                                                default:
 
137
                                                        break;
 
138
                                                }
 
139
                                                print_store_buf(temp, buf, buf_size, &len, fp);
 
140
                                        }
 
141
                                }
 
142
 
 
143
                                else if(StringCmp(oip->str, "Marker Category" ) == 0)
 
144
                                {
 
145
                                        if(ufp->choice == 2)
 
146
                                        {
 
147
                                                switch (ufp->data.intvalue)
 
148
                                                {
 
149
                                                case 1:
 
150
                                                        sprintf(temp, "This is a YAC End\n");
 
151
                                                        break;
 
152
                                                case 2:
 
153
                                                        sprintf(temp, "This is a Random Marker\n");
 
154
                                                        break;
 
155
                                                case 3:
 
156
                                                        sprintf(temp, "This is a Genetic Marker\n");
 
157
                                                        break;
 
158
                                                case 4:
 
159
                                                        sprintf(temp, "This is a Gene Marker\n");
 
160
                                                        break;
 
161
                                                case 5:
 
162
                                                        sprintf(temp, "This is a EST Marker\n");
 
163
                                                        break;
 
164
                                                case 6:
 
165
                                                        sprintf(temp, "This is a Misc Marker\n");
 
166
                                                        break;
 
167
                                                default:
 
168
                                                        break;
 
169
                                                }
 
170
                                        }
 
171
                                        print_store_buf(temp, buf, buf_size, &len, fp);
 
172
                                }
 
173
                                ufp = ufp->next;
 
174
                        }
 
175
                }
 
176
                if(StringCmp(oip->str, "MIT RH map") == 0)
 
177
                {
 
178
                        ufp = uop->data;
 
179
                        while(ufp)
 
180
                        {
 
181
                                oip = ufp->label;
 
182
                                if(oip && StringCmp(oip->str, "STS probability") == 0)
 
183
                                {
 
184
                                        if(ufp->choice == 1)
 
185
                                                sprintf(temp, "STS probability is %s \n", 
 
186
                                                (CharPtr)(ufp->data.ptrvalue));
 
187
                                        print_store_buf(temp, buf, buf_size, &len, fp);
 
188
                                }
 
189
                                ufp = ufp->next;
 
190
                        }
 
191
                }
 
192
 
 
193
                if(StringCmp(oip->str, "Marker Category" ) == 0)
 
194
                {
 
195
                        ufp = uop->data;
 
196
                        if(ufp->choice == 2)
 
197
                        {
 
198
                                switch (ufp->data.intvalue)
 
199
                                {
 
200
                                case 1:
 
201
                                        sprintf(temp, "This is a YAC End\n");
 
202
                                        break;
 
203
                                case 2:
 
204
                                        sprintf(temp, "This is a Random Marker\n");
 
205
                                        break;
 
206
                                case 3:
 
207
                                        sprintf(temp, "This is a Genetic Marker\n");
 
208
                                        break;
 
209
                                case 4:
 
210
                                        sprintf(temp, "This is a Gene Marker\n");
 
211
                                        break;
 
212
                                case 5:
 
213
                                        sprintf(temp, "This is a EST Marker\n");
 
214
                                        break;
 
215
                                case 6:
 
216
                                        sprintf(temp, "This is a Misc Marker\n");
 
217
                                        break;
 
218
                                default:
 
219
                                        break;
 
220
                                }
 
221
                        }
 
222
                        print_store_buf(temp, buf, buf_size, &len, fp);
 
223
                }
 
224
                uop = uop->next;
 
225
        }
 
226
        if(len > 0)
 
227
                SendTextToFile (fp, buf, &prt_par, &prt_col);
 
228
                
 
229
        return TRUE;
 
230
}
 
231
 
 
232
 
 
233
 
 
234
static Boolean PrintCommonFeature(SeqFeatPtr sfp, FILE *fp, CharPtr buf, Int4 buf_size)
 
235
{
 
236
        if(sfp->title)
 
237
        {
 
238
                sprintf(buf, "Title: %s\n", sfp->title);
 
239
                SendTextToFile (fp, buf, &prt_par, &prt_col);
 
240
        }
 
241
 
 
242
        if(sfp->partial)
 
243
        {
 
244
                sprintf(buf, "Partial\n");
 
245
                SendTextToFile (fp, buf, &prt_par, &prt_col);
 
246
        }
 
247
 
 
248
        if(sfp->excpt)
 
249
        {
 
250
                sprintf(buf, "Exception\n");
 
251
                SendTextToFile (fp, buf, &prt_par, &prt_col);
 
252
        }
 
253
 
 
254
        if(sfp->comment)
 
255
        {
 
256
                sprintf(buf, "Comment: %s\n", sfp->comment);
 
257
                SendTextToFile (fp, buf, &prt_par, &prt_col);
 
258
        }
 
259
 
 
260
 
 
261
        PrintQual(sfp->qual, fp, buf, buf_size);
 
262
 
 
263
        if(sfp->exp_ev ==1)
 
264
        {
 
265
                sprintf(buf, "Experimental Result\n");
 
266
                SendTextToFile (fp, buf, &prt_par, &prt_col);
 
267
        }
 
268
 
 
269
        if(sfp->exp_ev ==2)
 
270
        {
 
271
                sprintf(buf, "Not-Experimental\n");
 
272
                SendTextToFile (fp, buf, &prt_par, &prt_col);
 
273
        }
 
274
 
 
275
 
 
276
        return TRUE;
 
277
 
 
278
}
 
279
 
 
280
static Boolean print_citation (SeqFeatPtr sfp, FILE *fp, CharPtr buf, Int4 buf_size, Boolean is_html)
 
281
{
 
282
        ValNodePtr cit, pub;
 
283
        Char temp[101];
 
284
        Boolean found;
 
285
        Int4 muid;
 
286
        Int4 len;
 
287
        Int4 index;
 
288
 
 
289
        if(sfp->cit == NULL)
 
290
                return FALSE;
 
291
        cit = sfp->cit;
 
292
        found = FALSE;
 
293
        len = 0;
 
294
        index = 0;
 
295
        while(cit)
 
296
        {
 
297
                if(cit->choice == 3)
 
298
                {
 
299
                        muid = cit->data.intvalue;
 
300
                        if(muid != 0)
 
301
                        {
 
302
                                if(found == FALSE)
 
303
                                {
 
304
                                        StringCpy(buf, "MEDLINE: ");
 
305
                                        found = TRUE;
 
306
                                        len = StringLen(buf);
 
307
                                        if(is_html)
 
308
                                                print_store_for_html(buf, NULL, &index, prt_col.width, fp);
 
309
                                }
 
310
                                if(is_html)
 
311
                                {
 
312
                                        sprintf(temp, "%ld", (long) muid);
 
313
                                        sprintf(HTML_buffer, "<a href=\"http://www3.ncbi.nlm.nih.gov:80/htbin-post/Entrez/query?-guid=%ld&form=6&db=m&Dopt=r\">", (long) muid);
 
314
                                        print_store_for_html(temp, HTML_buffer, &index, prt_col.width, fp);
 
315
                                        print_store_for_html(" ", NULL, &index, prt_col.width, fp);
 
316
                                }
 
317
                                else
 
318
                                {
 
319
                                        sprintf(temp, "%ld ", (long) muid);
 
320
                                        print_store_buf(temp, buf, buf_size, &len, fp);
 
321
                                }
 
322
                        }
 
323
                }
 
324
                else if(cit->choice == 1)
 
325
                {
 
326
                        pub = (ValNodePtr)(cit->data.ptrvalue);
 
327
                        while(pub)
 
328
                        {
 
329
                                if(pub->choice == PUB_Muid)
 
330
                                {
 
331
                                        muid = pub->data.intvalue;
 
332
                                        if(muid != 0)
 
333
                                        {
 
334
                                                if(found == FALSE)
 
335
                                                {
 
336
                                                        StringCpy(buf, "MEDLINE: ");
 
337
                                                        found = TRUE;
 
338
                                                        len = StringLen(buf);
 
339
                                                        if(is_html)
 
340
                                                                print_store_for_html(buf, NULL, &index, prt_col.width, fp);
 
341
                                                }
 
342
                                                if(is_html)
 
343
                                                {
 
344
                                                        sprintf(temp, "%ld", (long) muid);
 
345
                                                        sprintf(HTML_buffer, "<a href=\"http://www3.ncbi.nlm.nih.gov:80/htbin-post/Entrez/query?-guid=%ld&form=6&db=m&Dopt=r\">", (long) muid);
 
346
                                                        print_store_for_html(temp, HTML_buffer, &index, prt_col.width, fp);
 
347
                                                        print_store_for_html(" ", NULL, &index, prt_col.width, fp);
 
348
                                                }
 
349
                                                else
 
350
                                                {
 
351
                                                        sprintf(temp, "%ld ", (long) muid);
 
352
                                                        print_store_buf(temp, buf, buf_size, &len, fp);
 
353
                                                }
 
354
                                        }
 
355
                                }
 
356
                                pub = pub->next;
 
357
                        }
 
358
                }
 
359
                cit = cit->next;
 
360
        }
 
361
 
 
362
        if(found)
 
363
        {
 
364
                if(is_html)
 
365
                {
 
366
                        if(index > 0)
 
367
                                fprintf(fp, "\n");
 
368
                }
 
369
                else if(len > 0)
 
370
                {
 
371
                        StringCat(buf, "\n");
 
372
                        SendTextToFile (fp, buf, &prt_par, &prt_col);
 
373
                }
 
374
        }
 
375
        return found;
 
376
}
 
377
 
 
378
 
 
379
/*************************************************************
 
380
*
 
381
*       creating the html pages to the other genome mapping center
 
382
*
 
383
**************************************************************/
 
384
static CharPtr find_db_html_pointer (CharPtr db, CharPtr str)
 
385
{
 
386
        Char temp[101];
 
387
 
 
388
        if(db == NULL || str == NULL)
 
389
                return NULL;
 
390
 
 
391
        if(StringNCmp(db, "JAX", 3) == 0)
 
392
        {
 
393
                sprintf(HTML_buffer, "<a href=\"http://www.informatics.jax.org/bin/get_marker_by_symbol?%s\">", str);
 
394
                return HTML_buffer;
 
395
        }
 
396
 
 
397
        if(StringCmp(db, "Stanford") == 0 || StringCmp(db, "SHGC") == 0)
 
398
        {
 
399
                if(StringNCmp(str, "SHGC", 4) == 0)
 
400
                {
 
401
                        sprintf(HTML_buffer, "<a href=\"http://www-shgc.stanford.edu/cgi-bin/getSTSinfo?%s\">", str);
 
402
                        return HTML_buffer;
 
403
                }
 
404
                if(StringNCmp(str, "STSG-", 5) == 0)
 
405
                {       /*old name format for the STSG*/
 
406
                        StringCpy(temp, "SHGC-");
 
407
                        StringCat(temp, str+5);
 
408
                        sprintf(HTML_buffer, "<a href=\"http://www-shgc.stanford.edu/cgi-bin/getSTSinfo?%s\">", temp);
 
409
                        return HTML_buffer;
 
410
                }
 
411
 
 
412
                return NULL;
 
413
        }
 
414
 
 
415
        if(StringCmp(db, "MIT") == 0 )
 
416
        {
 
417
                if(StringNCmp(str, "WI-", 3) == 0)
 
418
                {
 
419
                        sprintf(HTML_buffer, "<a href=\"http://www-genome.wi.mit.edu/cgi-bin/"
 
420
                        "contig/sts_info?sts=%s&database=release\">", str);
 
421
                        return HTML_buffer;
 
422
                }
 
423
                return NULL;
 
424
        }
 
425
 
 
426
        if(StringCmp(db, "CHLC") == 0)
 
427
        {
 
428
                if(StringNCmp(str, "GATA", 4) == 0)
 
429
                {
 
430
                        sprintf(HTML_buffer, "<a href=\"http://www.chlc.org/cgi-bin/"
 
431
                        "MarkerSearch?%s\">", str);
 
432
                        return HTML_buffer;
 
433
                }
 
434
                return NULL;
 
435
        }
 
436
 
 
437
 
 
438
        return NULL;
 
439
}
 
440
 
 
441
 
 
442
static Boolean print_gene_dblst(ValNodePtr db, FILE *fp, CharPtr buf, Int4 buf_size, Uint1 match_type, Boolean is_html)
 
443
{
 
444
        DbtagPtr dbtag;
 
445
        ObjectIdPtr oip;
 
446
        ValNodePtr curr;
 
447
        Int4 len;
 
448
        Char temp[101];
 
449
        Char separator[3];
 
450
        CharPtr html_buf;
 
451
        Int4 index;
 
452
        SeqIdPtr t_sip;
 
453
        Int4 gi;
 
454
 
 
455
        if(db == NULL)
 
456
                return FALSE;
 
457
 
 
458
        StringCpy(buf, "Other Databases: ");
 
459
        len = StringLen(buf);
 
460
        if(is_html)
 
461
        {
 
462
                fprintf(fp, "%s", buf);
 
463
                index = len;
 
464
        }
 
465
 
 
466
 
 
467
        for(curr = db; curr != NULL; curr = curr->next)
 
468
        {
 
469
                html_buf = NULL;
 
470
                dbtag = curr->data.ptrvalue;
 
471
                oip = dbtag->tag;
 
472
                if(is_html)
 
473
                {
 
474
                        if(StringICmp(dbtag->db, "GDB") == 0 && oip->id > 0)
 
475
                        {
 
476
                                sprintf(HTML_buffer, "<a href=\"http://gdbwww.gdb.org/"
 
477
                                "gdb-bin/genera/genera/hgd/DBObject/"
 
478
                                "GDB:%ld\">", (long) oip->id);
 
479
 
 
480
                                html_buf = HTML_buffer;
 
481
                        }
 
482
                        else if(StringICmp(dbtag->db, "MIM") == 0 && oip->id > 0)
 
483
                        {
 
484
                                sprintf(HTML_buffer, "<a href=\"http://www3.ncbi.nlm.nih.gov/htbin-post/Omim/dispmim?"
 
485
                                "%ld\">",(long) oip->id);
 
486
                                html_buf = HTML_buffer;
 
487
                        }
 
488
                        else if(StringICmp(dbtag->db, "GenBank") == 0 && oip->str != NULL)
 
489
                        {
 
490
                                t_sip = gb_id_make(NULL, oip->str);
 
491
                                gi = GetGIForSeqId (t_sip);
 
492
                                if(gi > 0)
 
493
                                {
 
494
                                        sprintf(HTML_buffer, "<a href=\"http://www3.ncbi.nlm.nih.gov/"
 
495
                                                "htbin-post/Entrez/query?form=6&dopt=g&db=n&"
 
496
                                                "uid=%08ld\">",(long) gi);
 
497
                                        html_buf = HTML_buffer;
 
498
                                }
 
499
                                SeqIdFree(t_sip);
 
500
                        }
 
501
                        else if(oip->str != NULL)
 
502
                                html_buf = find_db_html_pointer (dbtag->db, oip->str);
 
503
                }
 
504
                if(curr->next == NULL)
 
505
                        separator[0] = '\0';
 
506
                else
 
507
                        StringCpy(separator, " ");
 
508
                if(oip->str)
 
509
                {
 
510
                        if(StringICmp(dbtag->db, "GenBank") == 0 || 
 
511
                                match_type == MATCH_NONE)
 
512
                                sprintf(temp, "%s %s%s", dbtag->db, oip->str, separator);
 
513
                        else
 
514
                        {
 
515
                                if(match_type == MATCH_QUERY)
 
516
                                        sprintf(temp, "%s [%s]%s", dbtag->db, oip->str, separator);
 
517
                                else if(match_type == MATCH_ALIGN)
 
518
                                        sprintf(temp, "%s (%s)%s", dbtag->db, oip->str, separator);
 
519
                        }
 
520
                }
 
521
                else
 
522
                        sprintf(temp, "%s %ld%s", dbtag->db, (long) oip->id, separator);
 
523
                if(is_html)
 
524
                {
 
525
                        if(curr->next == NULL)
 
526
                                StringCat(temp, "\n");
 
527
                        print_store_for_html(temp, html_buf, &index, prt_col.width, fp);
 
528
                        print_store_for_html(" ", NULL, &index, prt_col.width, fp);
 
529
                }
 
530
                else
 
531
                        print_store_buf(temp, buf, buf_size, &len, fp);
 
532
        }
 
533
        if(len > 0 && !is_html)
 
534
        {
 
535
                StringCat(buf, "\n");
 
536
                SendTextToFile (fp, buf, &prt_par, &prt_col);
 
537
        }
 
538
        return TRUE;
 
539
}
 
540
 
 
541
static Boolean print_gene_synonym(ValNodePtr syn, FILE *fp, CharPtr buf, Int4 buf_size, Uint1 match_type)
 
542
{
 
543
        ValNodePtr curr;
 
544
        CharPtr str;
 
545
        Char temp[101];
 
546
        Int4 len;
 
547
 
 
548
        if(syn == NULL)
 
549
                return FALSE;
 
550
        StringCpy(buf, "Synonym: ");
 
551
        len = StringLen(buf);
 
552
        for(curr = syn; curr != NULL; curr = curr->next)
 
553
        {
 
554
                str = curr->data.ptrvalue;
 
555
                if(match_type == MATCH_QUERY)
 
556
                        sprintf(temp, "[%s] ", str);
 
557
                else if(match_type == MATCH_ALIGN)
 
558
                        sprintf(temp, "(%s) ", str);
 
559
                else
 
560
                        sprintf(temp, "%s ", str);
 
561
                print_store_buf(temp, buf, buf_size, &len, fp);
 
562
        }
 
563
        if(len > 0)
 
564
        {
 
565
                StringCat(buf, "\n");
 
566
                SendTextToFile(fp, buf, &prt_par, &prt_col);
 
567
        }
 
568
        return TRUE;
 
569
}
 
570
 
 
571
 
 
572
/************************************************************
 
573
*
 
574
* PrintGeneRefToFile(sfp, fp, match_type, print_loc, np)
 
575
*       print all the data associated with sfp to a file
 
576
*       sfp: the Seqfeat of type Gene-ref
 
577
*       fp: the FILE
 
578
*       match_type: the marker matches any query gene. If 
 
579
*       it matches directly (MATCH_QUERY), will be shown as [marker], 
 
580
*       if it matches via alignment (MATCH_ALIGN), will be shown 
 
581
*       as (marker). Otherwise,nothing will be shown
 
582
*       print_loc: print the location of the marker. PRINT_LOC_BOGO
 
583
*       directly print out the bogo base pair. PRINT_LOC_NUM, 
 
584
*       print out the location as the Numbering system
 
585
*       np the numbering system
 
586
*
 
587
***********************************************************/ 
 
588
static Boolean PrintGeneRefToFile(SeqFeatPtr sfp, FILE *fp, Uint1 match_type, Uint1 print_loc, NumberingPtr np, Boolean is_html)
 
589
{
 
590
        GeneRefPtr grp;
 
591
        Char buf[1001];
 
592
        SeqIdPtr sip;
 
593
        DbtagPtr db_tag;
 
594
        CharPtr html_buf;
 
595
 
 
596
        PrintCommonFeature(sfp, fp, buf, 1000);
 
597
        grp = sfp->data.value.ptrvalue;
 
598
        if(grp)
 
599
        {
 
600
                /* print out the locus name */
 
601
                if(grp->locus)
 
602
                {
 
603
                        html_buf = NULL;
 
604
                        if(is_html)
 
605
                        {
 
606
                                html_buf = NULL;
 
607
                                sip = SeqLocId(sfp->location);
 
608
                                if(sip->choice == SEQID_GENERAL)
 
609
                                {
 
610
                                        db_tag = sip->data.ptrvalue;
 
611
                                        if(db_tag->db != NULL)
 
612
                                                html_buf = find_db_html_pointer (db_tag->db, grp->locus);
 
613
                                }
 
614
                        }
 
615
 
 
616
 
 
617
                        if(match_type == MATCH_QUERY)
 
618
                        {
 
619
                                if(is_html)
 
620
                                {
 
621
                                        if(html_buf != NULL)
 
622
                                                fprintf(fp, "Locus: %s<B>%s</B></a>\n", html_buf, grp->locus);
 
623
                                        else
 
624
                                                fprintf(fp, "Locus: <B>%s</B>\n", grp->locus);
 
625
                                }
 
626
                                else
 
627
                                        fprintf(fp, "Locus: [%s]\n", grp->locus);
 
628
                        }
 
629
                        else
 
630
                        {
 
631
                                if(is_html && html_buf != NULL)
 
632
                                        fprintf(fp, "Locus: %s%s</a>\n", html_buf, grp->locus);
 
633
                                else
 
634
                                        fprintf(fp, "Locus: %s\n",  grp->locus);
 
635
                        }
 
636
                }
 
637
                if(grp->desc)
 
638
                {
 
639
                        sprintf(buf, "Description: %s\n", grp->desc);
 
640
                        SendTextToFile (fp, buf, &prt_par, &prt_col);
 
641
                }
 
642
 
 
643
                if(grp->syn)
 
644
                        print_gene_synonym(grp->syn, fp, buf, 1000, match_type);
 
645
 
 
646
                if(grp->db)
 
647
                        print_gene_dblst(grp->db, fp, buf, 1000, match_type, is_html);
 
648
                if(grp->allele)
 
649
                        fprintf(fp, "Allele: %s\n", grp->allele);
 
650
                if(grp->maploc)
 
651
                        fprintf(fp, "MapLoc: %s\n", grp->maploc);
 
652
 
 
653
                if(grp->pseudo)
 
654
                        fprintf(fp, "Pseudo Gene\n");
 
655
 
 
656
        }
 
657
        print_citation (sfp, fp, buf, 1000, is_html);
 
658
        print_sfp_ext (sfp, fp, buf, 1000);
 
659
 
 
660
        if(print_loc == PRINT_LOC_BOGO || np == NULL)
 
661
        {
 
662
                fprintf(fp, "Region %ld-%ld\n", (long) SeqLocStart(sfp->location), 
 
663
                        (long) SeqLocStop(sfp->location));
 
664
        }
 
665
        else if(print_loc == PRINT_LOC_NUM)
 
666
        {
 
667
                if(np != NULL)
 
668
                {
 
669
                        map_unit_label(SeqLocStart(sfp->location), np, buf, FALSE);
 
670
                        fprintf(fp, "Region %s\n", buf);
 
671
                }
 
672
        }
 
673
        fprintf(fp, "\n");
 
674
        return TRUE;
 
675
 
 
676
}
 
677
 
 
678
CharPtr WWW_PrintGeneRef(SeqFeatPtr sfp, Uint1 match_type, Uint1 print_loc, NumberingPtr np, Boolean is_html)
 
679
{
 
680
        GeneRefPtr grp = NULL;
 
681
        SeqIdPtr sip;
 
682
        DbtagPtr db_tag;
 
683
        CharPtr html_buf, text = NULL;
 
684
 
 
685
        if (sfp == NULL) {
 
686
                return NULL;
 
687
        }
 
688
        if (sfp->data.choice == SEQFEAT_GENE) {
 
689
                grp = sfp->data.value.ptrvalue;
 
690
        }
 
691
        if(grp == NULL) {
 
692
                return NULL;
 
693
        }
 
694
        if(grp->locus)
 
695
        {
 
696
                html_buf = NULL;
 
697
                if(is_html)
 
698
                {
 
699
                        html_buf = NULL;
 
700
                        sip = SeqLocId(sfp->location);
 
701
                        if(sip->choice == SEQID_GENERAL)
 
702
                        {
 
703
                                db_tag = sip->data.ptrvalue;
 
704
                                if(db_tag->db != NULL)
 
705
                                        html_buf = find_db_html_pointer (db_tag->db, grp->locus);
 
706
                        }
 
707
                }
 
708
 
 
709
 
 
710
                if(match_type == MATCH_QUERY)
 
711
                {
 
712
                        if(is_html)
 
713
                        {
 
714
                                if(html_buf != NULL) {
 
715
                                        text = MemNew(StringLen(html_buf) + StringLen(grp->locus) + 20);
 
716
                                        sprintf(text, "Locus: %s<B>%s</B></a>\n", html_buf, grp->locus);
 
717
                                } else {
 
718
                                        text = MemNew(StringLen(grp->locus) + 20);
 
719
                                        sprintf(text, "Locus: <B>%s</B>", grp->locus);
 
720
                                }
 
721
                        } else {
 
722
                                text = MemNew(StringLen(grp->locus) + 20);
 
723
                                sprintf(text, "Locus: [%s]\n", grp->locus);
 
724
                        }
 
725
                } else {
 
726
                        if(is_html && html_buf != NULL) {
 
727
                                text = MemNew(StringLen(html_buf) + StringLen(grp->locus) + 20);
 
728
                                sprintf(text, "Locus: %s%s</a>\n", html_buf, grp->locus);
 
729
                        } else {
 
730
                                text = MemNew(StringLen(grp->locus) + 20);
 
731
                                sprintf(text, "Locus: %s",  grp->locus);
 
732
                        }
 
733
                }
 
734
        }
 
735
        if(grp->desc)
 
736
        {
 
737
                text = MemNew(StringLen(grp->desc) + 30);
 
738
                sprintf(text, "Description: %s", grp->desc);
 
739
        }
 
740
        return text;
 
741
 
 
742
}
 
743
 
 
744
static void print_store_for_html(CharPtr temp, CharPtr html_buf, Int4Ptr c_pos, Int4 width, FILE *fp)
 
745
{
 
746
        Int4 t_len;
 
747
        CharPtr str;
 
748
        Int4 from, to;
 
749
        Char white_sp;
 
750
        Char str_val[201];
 
751
 
 
752
        t_len = StringLen(temp);
 
753
        if(t_len + (*c_pos) <= width)
 
754
        {
 
755
                if(html_buf != NULL)
 
756
                        fprintf(fp, "%s", html_buf);
 
757
                fprintf(fp, "%s", temp);
 
758
                if(html_buf != NULL)
 
759
                        fprintf(fp, "</a>");
 
760
 
 
761
                *c_pos += t_len;
 
762
                if(*c_pos == width)
 
763
                {
 
764
                        fprintf(fp, "<br>");
 
765
                        fprintf(fp, "\n");
 
766
                        *c_pos = 0;
 
767
                }
 
768
        }
 
769
        else
 
770
        {
 
771
                if(html_buf != NULL)
 
772
                        fprintf(fp, "%s", html_buf);
 
773
                white_sp = '\0';
 
774
                t_len = 0;
 
775
                from = 0;
 
776
                to = -1;
 
777
                for(str = temp; str != NULL && *str !='\0'; ++str)
 
778
                {
 
779
                        if(IS_WHITESP(*str))
 
780
                        {
 
781
                                if(t_len > 0)
 
782
                                {
 
783
                                        if((to - from +1) + t_len + *c_pos > width)
 
784
                                        {
 
785
                                                StringNCpy(str_val, temp+from, to-from+1);
 
786
                                                str_val[to-from+1] = '\0';
 
787
                                                fprintf(fp, "%s\n", str_val);
 
788
                                                *c_pos = 0;
 
789
                                                from = to+1;
 
790
                                        }
 
791
                                        to += (t_len +1);
 
792
                                        if(*str == '\n')
 
793
                                        {
 
794
                                                StringNCpy(str_val, temp+from, to-from+1);
 
795
                                                str_val[to-from+1] = '\0';
 
796
                                                fprintf(fp, "%s", str_val);
 
797
                                                *c_pos = 0;
 
798
                                                from = to +1;
 
799
                                        }
 
800
                                        
 
801
                                }
 
802
                                else
 
803
                                {
 
804
                                        to += 1;
 
805
                                }
 
806
                                t_len = 0;
 
807
                                white_sp = *str;
 
808
 
 
809
                        }
 
810
                        else
 
811
                                ++t_len;
 
812
                }
 
813
 
 
814
                if(to - from +1 > 0)
 
815
                {
 
816
                        *c_pos += to - from +1;
 
817
                        StringNCpy(str_val, temp+from, to-from+1);
 
818
                        str_val[to-from+1] = '\0';
 
819
                        fprintf(fp, "%s", str_val);
 
820
                        if(html_buf != NULL)
 
821
                                fprintf(fp, "</a>");
 
822
 
 
823
                        if(*c_pos == width)
 
824
                        {
 
825
                                fprintf(fp, "<br>");
 
826
                                fprintf(fp, "\n");
 
827
                                *c_pos =0;
 
828
                        }
 
829
                }
 
830
                if(html_buf != NULL)
 
831
                        fprintf(fp, "</a>");
 
832
        }
 
833
}
 
834
 
 
835
 
 
836
 
 
837
static void print_seqid PROTO((SeqIdPtr sip, CharPtr buf, Int2 buf_size));
 
838
 
 
839
static Boolean print_store_seqid(SeqIdPtr sip, CharPtr buf, Int4 buf_size, Int4Ptr len, FILE *fp, Boolean is_html, Int4Ptr index, Boolean first)
 
840
{
 
841
        Char temp[101];
 
842
        CharPtr html_buf;
 
843
        DbtagPtr db_tag;
 
844
        ObjectIdPtr oip;
 
845
 
 
846
        if(sip == NULL)
 
847
                return FALSE;
 
848
        if(!first)
 
849
        {
 
850
                StringCpy(temp, " ");
 
851
                if(is_html)
 
852
                        print_store_for_html(temp, NULL, index, (Int4)(prt_col.width), fp);
 
853
                else
 
854
                        print_store_buf(temp, buf, buf_size, len, fp);
 
855
        }
 
856
        html_buf = NULL;
 
857
 
 
858
        if(sip->choice == SEQID_GI)
 
859
        {
 
860
                MuskSeqIdWrite(sip, temp, 100, PRINTID_TEXTID_ACCESSION, TRUE, TRUE);
 
861
                if(is_html)
 
862
                {
 
863
                        sprintf(HTML_buffer, "<a href=\"http://www3.ncbi.nlm.nih.gov/"
 
864
                "htbin-post/Entrez/query?form=6&dopt=g&db=n&"
 
865
                 "uid=%08ld\">", (long) sip->data.intvalue);
 
866
                        html_buf = HTML_buffer;
 
867
                }
 
868
        }
 
869
        else 
 
870
        {
 
871
                if(sip->choice == SEQID_GENERAL)
 
872
                {
 
873
                        db_tag = sip->data.ptrvalue;
 
874
                        if(is_html && StringICmp(db_tag->db, "UNIGENE") == 0)
 
875
                        {
 
876
                                oip = db_tag->tag;
 
877
                                sprintf(HTML_buffer, "<a href=\"http://www.ncbi.nlm.nih.gov/"
 
878
                "cgi-bin/Schuler/clust2html?Homo+sapiens+%ld\">",(long) oip->id);
 
879
                                html_buf = HTML_buffer;
 
880
                        }
 
881
                        print_seqid (sip, temp, 100);
 
882
                }
 
883
                else
 
884
                        MuskSeqIdWrite(sip, temp, 100, PRINTID_TEXTID_ACCESSION, FALSE, FALSE);
 
885
        }
 
886
 
 
887
        if(is_html)
 
888
                print_store_for_html(temp, html_buf, index, (Int4)(prt_col.width), fp);
 
889
        else
 
890
                print_store_buf(temp, buf, buf_size, len, fp);
 
891
        return TRUE;
 
892
}
 
893
 
 
894
static Boolean fetch_this_bioseq(SeqIdPtr sip)
 
895
{
 
896
        ObjectIdPtr oip;
 
897
        DbtagPtr db_tag;
 
898
 
 
899
        if(sip->choice == SEQID_LOCAL)
 
900
        {
 
901
                oip = sip->data.ptrvalue;
 
902
                if(oip->str)
 
903
                        return (StringNCmp(oip->str, "HGM", 3) == 0);
 
904
        }
 
905
        else if(sip->choice == SEQID_GENERAL)
 
906
        {
 
907
                db_tag = sip->data.ptrvalue;
 
908
                if(StringCmp(db_tag->db, "HUMGEN") == 0)
 
909
                {
 
910
                        oip = db_tag->tag;
 
911
                        return (oip->id > 0);
 
912
                }
 
913
        }
 
914
 
 
915
        return FALSE;
 
916
}
 
917
 
 
918
static Boolean PrintSequenceToFile(SeqLocPtr slp, FILE *fp, Uint1 print_loc, NumberingPtr np, GatherRangePtr grp, Boolean is_html)
 
919
{
 
920
        SeqIdPtr sip;
 
921
        BioseqPtr bsp;
 
922
        SeqAlignPtr align;
 
923
        Int4 len;
 
924
        Char temp[101];
 
925
        Char temp_1[41], temp_2[41];
 
926
        DenseSegPtr dsp;
 
927
        Char buf[1001];
 
928
        Int4 buf_size = 1000;
 
929
        Int4 index = 0;
 
930
        Boolean first;
 
931
        SeqLocPtr t_slp;
 
932
 
 
933
        if(slp == NULL)
 
934
                return FALSE;
 
935
        sip = SeqLocId(slp);
 
936
        len = 0;
 
937
        print_store_seqid(sip, buf, buf_size, &len, fp, is_html, &index, TRUE);
 
938
 
 
939
 
 
940
        if(print_loc != PRINT_LOC_NONE)
 
941
        {       /*print out the location on the genome */
 
942
                if(print_loc == PRINT_LOC_BOGO || np == NULL)
 
943
                        sprintf(temp, ": %ld - %ld (bp)", (long) grp->left, (long) grp->right);
 
944
                else
 
945
                {
 
946
 
 
947
                        map_unit_label(grp->left, np, temp_1, FALSE);
 
948
                        map_unit_label(grp->right, np, temp_2, FALSE);
 
949
 
 
950
                        sprintf(temp, ": %s - %s (bp) on the genome", temp_1, temp_2);
 
951
                }
 
952
                if(is_html)
 
953
                {
 
954
                        StringCat(temp, "<br>");
 
955
                        StringCat(temp, "\n");
 
956
                        print_store_for_html(temp, NULL, &index, (Int4)prt_col.width, fp);
 
957
                }
 
958
                else
 
959
                        print_store_buf(temp, buf, buf_size, &len, fp);
 
960
        }
 
961
        if(len > 0)
 
962
        {
 
963
                StringCat(buf, "\n");
 
964
                SendTextToFile (fp, buf, &prt_par, &prt_col);
 
965
        }
 
966
 
 
967
        if(fetch_this_bioseq(sip))
 
968
        {       /* fetch the hum-gen record */
 
969
                bsp = BioseqLockById(sip);
 
970
                if(bsp != NULL)
 
971
                {
 
972
                        if(bsp->hist != NULL)
 
973
                        {
 
974
                                len = 0;
 
975
                                index = 0;
 
976
                                align = bsp->hist->assembly;
 
977
                                first = TRUE;
 
978
                                while(align)
 
979
                                {
 
980
                                        if(align->segtype == 2)
 
981
                                        {
 
982
                                                dsp = align->segs;
 
983
                                                sip = dsp->ids->next;
 
984
                                                print_store_seqid(sip, buf, buf_size, &len, fp, is_html, &index, first);
 
985
                                                first = FALSE;
 
986
                                        }
 
987
                                        align = align->next;
 
988
                                }
 
989
                                if(!is_html)
 
990
                                {
 
991
                                        if(len > 0)
 
992
                                        {
 
993
                                                StringCat(buf, "\n");
 
994
                                                SendTextToFile (fp, buf, &prt_par, &prt_col);
 
995
                                        }
 
996
                                }
 
997
                                else if(index > 0) {
 
998
                                        fprintf(fp, "<br>");
 
999
                                        fprintf(fp, "\n");
 
1000
                                }
 
1001
                        }
 
1002
                        else if(bsp->repr == Seq_repr_seg && bsp->seq_ext_type == 1)
 
1003
                        {
 
1004
                                t_slp = bsp->seq_ext;
 
1005
                                len = 0;
 
1006
                                index = 0;
 
1007
                                first = TRUE;
 
1008
                                while(t_slp)
 
1009
                                {
 
1010
                                        if(SeqLocId(t_slp) != NULL)
 
1011
                                                print_store_seqid(SeqLocId(t_slp), buf, buf_size, &len, fp, is_html, &index, first);
 
1012
                                        first = FALSE;
 
1013
                                        t_slp = t_slp->next;
 
1014
                                }
 
1015
                
 
1016
                                if(!is_html)
 
1017
                                {
 
1018
                                        if(len > 0)
 
1019
                                        {
 
1020
                                                StringCat(buf, "\n");
 
1021
                                                SendTextToFile (fp, buf, &prt_par, &prt_col);
 
1022
                                        }
 
1023
                                }
 
1024
                                else if(index > 0) {
 
1025
                                        fprintf(fp, "<br>");
 
1026
                                        fprintf(fp, "\n");
 
1027
                                }
 
1028
                        }
 
1029
                        BioseqUnlock(bsp);
 
1030
                }
 
1031
        }
 
1032
        if(is_html)
 
1033
                fprintf(fp, "<br>");
 
1034
        fprintf(fp, "\n");
 
1035
 
 
1036
        return TRUE;
 
1037
}
 
1038
 
 
1039
 
 
1040
 
 
1041
 
 
1042
 
 
1043
        
 
1044
 
 
1045
 
 
1046
 
 
1047
 
 
1048
static Boolean is_sfp_query_gene (GeneDataPtr gdata, Uint2 itemID, 
 
1049
                                                                  Uint2 entityID, Uint2 itemType)
 
1050
{
 
1051
        while(gdata)
 
1052
        {
 
1053
                if(gdata->entityID == entityID && gdata->itemID == itemID && 
 
1054
                        gdata->itemType == itemType)
 
1055
                        return TRUE;
 
1056
                gdata = gdata->next;
 
1057
        }
 
1058
 
 
1059
        return FALSE;
 
1060
}
 
1061
 
 
1062
static Boolean is_loc_match_align (GeneDataPtr gdata, SeqFeatPtr sfp)
 
1063
{
 
1064
        StdSegPtr ssp;
 
1065
        SeqLocPtr slp;
 
1066
 
 
1067
        while(gdata)
 
1068
        {
 
1069
                if(gdata->align_seg != NULL)
 
1070
                {
 
1071
                        ssp = gdata->align_seg->data.ptrvalue;
 
1072
                        for(slp = ssp->loc; slp != NULL; slp = slp->next)
 
1073
                        {
 
1074
                                if(SeqLocCompare (slp, sfp->location) == SLC_A_EQ_B)
 
1075
                                        return TRUE;
 
1076
                        }
 
1077
                }
 
1078
                gdata = gdata->next;
 
1079
        }
 
1080
 
 
1081
        return FALSE;
 
1082
}
 
1083
 
 
1084
 
 
1085
 
 
1086
static void print_seqid (SeqIdPtr sip, CharPtr buf, Int2 buf_size)
 
1087
{
 
1088
        DbtagPtr db_tag;
 
1089
        ObjectIdPtr oip;
 
1090
 
 
1091
        if(sip->choice == SEQID_GENERAL)
 
1092
        {
 
1093
                db_tag = sip->data.ptrvalue;
 
1094
                oip = db_tag->tag;
 
1095
                if(oip->str != NULL)
 
1096
                        sprintf(buf, "%s %s", db_tag->db, oip->str);
 
1097
                else
 
1098
                        sprintf(buf, "%s %ld", db_tag->db, (long) oip->id);
 
1099
        }
 
1100
        else
 
1101
                SeqIdWrite(sip, buf, PRINTID_TEXTID_ACCESSION, buf_size);
 
1102
}
 
1103
 
 
1104
 
 
1105
static void print_bioseq_descriptor (BioseqPtr bsp, SeqLocPtr slp, FILE *fp, Int2 line_len)
 
1106
{
 
1107
        Int2 i;
 
1108
        Char buf[1001];
 
1109
        ValNodePtr descr;
 
1110
 
 
1111
        for(i =0; i<line_len; ++i)
 
1112
                fprintf(fp, "*");
 
1113
        fprintf(fp, "\n");
 
1114
        print_seqid (bsp->id, buf, 1000);
 
1115
        fprintf(fp, "%s\n", buf);
 
1116
 
 
1117
        for(descr = bsp->descr; descr != NULL; descr = descr->next)
 
1118
        {
 
1119
                if(descr->choice == Seq_descr_title || descr->choice == Seq_descr_name)
 
1120
                {
 
1121
                        sprintf(buf, "%s\n", (CharPtr)(descr->data.ptrvalue));
 
1122
                        SendTextToFile(fp, buf, &prt_par, &prt_col);
 
1123
                }
 
1124
        }
 
1125
        sprintf (buf, "Region: %ld-%ld(bp) on the Chromosome\n", (long) SeqLocStart(slp), (long) SeqLocStop(slp));
 
1126
        SendTextToFile(fp, buf, &prt_par, &prt_col);
 
1127
        for(i =0; i<line_len; ++i)
 
1128
                fprintf(fp, "*");
 
1129
        fprintf(fp, "\n");
 
1130
 
 
1131
}
 
1132
 
 
1133
 
 
1134
static Boolean prtgenefunc(GatherContextPtr gcp)
 
1135
{
 
1136
 
 
1137
        PrintGenePtr pgp;
 
1138
        SeqFeatPtr sfp;
 
1139
        Uint1 match_type;
 
1140
        SeqLocPtr slp;
 
1141
 
 
1142
        if(gcp == NULL)
 
1143
                return FALSE;
 
1144
 
 
1145
        pgp = (PrintGenePtr)(gcp->userdata);
 
1146
        if(pgp == NULL)
 
1147
                return FALSE;
 
1148
 
 
1149
        switch(gcp->thistype)
 
1150
        {
 
1151
        case OBJ_SEQFEAT:
 
1152
        case OBJ_BIOSEQ_MAPFEAT:
 
1153
 
 
1154
                sfp = (SeqFeatPtr)(gcp->thisitem);
 
1155
                if(sfp == NULL || sfp->data.choice != 1)
 
1156
                        return TRUE;
 
1157
 
 
1158
                match_type = MATCH_NONE;
 
1159
                if(is_sfp_query_gene (pgp->g_data, gcp->itemID,
 
1160
                        gcp->entityID, gcp->thistype))
 
1161
                        match_type = MATCH_QUERY;
 
1162
                else if (is_loc_match_align (pgp->g_data, sfp))
 
1163
                        match_type = MATCH_ALIGN;
 
1164
                if(pgp->prev_type != GENE_MARKER)
 
1165
                {
 
1166
                        pgp->prev_type = GENE_MARKER;
 
1167
                        fprintf(pgp->fp, "\nSTS Markers\n\n");
 
1168
                }
 
1169
 
 
1170
                PrintGeneRefToFile(sfp, pgp->fp, match_type, pgp->print_loc, pgp->np, pgp->html);
 
1171
                pgp->found = TRUE;
 
1172
                break;
 
1173
 
 
1174
        case OBJ_BIOSEQ_SEG:    /*segments of a segmented sequence*/
 
1175
                slp = (SeqLocPtr)(gcp->thisitem);
 
1176
                if(!is_map_segment(slp))
 
1177
                {
 
1178
                        if(pgp->prev_type != SEQ_SEGMENT)
 
1179
                        {
 
1180
                                pgp->prev_type = SEQ_SEGMENT;
 
1181
                                fprintf(pgp->fp, "\nSequence Data\n\n");
 
1182
                        }
 
1183
 
 
1184
                        PrintSequenceToFile(slp, pgp->fp, pgp->print_loc, pgp->np, &(gcp->extremes), pgp->html);
 
1185
                        pgp->found = TRUE;
 
1186
                }
 
1187
                break;
 
1188
        default:
 
1189
                break;
 
1190
        }
 
1191
        return TRUE;
 
1192
}
 
1193
 
 
1194
 
 
1195
/******************************************************************
 
1196
*
 
1197
*       print the everything in the interval slp to a text file
 
1198
*       slp: the interval
 
1199
*       g_data: the query gene
 
1200
*       is_html: make it a html page
 
1201
*       line_len; the length of the file
 
1202
*       fp: the output file
 
1203
*
 
1204
********************************************************************/   
 
1205
Boolean print_genome_interval(SeqLocPtr slp, GeneDataPtr g_data, Boolean is_html, Int2 line_len, FILE *fp)
 
1206
{
 
1207
        GatherScope gs;
 
1208
        PrintGene pg;
 
1209
        SeqEntryPtr sep;
 
1210
        BioseqPtr bsp;
 
1211
 
 
1212
        if(slp == NULL || fp == NULL)
 
1213
                return FALSE;
 
1214
        sep = SeqEntryFind(SeqLocId(slp));
 
1215
        if(sep == NULL)
 
1216
                return FALSE;
 
1217
        bsp = BioseqFind(SeqLocId(slp));
 
1218
        if(bsp == NULL)
 
1219
                return FALSE;
 
1220
 
 
1221
        pg.g_data = g_data;
 
1222
        pg.html = is_html;
 
1223
        pg.fp = fp;
 
1224
        pg.found = FALSE;
 
1225
        pg.print_loc = PRINT_LOC_NUM;
 
1226
        pg.np = getBioseqNumbering(bsp);
 
1227
        pg.prev_type = 0;
 
1228
 
 
1229
        prt_col.width = line_len;
 
1230
        print_bioseq_descriptor (bsp, slp, fp, line_len);
 
1231
 
 
1232
        
 
1233
        MemSet((Pointer)(&gs), 0, sizeof(GatherScope));
 
1234
        MemSet((Pointer)(gs.ignore), (int)(TRUE), (size_t)OBJ_MAX * sizeof(Boolean));
 
1235
        gs.ignore[OBJ_SEQFEAT] = FALSE;
 
1236
        gs.ignore[OBJ_SEQANNOT] = FALSE;
 
1237
        gs.ignore[OBJ_BIOSEQ_MAPFEAT] = FALSE;
 
1238
        gs.ignore[OBJ_BIOSEQ] = FALSE;
 
1239
        if(bsp->repr == Seq_repr_seg && bsp->seq_ext_type == 1)
 
1240
                gs.ignore[OBJ_BIOSEQ_SEG] = FALSE;
 
1241
        gs.nointervals = TRUE;
 
1242
        gs.target = slp;
 
1243
        gs.offset = SeqLocStart(slp);
 
1244
        gs.get_feats_location = TRUE;
 
1245
        GatherSeqEntry(sep, (Pointer)(&pg), prtgenefunc, &gs);
 
1246
 
 
1247
        if(pg.found == FALSE)
 
1248
                fprintf(fp, "None\n");
 
1249
        return (pg.found);
 
1250
}
 
1251