~ubuntu-branches/ubuntu/raring/ncbi-tools6/raring

« back to all changes in this revision

Viewing changes to network/medarch/client/medutil.c

  • Committer: Package Import Robot
  • Author(s): Aaron M. Ucko
  • Date: 2011-09-05 18:55:02 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: package-import@ubuntu.com-20110905185502-iuvmoe65ytljhckn
Tags: 6.1.20110713-1
* New upstream release.
* debian/*.symbols: update accordingly.
* make/makeshlb.unx: link libcn3dOGL.so against -lm for sqrt.
* doc/man/*.1: update for new release.
* debian/rules:
  - (VIB): add asnmacro, as upstream takes care to publish binaries thereof.
  - Retire obsolete multiarch-unaware checks for libpthread.
  - Fully modernize Debhelper usage; in particular, transition to overrides.
* debian/compat: advance to 9 per rules modernization.
* debian/ncbi-tools-bin.install: add asnmacro.
* make/makenet.unx: link asnmacro only against libraries it directly needs.
* doc/man/asnmacro.1: give asnmacro a man page.
* doc/man/Psequin.1: list it in SEE ALSO.
* network/id1arch/idfetch.c: revert redundant change (from #295110).
* Convert to multiarch.
  - debian/rules: Install libraries (and ncbithr.o) to multiarch directories.
  - debian/lib*.install: match multiarch library paths.
  - debian/control:
    + Build-Depends: debhelper (>= 8.1.3~), implying a recent dpkg-dev.
    + Set Multi-Arch: as appropriate across the board, and specify
      Pre-Depends: ${misc:Pre-Depends} for runtime libraries.
* debian/*.lintian-overrides: drop leading slashes for Lintian 2.5.x.
* debian/control: Standards-Version: 3.9.2 (already compliant).

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
*   
29
29
* Version Creation Date: 8/31/93
30
30
*
31
 
* $Revision: 6.24 $
 
31
* $Revision: 6.32 $
32
32
*
33
33
* File Description:  Medline Utilities for MedArch
34
34
*   Assumes user calls MedArchInit and Fini
41
41
*
42
42
* ==========================================================================
43
43
*
44
 
*
45
 
* RCS Modification History:
46
 
* $Log: medutil.c,v $
47
 
* Revision 6.24  2009/06/19 19:27:29  bazhin
48
 
* Added support for multiple consortium names.
49
 
*
50
 
* Revision 6.23  2007/12/04 23:29:22  bazhin
51
 
* MergePubIds() renamed to MergeNonPubmedPubIds(). Merging is
52
 
* limited to types DOI and OTHER only.
53
 
*
54
 
* Revision 6.22  2007/12/04 20:07:02  bazhin
55
 
* Added ability to merge input article ids with ones from med server.
56
 
*
57
 
* Revision 6.21  2005/02/15 17:45:32  bazhin
58
 
* Modified MedlineToISO() function: now in addition to Cit-art.Auth-list.ml
59
 
* slot it also looks at Cit-art.Auth-list.Author.Person-id.ml one
60
 
* to convert authors names from Medline format to Name-std (last, first,
61
 
* initials).
62
 
*
63
 
* Revision 6.20  2005/01/28 20:43:00  bazhin
64
 
* Fixed bug related to preserving input Cit-arts in cases of
65
 
* lookup without replacement.
66
 
*
67
 
* Revision 6.19  2004/11/29 17:50:06  bazhin
68
 
* Removed memory leak in FixPubEquiv() function.
69
 
*
70
 
* Revision 6.18  2004/11/12 17:35:51  bazhin
71
 
* Fixed bug related to the converting empty authors list from
72
 
* medline format to standard one.
73
 
*
74
 
* Revision 6.17  2004/11/04 17:53:17  bazhin
75
 
* Reverted FixPubEquiv modification, when not lookup for pmid was
76
 
* performed, if input Pub-equiv has a Cit-gen with authors, or title,
77
 
* or journal blocks filled in. Now it does lookup for pmid even if
78
 
* Cit-gen has them.
79
 
*
80
 
* Revision 6.16  2004/11/02 21:28:35  bazhin
81
 
* Modifications related to the new MedArch server to be installed.
82
 
* Does not use Medline ids for lookup, and does not look them up.
83
 
*
84
 
* Revision 6.15  2004/08/18 17:00:56  bazhin
85
 
* Fixed bug with medline lookup if both PubMed and Medline ids are present.
86
 
*
87
 
* Revision 6.14  2004/03/19 18:32:03  bazhin
88
 
* One more patch related to the previous one.
89
 
*
90
 
* Revision 6.13  2004/03/19 14:53:18  bazhin
91
 
* Added function PropogateInPress(), which is called from FixPubEquiv().
92
 
* It sets Imprint.prepub value to "in-press" if input Cit-art was flagged
93
 
* as "in-press", but had Medline or/and Pubmed id(s) and successful lookup
94
 
* returned Cit-art with no article references, such as volume and page
95
 
* numbers.
96
 
*
97
 
* Revision 6.12  2004/03/17 16:59:35  bazhin
98
 
* Slight modification in ten_authors() function. If the number of input
99
 
* authors greater than 10 and number of MedArch ones less or equal 11,
100
 
* or input has more than 25 and MedArch has less or equal 26, then
101
 
* it will take input set instead of MedArch one.
102
 
*
103
 
* Revision 6.11  2004/03/16 18:53:37  bazhin
104
 
* Now does not ignore in-press'ed Cit-arts for lookup.
105
 
*
106
 
* Revision 6.10  2003/10/01 13:08:33  bazhin
107
 
* Modified ten_authors() function to handle consortiums properly.
108
 
*
109
 
* Revision 6.9  2003/09/10 18:47:28  bazhin
110
 
* "print_pub()" function now is aware of consortiums.
111
 
*
112
 
* Revision 6.8  2003/03/25 19:14:59  bazhin
113
 
* Function "ten_authors()" became public (from static).
114
 
*
115
 
* Revision 6.7  2003/03/12 20:35:02  bazhin
116
 
* "ten_authors()" function now can handle consortiums.
117
 
*
118
 
* Revision 6.6  2001/03/08 12:47:44  ostell
119
 
* made FixPub work if no medline uid returned, but pmid is returned.
120
 
*
121
 
* Revision 6.5  2000/08/18 17:01:02  kans
122
 
* added FetchPubPmId, enhanced FixPubEquiv to handle records with pmid but no muid
123
 
*
124
 
* Revision 6.4  1999/11/17 18:16:15  bazhin
125
 
* If failed to get pub from MedArch server, then does not return NULL,
126
 
* but use input one.
127
 
* Also removed unused variables.
128
 
*
129
 
* Revision 6.3  1999/11/08 19:32:44  kans
130
 
* removed unnecessary for loop initialization picked up by IRIX C comnpiler
131
 
*
132
 
* Revision 6.2  1999/05/06 18:53:53  kans
133
 
* FixPubEquiv now works on PMID as well as MUID
134
 
*
135
 
* Revision 6.1  1998/09/14 20:54:51  bazhin
136
 
* Changes in "ten_authors()" : if successful medline lookup has returned
137
 
* no authors, then will use input ones.
138
 
*
139
 
* Revision 6.0  1997/08/25 18:35:48  madden
140
 
* Revision changed to 6.0
141
 
*
142
 
* Revision 5.0  1996/05/28 14:11:11  ostell
143
 
* Set to revision 5.0
144
 
*
145
 
 * Revision 4.4  1996/05/22  17:30:09  kans
146
 
 * changed name of error file, initialize muid in lookup procedure
147
 
 *
148
 
 * Revision 4.3  1996/03/12  22:21:07  tatiana
149
 
 * add bullet proof to MedlineToISO function
150
 
 *
151
 
 * Revision 4.2  1995/11/02  23:39:28  tatiana
152
 
 * do not accept Medline article with 0 authors
153
 
 *
154
 
 * Revision 4.1  1995/08/16  14:28:21  tatiana
155
 
 * modified get_std_auth to handle spaces between initials
156
 
 *
157
 
 * Revision 4.0  1995/07/26  13:55:12  ostell
158
 
 * force revision to 4.0
159
 
 *
160
 
 * Revision 1.32  1995/06/06  14:34:39  tatiana
161
 
 * bug fixed in print_pub()
162
 
 *
163
 
 * Revision 1.30  1995/05/25  22:17:14  kans
164
 
 * fixed FixPubEquiv
165
 
 *
166
 
 * Revision 1.29  1995/05/25  18:14:35  kans
167
 
 * additional long and int casts in ErrPostEx
168
 
 *
169
 
 * Revision 1.28  1995/05/24  16:13:47  tatiana
170
 
 * add in_press() to avoid lookup for in press articles
171
 
 *
172
 
 * Revision 1.24  1995/05/17  17:54:05  epstein
173
 
 * add RCS log revision history
174
 
 *
175
44
*/
176
45
 
177
46
/** for ErrPostEx() ****/
189
58
#include <medutil.h>               /* the interface */
190
59
#include <medarch.h>           /* the medarch interface */
191
60
#include <mdrcherr.h>           /* the errors interface */
 
61
#include <urlquery.h>
 
62
 
 
63
static void MUGetStringCallback (XmlObjPtr xop, XmlObjPtr parent, Int2 level, Pointer userdata)
 
64
 
 
65
{
 
66
  CharPtr PNTR  strp;
 
67
 
 
68
  if (xop == NULL || userdata == NULL) return;
 
69
  strp = (CharPtr PNTR) userdata;
 
70
 
 
71
  if (StringHasNoText (xop->contents)) return;
 
72
 
 
73
  *strp = StringSave (xop->contents);
 
74
}
 
75
 
 
76
static void MUGetStringSetCallback (XmlObjPtr xop, XmlObjPtr parent, Int2 level, Pointer userdata)
 
77
 
 
78
{
 
79
  ValNodeBlockPtr  vnbp;
 
80
 
 
81
  if (xop == NULL || userdata == NULL) return;
 
82
  vnbp = (ValNodeBlockPtr) userdata;
 
83
 
 
84
  if (StringHasNoText (xop->contents)) return;
 
85
 
 
86
  ValNodeCopyStrEx (&(vnbp->head), &(vnbp->tail), 0, xop->contents);
 
87
}
 
88
 
 
89
static Boolean MULooksLikeISSN (CharPtr str)
 
90
 
 
91
{
 
92
  Char  ch;
 
93
  Int2  i;
 
94
 
 
95
  if (StringHasNoText (str)) return FALSE;
 
96
 
 
97
  if (StringLen (str) != 9) return FALSE;
 
98
  if (str [4] != '-') return FALSE;
 
99
 
 
100
  for (i = 0; i < 9; i++) {
 
101
    ch = str [i];
 
102
    if (IS_DIGIT (ch)) continue;
 
103
    if (ch == '-' && i == 4) continue;
 
104
    if (ch == 'X' && i == 8) continue;
 
105
    return FALSE;
 
106
  }
 
107
 
 
108
  return TRUE;
 
109
}
 
110
 
 
111
static Boolean MUIsJournalIndexed (CharPtr journal)
 
112
 
 
113
{
 
114
  ValNodeBlock  blk;
 
115
  Char          ch;
 
116
  CharPtr       count = NULL;
 
117
  CharPtr       jids = NULL;
 
118
  CharPtr       ptr;
 
119
  Boolean       rsult = FALSE;
 
120
  CharPtr       status = NULL;
 
121
  CharPtr       str = FALSE;
 
122
  Char          title [512];
 
123
  XmlObjPtr     xop;
 
124
 
 
125
  if (StringHasNoText (journal)) return FALSE;
 
126
  StringNCpy_0 (title, journal, sizeof (title));
 
127
 
 
128
  ptr = title;
 
129
  ch = *ptr;
 
130
  while (ch != '\0') {
 
131
    if (ch == '(' || ch == ')') {
 
132
      *ptr = ' ';
 
133
    }
 
134
    ptr++;
 
135
    ch = *ptr;
 
136
  }
 
137
  TrimSpacesAroundString (title);
 
138
  CompressSpaces (title);
 
139
 
 
140
  if (MULooksLikeISSN (title)) {
 
141
    str = QUERY_UrlSynchronousQuery ("eutils.ncbi.nlm.nih.gov", 80,
 
142
                                     "/entrez/eutils/esearch.fcgi",
 
143
                                     "db=nlmcatalog&retmax=200&term=",
 
144
                                     title, "%5Bissn%5D", NULL);
 
145
  }
 
146
 
 
147
  if (str == NULL) {
 
148
    str = QUERY_UrlSynchronousQuery ("eutils.ncbi.nlm.nih.gov", 80,
 
149
                                     "/entrez/eutils/esearch.fcgi",
 
150
                                     "db=nlmcatalog&retmax=200&term=",
 
151
                                     title, "%5Bmulti%5D+AND+ncbijournals%5Bsb%5D", NULL);
 
152
  }
 
153
 
 
154
  if (str == NULL) return FALSE;
 
155
 
 
156
  xop = ParseXmlString (str);
 
157
  MemFree (str);
 
158
  if (xop == NULL) return FALSE;
 
159
 
 
160
  blk.head = NULL;
 
161
  blk.tail = NULL;
 
162
  VisitXmlNodes (xop, (Pointer) &blk, MUGetStringSetCallback, "Id", NULL, NULL, NULL, 0);
 
163
  VisitXmlNodes (xop, (Pointer) &count, MUGetStringCallback, "Count", "eSearchResult", NULL, NULL, 0);
 
164
 
 
165
  FreeXmlObject (xop);
 
166
 
 
167
  if (StringCmp (count, "0") == 0 || blk.head == NULL) {
 
168
    MemFree (count);
 
169
 
 
170
    str = QUERY_UrlSynchronousQuery ("eutils.ncbi.nlm.nih.gov", 80,
 
171
                                     "/entrez/eutils/esearch.fcgi",
 
172
                                     "db=nlmcatalog&retmax=200&term=",
 
173
                                     title, "%5Bmulti%5D+AND+ncbijournals%5Bsb%5D", NULL);
 
174
    if (str == NULL) return FALSE;
 
175
 
 
176
    xop = ParseXmlString (str);
 
177
    MemFree (str);
 
178
    if (xop == NULL) return FALSE;
 
179
 
 
180
    blk.head = NULL;
 
181
    blk.tail = NULL;
 
182
    VisitXmlNodes (xop, (Pointer) &blk, MUGetStringSetCallback, "Id", NULL, NULL, NULL, 0);
 
183
    VisitXmlNodes (xop, (Pointer) &count, MUGetStringCallback, "Count", "eSearchResult", NULL, NULL, 0);
 
184
 
 
185
    FreeXmlObject (xop);
 
186
  }
 
187
 
 
188
  MemFree (count);
 
189
 
 
190
  if (blk.head == NULL) return FALSE;
 
191
 
 
192
  /* if more than one candidate, bail */
 
193
 
 
194
  if (blk.head->next != NULL) {
 
195
    ValNodeFreeData (blk.head);
 
196
    return FALSE;
 
197
  }
 
198
 
 
199
  jids = ValNodeMergeStrsEx (blk.head, ",");
 
200
  ValNodeFreeData (blk.head);
 
201
 
 
202
  if (jids == NULL) return FALSE;
 
203
 
 
204
  str = QUERY_UrlSynchronousQuery ("eutils.ncbi.nlm.nih.gov", 80,
 
205
                                   "/entrez/eutils/esummary.fcgi",
 
206
                                   "db=nlmcatalog&retmax=200&version=2.0&id=",
 
207
                                   jids, NULL, NULL);
 
208
  MemFree (jids);
 
209
  if (str == NULL) return FALSE;
 
210
 
 
211
  xop = ParseXmlString (str);
 
212
  MemFree (str);
 
213
  if (xop == NULL) return FALSE;
 
214
 
 
215
  VisitXmlNodes (xop, (Pointer) &status, MUGetStringCallback, "CurrentIndexingStatus", NULL, NULL, NULL, 0);
 
216
 
 
217
  FreeXmlObject (xop);
 
218
 
 
219
  if (StringCmp (status, "Y") == 0) {
 
220
    rsult = TRUE;
 
221
  }
 
222
 
 
223
  MemFree (status);
 
224
 
 
225
  return rsult;
 
226
}
192
227
 
193
228
/**********************************************************/
194
229
void print_pub(ValNodePtr pub, Boolean found, Boolean auth, Int4 muid)
319
354
                      "%ld|%s %s|%s|(%d)|%s|%s", (long) muid, last, first,
320
355
                      s_title, (int) year, vol, page);
321
356
        }
322
 
        else if(muid == 0)
 
357
        else if (MUIsJournalIndexed (s_title))
323
358
        {
324
 
            ErrPostEx(SEV_WARNING, ERR_REFERENCE_PmidNotFound,  
325
 
                      "%s %s|%s|(%d)|%s|%s", last, first, s_title,
326
 
                      (int) year, vol, page);
 
359
            if (muid == 0) {
 
360
                ErrPostEx(SEV_WARNING, ERR_REFERENCE_PmidNotFound,  
 
361
                          "%s %s|%s|(%d)|%s|%s", last, first, s_title,
 
362
                          (int) year, vol, page);
 
363
            } else {
 
364
                ErrPostEx(SEV_WARNING, ERR_REFERENCE_PmidNotFound,  
 
365
                          ">>%ld<<|%s %s|%s|(%d)|%s|%s", (long) muid, last,
 
366
                          first, s_title, (int) year, vol, page);
 
367
            }
327
368
        }
328
369
        else
329
370
        {
330
 
            ErrPostEx(SEV_WARNING, ERR_REFERENCE_PmidNotFound,  
331
 
                      ">>%ld<<|%s %s|%s|(%d)|%s|%s", (long) muid, last,
332
 
                      first, s_title, (int) year, vol, page);
 
371
            if (muid == 0) {
 
372
                ErrPostEx(SEV_WARNING, ERR_REFERENCE_NoPmidJournalNotInPubMed,  
 
373
                          "%s %s|%s|(%d)|%s|%s", last, first, s_title,
 
374
                          (int) year, vol, page);
 
375
            } else {
 
376
                ErrPostEx(SEV_INFO, ERR_REFERENCE_NoPmidJournalNotInPubMed,  
 
377
                          ">>%ld<<|%s %s|%s|(%d)|%s|%s", (long) muid, last,
 
378
                          first, s_title, (int) year, vol, page);
 
379
            }
333
380
        }
334
381
    }
335
382
}
681
728
            continue;
682
729
        pdp = (PubdescPtr) vnp->data.ptrvalue;
683
730
        newpub = FixPubEquiv(pdp->pub, fpop);
684
 
        pdp->pub = newpub;
 
731
        if (newpub != NULL) {
 
732
          pdp->pub = newpub;
 
733
        }
685
734
    }
686
735
 
687
736
    for(; sap != NULL; sap = sap->next)
695
744
            {
696
745
                pdp = (PubdescPtr) sfp->data.value.ptrvalue;
697
746
                newpub = FixPubEquiv(pdp->pub, fpop);
698
 
                pdp->pub = newpub;
 
747
                if (newpub != NULL) {
 
748
                  pdp->pub = newpub;
 
749
                }
699
750
            }
700
751
 
701
752
            if(sfp->cit == NULL)
851
902
            break;
852
903
        case PUB_Equiv:
853
904
            tmp = FixPubEquiv((ValNodePtr) pub->data.ptrvalue, fpop);
854
 
            pub->data.ptrvalue = tmp;
855
 
            newpub = pub;
 
905
            if (tmp != NULL) {
 
906
              pub->data.ptrvalue = tmp;
 
907
              newpub = pub;
 
908
            }
856
909
            break;
857
910
        default:
858
911
            break;
1244
1297
            return(pube);
1245
1298
        }
1246
1299
 
1247
 
        print_pub(citartptr, FALSE, FALSE, oldmuid);
 
1300
        print_pub(citartptr, FALSE, FALSE, oldpmid);
1248
1301
        pube = FixPubEquivAppend(pube, tmp2, citartptr);
1249
1302
        if(muidptr != NULL)             /* ditch the mismatched muid */
1250
1303
            PubFree(muidptr);