|
NCBI Home IEB Home C Toolkit docs C++ Toolkit source browser C Toolkit source browser (2) |
NCBI C Toolkit Cross ReferenceC/api/codon.c |
source navigation diff markup identifier search freetext search file search |
1
2 #include <codon.h>
3
4
5 /******************************************************************
6 *
7 * aa_to_codon(sfp, aa_start, aa_stop)
8 * generate a list of CodonVecotr to show the codons of an
9 * amino acid sequence
10 * sfp: the Seq-feat for cds
11 * aa_start: the start position of protein sequence
12 * aa_stop the stop position of protein sequence
13 *
14 ******************************************************************/
15 NLM_EXTERN ValNodePtr aa_to_codon(SeqFeatPtr sfp, Int4 aa_start, Int4 aa_stop)
16 {
17 BioseqPtr bsp;
18
19 Int4 frame_offset, start_offset;
20 SeqLocPtr slp = NULL;
21 SeqLocPtr cdloc;
22 CdRegionPtr crp;
23 Uint1 frame;
24
25 Boolean is_end; /**is the end for process reached?**/
26 Int4 p_start=0, p_stop=0; /**protein start & stop in defined
27 corresponding CdRegion Seq-loc**/
28
29 Int4 line_len;
30 Int4 cur_pos; /**current protein position in process**/
31 Int4 cd_len; /**length of the cDNA for the coding region**/
32
33 Int2 i, j;
34 Int2 k, n;
35 CharPtr PNTR buf;
36
37 Boolean is_new; /**Is cur_pos at the begin of new Seq-loc?**/
38 CharPtr temp;
39
40 SeqPortPtr spp;
41 Uint1 residue;
42
43 Boolean end_partial;
44 Int4 d_start, seq_pos;
45 Int2 pos;
46
47 ValNodePtr head= NULL;
48 CodonVectorPtr cvp;
49 Boolean prt_stop_codon;
50 Uint2 exon;
51
52
53
54
55 if(sfp->data.choice !=3)
56 return NULL;
57
58 crp = sfp->data.value.ptrvalue;
59 if(!crp)
60 return NULL;
61 frame = crp->frame;
62 cdloc = sfp->location;
63 if(cdloc == NULL )
64 return NULL;
65
66 if(frame>0)
67 frame_offset = frame-1;
68 else
69 frame_offset = 0;
70 start_offset = frame_offset;
71
72 prt_stop_codon = (aa_stop == SeqLocStop(sfp->product));
73 line_len = (aa_stop - aa_start + 1) + 1;
74 /* +1 for the possible partial start codon*/
75 if(prt_stop_codon)/*can be either as a stop codon or partial stop*/
76 ++line_len;
77 buf = MemNew((size_t)3 * sizeof(CharPtr));
78 for(i =0; i<3; ++i)
79 buf[i] = MemNew((size_t)(line_len + 1) * sizeof (Char));
80
81
82 cur_pos= aa_start;
83 cd_len = 0;
84 is_end = FALSE;
85 p_start = 0;
86 slp = NULL;
87 exon = 0;
88 while(!is_end && ((slp = SeqLocFindNext(cdloc, slp))!=NULL))
89 {
90 ++exon;
91 cd_len += SeqLocLen(slp);
92 end_partial = ((cd_len - start_offset)%3 != 0);
93 p_stop = (cd_len - start_offset)/3 -1;
94 if(end_partial)
95 ++p_stop;
96 if(p_stop > aa_stop || (p_stop == aa_stop && !end_partial))
97 {
98 p_stop = aa_stop; /**check if the end is reached**/
99 is_end = TRUE;
100 }
101
102 if(p_stop >= cur_pos) /*get the exon*/
103 {
104 bsp = BioseqLockById(SeqLocId(slp));
105 if(bsp)
106 {
107 is_new = (p_start == cur_pos); /*start a new exon?*/
108 cvp = MemNew(sizeof(CodonVector));
109 cvp->sip = SeqIdDup(find_sip(bsp->id));
110 cvp->strand = SeqLocStrand(slp);
111 cvp->exonCount = exon;
112 if(is_new)
113 {
114 if(frame_offset == 0)
115 cvp->frame = 0;
116 else
117 cvp->frame = 3- (Uint1)frame_offset;
118 }
119 else
120 cvp->frame = 0;
121 if(cur_pos==0 && frame_offset > 0) /*partial start codon*/
122 cvp->aa_index = 0;
123 else
124 cvp->aa_index = 1;
125 if(is_new) /**special case of the first partial**/
126 d_start = SeqLocStart(slp);
127 else
128 {
129 if(frame_offset && p_start >0)
130 ++p_start;
131 d_start = SeqLocStart(slp) + 3*(cur_pos - p_start) + frame_offset;
132 }
133 /**p_start is the start position of aa in the current Seq-loc
134 cur_pos is the current aa that is in process. The offset will
135 help to located the position on the DNA Seq-loc for translation
136 d_start is the position of the starting DNA in the coordinates
137 of DNA segment, used for mark the sequence
138 **/
139
140 seq_pos = d_start - SeqLocStart(slp); /**the pos in spp**/
141 if(SeqLocStrand(slp)== Seq_strand_minus)
142 d_start = SeqLocStop(slp) - seq_pos;
143 cvp->dna_pos = d_start;
144
145 n = (Int2)cur_pos - (Int2)aa_start + cvp->aa_index; /*position in buffer*/
146 for(i =0; i<3; ++i)
147 make_empty(buf[i], (Int2)line_len);
148 spp = SeqPortNewByLoc(slp, Seq_code_iupacna);
149 SeqPortSeek(spp, seq_pos, SEEK_SET);
150 /**store the partial codons**/
151 if(is_new && frame_offset > 0)
152 {
153 k = (Int2)frame_offset;
154 while(k > 0)
155 {
156 residue = SeqPortGetResidue(spp);
157 temp = buf[3-k]; /**the position**/
158 pos = n;
159 temp[pos] = TO_LOWER(residue);
160 --k;
161 }
162 ++n;
163 if(cur_pos!=0)
164 ++cur_pos;
165 }
166
167
168 /**load the codons**/
169 k =0;
170 while((residue = SeqPortGetResidue(spp)) != SEQPORT_EOF && cur_pos <= p_stop)
171 {
172 j= (Uint1)k%3;
173 temp = buf[j];
174 temp[n] = TO_LOWER(residue);
175 if(j ==2)
176 { /**the last base**/
177 ++n;
178 if(!prt_stop_codon|| !is_end) /*for the last codon*/
179 /**prt_end controls to print the whole loc**/
180 ++cur_pos;
181 }
182 ++k;
183 } /**end of while**/
184
185 SeqPortFree(spp);
186
187 for(i =0; i<3; ++i)
188 cvp->buf[i] = StringSave(buf[i]);
189 ValNodeAddPointer(&head, 0, (Pointer)cvp);
190
191 BioseqUnlock(bsp);
192 }/*end of if(bsp)*/
193 }/**end of if for matched intervals**/
194
195 if(end_partial)
196 p_start = p_stop;
197 else
198 p_start = p_stop +1;
199
200 frame_offset = (cd_len - start_offset)%3;
201 if(frame_offset >0)
202 frame_offset = 3-frame_offset;
203
204 }/**end of while(slp && !is_end) **/
205
206 for(i=0; i<3; ++i)
207 MemFree(buf[i]);
208 MemFree(buf);
209
210 return head;
211 }
212
213
214 /******************************************************************
215 *
216 * free_cvp_list(cvp_list)
217 * free a list of CodonVectorPtr
218 *
219 ******************************************************************/
220 NLM_EXTERN ValNodePtr free_cvp_list(ValNodePtr cvp_list)
221 {
222 ValNodePtr next;
223 CodonVectorPtr cvp;
224 Int2 i;
225
226 while(cvp_list)
227 {
228 next = cvp_list->next;
229 cvp_list->next = NULL;
230 cvp = cvp_list->data.ptrvalue;
231 for(i=0; i<3; ++i)
232 MemFree(cvp->buf[i]);
233 SeqIdFree(cvp->sip);
234 ValNodeFreeData(cvp_list);
235 cvp_list = next;
236 }
237
238 return NULL;
239 }
240
241
242 /*********************************************************************
243 *
244 * make_cds_paragraph(sfp, aa_start, aa_stop)
245 * return a buffer for the display of 3-codon under one amino
246 * acid format. It also includes the new line characters
247 * This is what Jonathan K. desires to have for the sequin
248 * doc object
249 * aa_start, aa_stop: start and stop in the amino acid sequence
250 *
251 *********************************************************************/
252 NLM_EXTERN CharPtr make_cds_paragraph(SeqFeatPtr sfp, Int4 aa_start, Int4 aa_stop)
253 {
254 BioseqPtr pbsp;
255 SeqPortPtr spp;
256 ValNodePtr cvp_node, curr;
257 CodonVectorPtr cvp;
258 CharPtr docbuf = NULL;
259 Int4 num, buf_size;
260 Uint1 residue;
261 Char p_name[30];
262 Int4 space_len, i;
263 CharPtr buf;
264 Int4 pos;
265 Int4 max_len = 150;
266 Boolean extra_space;
267
268 if(sfp == NULL || sfp->data.choice !=3)
269 return NULL;
270 if(sfp->product == NULL)
271 return NULL;
272 pbsp = BioseqLockById(SeqLocId(sfp->product));
273 if(pbsp == NULL)
274 return NULL;
275
276 cvp_node = aa_to_codon(sfp, aa_start, aa_stop);
277 num = 1;
278 for(curr = cvp_node; curr !=NULL; curr = curr->next)
279 num +=3;
280 buf_size = num * max_len;
281 /* #ifdef WIN_16
282 if(buf_size > 10000)
283 {
284 Message(MSG_ERROR, "Can not allocate enough space ");
285 return NULL;
286 }
287 #endif
288 */
289
290 docbuf = MemNew((size_t)(buf_size) * sizeof(Char));
291
292 MuskSeqIdWrite(pbsp->id, p_name, B_SPACE, PRINTID_TEXTID_ACCESSION, TRUE, FALSE);
293 /*SeqIdWrite (pbsp->id, p_name, PRINTID_FASTA_SHORT, 10);*/
294 pos = 0;
295 pos+= print_label_to_buffer(docbuf+pos, p_name, (aa_start+1), 0, FALSE,
296 FALSE, B_SPACE, POS_SPACE);
297
298 /*print the amino acid sequence into buffer*/
299 spp = SeqPortNew(pbsp, aa_start, aa_stop, Seq_strand_plus, Seq_code_ncbieaa);
300 while((residue = SeqPortGetResidue(spp)) != SEQPORT_EOF )
301 docbuf[pos++] = residue;
302 docbuf[pos++] = '\n';
303 SeqPortFree(spp);
304
305 for(curr = cvp_node; curr !=NULL; curr = curr->next)
306 {
307 cvp = curr->data.ptrvalue;
308 SeqIdWrite (cvp->sip, p_name, PRINTID_FASTA_SHORT, 10);
309 extra_space = (cvp->aa_index == 0);
310 for(i=0; i<3; ++i)
311 {
312 space_len = cvp->aa_index;
313 buf = cvp->buf[i] + cvp->aa_index;
314 if(i == cvp->frame)
315 {
316 pos+= print_label_to_buffer(docbuf+pos, p_name,
317 cvp->dna_pos, cvp->strand, extra_space, FALSE, B_SPACE, POS_SPACE);
318 }
319 else
320 pos+= print_label_to_buffer(docbuf+pos, NULL, -1,
321 0, extra_space, FALSE, B_SPACE, POS_SPACE);
322 sprintf(docbuf+pos, "%s\n", buf);
323 pos += (StringLen(buf) +1);
324
325 }
326 }
327
328 docbuf[pos++] = '\n';
329 docbuf[pos] = '\0';
330
331 free_cvp_list(cvp_node);
332 BioseqUnlock(pbsp);
333
334 return docbuf;
335 }
336
337
338
339 /******************************************************************
340 *
341 * aa_to_dnaloc(sfp, aa_start, aa_stop)
342 * map the amino acid sequence to a list of Seq-locs in the
343 * DNA sequence
344 *
345 ******************************************************************/
346 NLM_EXTERN SeqLocPtr aa_to_dnaloc(SeqFeatPtr sfp, Int4 aa_start, Int4 aa_stop)
347 {
348 Int4 frame_offset, start_offset; /*for determine the reading frame*/
349 SeqLocPtr slp = NULL;
350 CdRegionPtr crp;
351 SeqLocPtr dna_loc, loc; /*for the dna location*/
352
353 Boolean is_end; /**is the end for process reached?**/
354 Int4 p_start=0, p_stop=0; /**protein start & stop in defined
355 corresponding CdRegion Seq-loc**/
356 Int4 cur_pos; /**current protein position in process**/
357 Int4 cd_len; /**length of the cDNA for the coding region**/
358
359 Boolean is_new; /**Is cur_pos at the begin of new exon?**/
360 Boolean end_partial; /*the end of aa is a partial codon*/
361 Int4 d_start, d_stop; /*the start and the stop of the DNA sequence*/
362 Int4 offset; /*offset from the start of the current exon*/
363 Int4 aa_len;
364 Uint1 strand;
365
366
367
368
369 if(sfp->data.choice !=3)
370 return NULL;
371
372
373 crp = sfp->data.value.ptrvalue;
374 if(!crp)
375 return NULL;
376 if(crp->frame>0)
377 frame_offset = crp->frame-1;
378 else
379 frame_offset = 0;
380 start_offset = frame_offset;
381
382
383 cur_pos= aa_start;
384 cd_len = 0;
385 is_end = FALSE;
386 p_start = 0;
387 slp = NULL;
388 dna_loc= NULL;
389 while(!is_end && ((slp = SeqLocFindNext(sfp->location, slp))!=NULL))
390 {
391 cd_len += SeqLocLen(slp);
392 end_partial = ((cd_len - start_offset)%3 != 0);
393 p_stop = (cd_len - start_offset)/3 -1;
394 if(end_partial)
395 ++p_stop;
396 if(p_stop > aa_stop || (p_stop == aa_stop && !end_partial))
397 {
398 p_stop = aa_stop; /**check if the end is reached**/
399 is_end = TRUE;
400 }
401
402 if(p_stop >= cur_pos) /*get the exon*/
403 {
404 is_new = (p_start == cur_pos); /*start a new exon?*/
405 if(is_new) /**special case of the first partial**/
406 offset = 0;
407 else
408 {
409 if(frame_offset && p_start >0)
410 ++p_start;
411 offset = 3*(cur_pos - p_start) + frame_offset;
412 }
413 strand = SeqLocStrand(slp);
414 if(strand == Seq_strand_minus)
415 d_start = SeqLocStop(slp) - offset;
416 else
417 d_start = SeqLocStart(slp) + offset;
418
419 d_stop = d_start;
420 aa_len = MIN(p_stop, aa_stop) - cur_pos +1;
421 if(strand == Seq_strand_minus)
422 {
423 d_stop -= 3*aa_len;
424 d_stop = MAX(d_stop, SeqLocStart(slp));
425 loc = SeqLocIntNew(d_stop, d_start, strand, SeqLocId(slp));
426 }
427 else
428 {
429 d_stop += 3*aa_len;
430 d_stop = MIN(d_stop, SeqLocStop(slp));
431 loc = SeqLocIntNew(d_start, d_stop, strand, SeqLocId(slp));
432 }
433 ValNodeLink(&dna_loc, loc);
434
435 if(end_partial)
436 cur_pos = p_stop;
437 else
438 cur_pos = p_stop+1;
439 }
440
441
442
443 if(end_partial)
444 p_start = p_stop;
445 else
446 p_start = p_stop +1;
447
448 frame_offset = (cd_len - start_offset)%3;
449 if(frame_offset >0)
450 frame_offset = 3-frame_offset;
451
452 }/**end of while(slp && !is_end) **/
453 return dna_loc;
454
455 }
456
457 static Boolean ck_reverse(Uint1 strand_1, Uint1 strand_2)
458 {
459 if(strand_1 == strand_2)
460 return FALSE;
461
462 /* if(strand_1 == 0 || strand_2 == 0)
463 {
464 if(strand_1 == Seq_strand_plus)
465 return FALSE;
466 if(strand_2 == Seq_strand_plus)
467 return FALSE;
468 } */
469 return (strand_1 == Seq_strand_minus || strand_2 == Seq_strand_minus);
470
471 }
472
473
474 NLM_EXTERN Int4 print_protein_for_cds(SeqFeatPtr sfp, CharPtr buf, SeqLocPtr loc, Boolean reverse_minus)
475 {
476 CdRegionPtr crp;
477 Int4 frame_offset, start_offset;
478 Uint1 f_strand;
479 Boolean reverse;
480 Int4 cd_len;
481 GatherRange gr;
482 Int2 p_pos, buf_len;
483 Int4 a_left, a_right;
484 Int4 aa, val;
485 SeqLocPtr slp;
486 SeqPortPtr spp;
487 ByteStorePtr p_data;
488 Int4 end_pos, start_pos = -1;
489 Uint1 residue;
490 Boolean seal_ends = FALSE;
491 Boolean reverse_order;
492
493 if(sfp == NULL || sfp->data.choice != 3)
494 return -1;
495 if(buf == NULL || loc == NULL)
496 return -1;
497 crp = sfp->data.value.ptrvalue;
498 if(crp == NULL)
499 return -1;
500
501 if(buf[0] == '\0')
502 seal_ends = TRUE;
503 spp = NULL;
504 p_data = NULL;
505 if(sfp->product !=NULL && !IS_BOGO_Product(sfp->ext))
506 {
507 spp = SeqPortNewByLoc(sfp->product, Seq_code_ncbieaa);
508 if(spp !=NULL)
509 {
510 SeqPortSeek(spp, 0, SEEK_SET);
511 end_pos = spp->totlen-1;
512 }
513 }
514 if(spp == NULL)
515 {
516 p_data = ProteinFromCdRegion(sfp, TRUE);
517 /* p_data = ProteinFromCdRegion(sfp, FALSE); */
518 if(p_data !=NULL)
519 {
520 BSSeek(p_data, 0, SEEK_SET);
521 end_pos = BSLen(p_data)-1;
522 }
523 }
524
525 if(spp == NULL && p_data == NULL)
526 return -1;
527
528 if(crp->frame == 0)
529 frame_offset = 0;
530 else
531 frame_offset = (Int4)crp->frame-1;
532 start_offset = frame_offset;
533
534 f_strand = SeqLocStrand(sfp->location);
535 reverse = ck_reverse(f_strand, SeqLocStrand(loc));
536 /*if reverse == TRUE, the translated protein is written backwards*/
537 if(reverse && reverse_minus)
538 reverse_order = TRUE;
539 else
540 reverse_order = FALSE;
541
542 slp = NULL;
543 cd_len = 0;
544 aa = 0;
545
546 buf_len = SeqLocLen(loc);
547
548 if(reverse_order)
549 {
550 p_pos = buf_len -1;
551 if(seal_ends)
552 {
553 buf[p_pos+1] = '\0';
554 seal_ends = FALSE;
555 }
556 }
557 else
558 p_pos = 0;
559
560 while((slp = SeqLocFindNext(sfp->location, slp))!=NULL)
561 {
562 if(SeqLocOffset(loc, slp, &gr, 0))
563 {
564 if(reverse_order)
565 {
566 if(gr.right < p_pos)
567 p_pos = (Int2)(gr.right);
568 }
569 else
570 {
571 if(p_pos < gr.left)
572 p_pos = (Int2)(gr.left);
573 }
574 SeqLocOffset(slp, loc, &gr, 0);
575
576 a_left = gr.left + cd_len;
577 a_right = gr.right + cd_len;
578 /* if(reverse_order)
579 {
580 temp = a_right;
581 a_right = -a_left;
582 a_left = -temp;
583 } */
584 for(; a_left<=a_right; ++a_left)
585 {
586 val = ABS(a_left) - start_offset;
587 aa = val/3;
588 if(aa < 0 || aa > end_pos)/*stop & partial codon*/
589 {
590 buf[p_pos] = '^';
591 }
592 else
593 {
594 if(val%3==1)/*label aa in the middle of 3-bp codon*/
595 {
596 if(start_pos == -1)
597 start_pos = aa;
598 if(spp !=NULL)
599 {
600 SeqPortSeek(spp, aa, SEEK_SET);
601 residue = SeqPortGetResidue(spp);
602 }
603 else
604 {
605 BSSeek(p_data, aa, SEEK_SET);
606 residue = (Uint1)BSGetByte(p_data);
607 }
608 if(IS_ALPHA(residue) || residue == '*' || residue == '-')
609
610 buf[p_pos] = residue;
611 else
612 buf[p_pos] = '?';
613 }
614 else
615 buf[p_pos] = ' ';
616 }
617 if(reverse_order)
618 -- p_pos;
619 else {
620 ++p_pos;
621 if (p_pos > buf_len)
622 break;
623 }
624 }
625 }
626 cd_len += SeqLocLen(slp);
627 /*frame_offset = (cd_len - start_offset)%3;
628 if(frame_offset > 0)
629 --frame_offset;*/
630
631 }
632
633 if(spp != NULL)
634 SeqPortFree(spp);
635 if(p_data != NULL)
636 BSFree(p_data);
637
638 if(p_pos == 0) /*all the residues are introns*/
639 {
640 if(seal_ends)
641 {
642 end_pos = buf_len;
643 MemSet((Pointer)buf, '~', (size_t)(end_pos) * sizeof(Char));
644 buf[end_pos] = '\0';
645 }
646 }
647 else
648 {
649 if(seal_ends)
650 {
651 buf[p_pos] = '\0';
652 }
653 if(start_pos == -1)
654 start_pos = aa;
655 }
656
657 return start_pos;
658 }
659
660
661 /********************************************************************
662 *
663 * print_label_to_buffer(buf, label, pos, strand, extra_space)
664 *
665 * print a label (with label_name=label, position=pos,
666 * orientation = strand, extra_space = extra_space for partial start)
667 * into the current buffer
668 * return the offset of the buffer pointer to the current buffer
669 *
670 *********************************************************************/
671 NLM_EXTERN Int4 print_label_to_buffer_all(CharPtr buf, CharPtr label,
672 Int4 pos, Uint1 strand, Boolean extra_space, Boolean is_html,
673 Int4 label_space, Int4 num_space, Boolean show_strand)
674 {
675
676 return print_label_to_buffer_all_ex(buf, label, pos, strand,
677 extra_space, is_html, label_space, num_space, show_strand,
678 TRUE);
679 }
680
681 /********************************************************************
682 *
683 * print_label_to_buffer_all_ex(buf, label, pos, strand, extra_space)
684 *
685 * print a label (with label_name=label, position=pos,
686 * orientation = strand, extra_space = extra_space for partial start)
687 * into the current buffer
688 * return the offset of the buffer pointer to the current buffer
689 * Has an option to strip/not-strip semicolons for hardline old blast
690 * users.
691 *
692 *********************************************************************/
693 NLM_EXTERN Int4 print_label_to_buffer_all_ex(CharPtr buf, CharPtr label,
694 Int4 pos, Uint1 strand, Boolean extra_space, Boolean is_html,
695 Int4 label_space, Int4 num_space, Boolean show_strand,
696 Boolean strip_semicolon)
697 {
698 Int4 len;
699 Char symbol;
700 Char temp[100];
701 Int4 i = 0;
702 CharPtr str;
703 Int4 max_b_space;
704
705 /*
706 * print the label to the buffer
707 */
708 max_b_space = label_space + 1;
709 len = 0;
710 if(label)
711 {
712 if (strip_semicolon)
713 {
714 str= StrTok(label, ":");
715 if(str == NULL)
716 str = label;
717 else
718 {
719 str = StrTok(NULL, ":");
720 if(str == NULL)
721 str = label;
722 }
723 }
724 else
725 {
726 str = label;
727 }
728 len = MIN(max_b_space-1, (Int4)StringLen(str));
729 StringNCpy(buf, str, len);
730 i = len;
731 if(is_html)
732 {
733 sprintf(buf+i, "</a>");
734 i += 4;
735 }
736 buf[i++] = ' ';
737 ++len;
738 }
739
740 /*add the leftover empty space */
741 for(; len<max_b_space; ++len)
742 buf[i++] = ' ';
743
744 if(show_strand)
745 {
746 symbol = ' ';
747 if(strand == Seq_strand_plus)
748 symbol = '>';
749 if(strand == Seq_strand_minus)
750 symbol = '<';
751 buf[i++] = ' ';
752 buf[i++] = symbol;
753 buf[i++] = ' ';
754 }
755
756 len = 0;
757 if(pos != -1)
758 {
759 sprintf(buf+i, "%ld", (long) pos);
760 sprintf(temp, "%ld", (long) pos);
761 len = StringLen(temp);
762 i += len;
763 }
764
765 if(extra_space) /*for partial codon*/
766 ++len;
767 max_b_space = num_space + 1;
768 for(; len <max_b_space; ++len)
769 buf[i++] = ' ';
770 return i;
771 }
772
773 NLM_EXTERN Int4 print_label_to_buffer(CharPtr buf, CharPtr label, Int4 pos, Uint1 strand,
774 Boolean extra_space, Boolean is_html, Int4 label_space, Int4 num_space)
775 {
776 return print_label_to_buffer_all(buf, label, pos, strand,
777 extra_space, is_html, label_space, num_space, TRUE);
778 }
779
780
781 NLM_EXTERN void print_label(FILE *fp, CharPtr label, Int4 pos, Uint1 strand, Boolean extra_space)
782 {
783 Int4 len;
784 Char symbol;
785 Char temp[100];
786
787 len = 0;
788 if(label)
789 {
790 len = StringLen(label);
791 fprintf(fp, "%s", label);
792 }
793 for(; len<B_SPACE; ++len)
794 fprintf(fp, " ");
795
796 symbol = ' ';
797 if(strand == Seq_strand_plus)
798 symbol = '>';
799 if(strand == Seq_strand_minus)
800 symbol = '<';
801 fprintf(fp, " %c ", symbol);
802
803 len = 0;
804 if(pos != -1)
805 {
806 sprintf(temp, "%ld", (long) pos);
807 len = StringLen(temp);
808 fprintf(fp, "%s", temp);
809 }
810
811 if(extra_space) /*for partial codon*/
812 ++len;
813 for(; len <POS_SPACE; ++len)
814 fprintf(fp, " ");
815 }
816 |
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more information. |