1 static char const rcsid[] = "$Id: urkutil.c,v 6.5 2003/05/30 17:25:38 coulouri Exp $";
2
3 /*
4 * ===========================================================================
5 *
6 * PUBLIC DOMAIN NOTICE
7 * National Center for Biotechnology Information
8 *
9 * This software/database is a "United States Government Work" under the
10 * terms of the United States Copyright Act. It was written as part of
11 * the author's official duties as a United States Government employee and
12 * thus cannot be copyrighted. This software/database is freely available
13 * to the public for use. The National Library of Medicine and the U.S.
14 * Government have not placed any restriction on its use or reproduction.
15 *
16 * Although all reasonable efforts have been taken to ensure the accuracy
17 * and reliability of the software and data, the NLM and the U.S.
18 * Government do not and cannot warrant the performance or results that
19 * may be obtained by using this software or data. The NLM and the U.S.
20 * Government disclaim all warranties, express or implied, including
21 * warranties of performance, merchantability or fitness for any particular
22 * purpose.
23 *
24 * Please cite the author in any work or product based on this material.
25 *
26 * ===========================================================================
27 *
28 * File Name: urkutil.c
29 *
30 * Author(s): John Kuzio
31 *
32 * Version Creation Date: 98-01-01
33 *
34 * $Revision: 6.5 $
35 *
36 * File Description: urk utilities
37 *
38 * Modifications:
39 * --------------------------------------------------------------------------
40 * Date Name Description of modification
41 * --------------------------------------------------------------------------
42 * $Log: urkutil.c,v $
43 * Revision 6.5 2003/05/30 17:25:38 coulouri
44 * add rcsid
45 *
46 * Revision 6.4 1999/10/18 18:03:40 madden
47 * Remove Entrez calls from tools lib function
48 *
49 * Revision 6.3 1999/01/27 15:08:42 kuzio
50 * ErrorDescString
51 *
52 * Revision 6.2 1998/09/16 14:20:10 kuzio
53 * testing cvs logging on boilerplate (?)
54 *
55 *
56 * ==========================================================================
57 */
58
59 #include <accentr.h>
60 #include <tofasta.h>
61 #include <urkutil.h>
62
FastaTitle(BioseqPtr bsp,CharPtr pretext,CharPtr posttext)63 extern CharPtr FastaTitle (BioseqPtr bsp, CharPtr pretext, CharPtr posttext)
64 {
65 CharPtr title = NULL;
66 CharPtr prep, postp, predum = "", postdum = "";
67 Char idbuf[L_ID], defbuf[L_DEF];
68 Int4 prelen = 0, postlen = 0;
69 SeqIdPtr sip;
70
71 if (bsp != NULL)
72 {
73 if ((sip = bsp->id) != NULL)
74 {
75 if (pretext != NULL)
76 {
77 prelen = StrLen (pretext);
78 prep = pretext;
79 }
80 else
81 {
82 prep = predum;
83 }
84 if (posttext != NULL)
85 {
86 postlen = StrLen (posttext);
87 postp = posttext;
88 }
89 else
90 {
91 postp = postdum;
92 }
93 if ((title = (CharPtr) MemNew (sizeof (Char) * (L_T+prelen+postlen)))
94 != NULL)
95 {
96 switch (sip->choice)
97 {
98 case SEQID_LOCAL:
99 idbuf[0] = '\0';
100 if (sip->data.ptrvalue != NULL)
101 StrNCpy (idbuf, ((ObjectIdPtr) sip->data.ptrvalue)->str, L_ID-1);
102 idbuf[L_ID-1] = '\0';
103 break;
104 default:
105 FastaId (bsp, idbuf, L_ID);
106 break;
107 }
108 FastaDefLine (bsp, defbuf, L_DEF, NULL, NULL, 0);
109 sprintf (title, "%s%s %s%s", prep, idbuf, defbuf, postp);
110 }
111 }
112 }
113 return title;
114 }
115
ErrorDescString(SeqIdPtr sip)116 extern CharPtr ErrorDescString (SeqIdPtr sip)
117 {
118 SeqIdPtr bestid;
119 CharPtr errbuf;
120
121 bestid = SeqIdFindBest(sip, SEQID_GI);
122
123 errbuf = (CharPtr) MemNew ((size_t) (sizeof (Char) * 32));
124 SeqIdWrite (bestid, errbuf, PRINTID_FASTA_LONG, 32-1);
125
126 return errbuf;
127 }
128