/
README.html
819 lines (735 loc) · 31.4 KB
/
README.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.12: http://docutils.sourceforge.net/" />
<title>medic</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7614 2013-02-21 15:55:51Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="medic">
<h1 class="title">medic</h1>
<h2 class="subtitle" id="a-command-line-tool-to-manage-a-mirror-of-medline">a command-line tool to manage a mirror of MEDLINE</h2>
<p>The Swiss Army knife to parse <a class="reference external" href="http://www.nlm.nih.gov/bsd/mms/medlineelements.html">MEDLINE</a> XML files or
download eUtils' <a class="reference external" href="http://www.ncbi.nlm.nih.gov/pubmed">PubMed</a> XML records,
bootstrapping a local MEDLINE/PubMed database,
updating and/or deleting the records, and
writing the contents of selected PMIDs into flat-files.
A more in-depth tutorial for this tool is part of my <a class="reference external" href="http://fnl.es/medline-kung-fu.html">blog</a>.</p>
<a class="reference external image-reference" href="https://zenodo.org/record/9968"><img alt="DOI:10.5281/zendo.9968" src="https://zenodo.org/badge/4016/fnl/medic.png" /></a>
<p>DOI:10.5281/zendo.9968</p>
<div class="section" id="synopsis">
<h1>Synopsis</h1>
<pre class="literal-block">
medic [options] CMD FILE|PMID...
man medic
medic --help
medic --output /tmp parse baseline/medline*.xml.gz
medic --update parse update/medline*.xml.gz
medic --info delete delete.txt
medic --url sqlite:///tmp.db insert pubmed.xml
medic --pmid-lists update pmids_to_fetch_online.txt
medic --all update medline13n1000.xml
medic --format html write 1028734 1298474 > out.html
medic --logfile log.txt write pmid_list.txt
</pre>
</div>
<div class="section" id="setup">
<h1>Setup</h1>
<p>If you are <strong>not</strong> using <tt class="docutils literal">pip install medic</tt>, install all
dependencies/requirements:</p>
<pre class="literal-block">
pip install sqlalchemy
# only if using python3 < 3.2:
pip install argparse
</pre>
<p>Install the <strong>DB driver</strong> you prefer to use (supported are PostgreSQL
and SQLite, with the latter part of the Python StdLib):</p>
<pre class="literal-block">
pip install psycopg2
</pre>
<p>Create the PostgreSQL database:</p>
<pre class="literal-block">
createdb medline
</pre>
<p>If you are fine working with SQLite, you only need to use the path to the
SQLite DB file in the URL option (that will implicitly "create" the DB):</p>
<pre class="literal-block">
medic insert --url sqlite:///tmp.db 123456
</pre>
<p>To <em>create the tables in an empty DB</em>, you can just "try" to fetch a record:
As the DB is empty, this will not write anything, but SQL Alchemy will create
the tables for you in the DB:</p>
<pre class="literal-block">
medic write 123 # for PostgreSQL
medic --url sqlite:///tmp.db write 123 # for SQLite
</pre>
</div>
<div class="section" id="description">
<h1>Description</h1>
<p><tt class="docutils literal">medic [options] COMMAND <span class="pre">PMID|FILE...</span></tt></p>
<p>The <tt class="docutils literal"><span class="pre">--url</span> URL</tt> option represents the DSN of the database and might
be needed (default: <tt class="docutils literal"><span class="pre">postgresql://localhost/medline</span></tt>); For example:</p>
<dl class="docutils">
<dt>PostgreSQL</dt>
<dd><tt class="docutils literal"><span class="pre">postgresql://host//dbname</span></tt></dd>
<dt>SQLite DB</dt>
<dd><tt class="docutils literal"><span class="pre">sqlite:////absolute/path/to/foo.db</span></tt> or
<tt class="docutils literal"><span class="pre">sqlite:///relative/path/to/foo.db</span></tt></dd>
</dl>
<p>The five <strong>COMMAND</strong> arguments:</p>
<dl class="docutils">
<dt><tt class="docutils literal">insert</tt></dt>
<dd>Create records in the DB by parsing MEDLINE XML files or
by downloading PubMed XML from NCBI eUtils for a list of PMIDs.
The insert fails if the record already exists in the DB.</dd>
<dt><tt class="docutils literal">write</tt> *</dt>
<dd>Write records as <a class="reference external" href="http://www.nlm.nih.gov/bsd/mms/medlineelements.html">MEDLINE</a> files to a directory, each file named as
"<pmid>.txt". Alternatively, just the TIAB (title and abstract) plain-text
can be output, and finally, a single file in TSV or HTML format can be
generated (see option <tt class="docutils literal"><span class="pre">--format</span></tt>).
If the requested PMID does not exist in the DB, the command does not fail,
but the relevant file, row, or element will not have been written.</dd>
<dt><tt class="docutils literal">update</tt></dt>
<dd>Insert or update records in the DB (instead of creating them); note that
if a record exists, but is added with <tt class="docutils literal">create</tt>, this would throw an
<cite>IntegrityError</cite>. If you are not sure if the records are in the DB or
not, use <tt class="docutils literal">update</tt> (N.B. that <tt class="docutils literal">update</tt> is slower).</dd>
<dt><tt class="docutils literal">delete</tt> *</dt>
<dd>Delete records from the DB for a list of PMIDs (using <tt class="docutils literal"><span class="pre">--pmid-lists</span></tt>)</dd>
<dt><tt class="docutils literal">parse</tt></dt>
<dd>Does not interact with the DB, but rather creates ".tab" files for each
table that later can be used to load a database, particularly useful when
bootstrapping a large collection.</dd>
</dl>
<p>* Note that <tt class="docutils literal">write</tt> and <tt class="docutils literal">delete</tt> can only use PMID lists (option
<tt class="docutils literal"><span class="pre">--pmid-lists</span></tt>), so for these two commands, that option is always active
(implicitly).</p>
<p>For example, to download two PubMed records by PMID and update them in
the DB:</p>
<pre class="literal-block">
medic update 100000 123456
</pre>
<p>Add a single MEDLINE or PubMed XML file to the database:</p>
<pre class="literal-block">
medic insert pudmed.xml
</pre>
<p>Note that if the suffix ".gz" is present, the parser automatically
decompresses the XML file(s) first. This feature <em>only</em> works with
GNU-zipped files and the ".gz" suffix must be present.</p>
<p>Export a few records from the database as HTML (to "articles.html"):</p>
<pre class="literal-block">
medic write --format html --output articles.html 292837491 128374 213487
</pre>
<p>Write the content of the entire database (in MEDLINE format, to STDOUT):</p>
<pre class="literal-block">
medic write ALL
</pre>
<p>Therefore, command line arguments are treated as follows:</p>
<dl class="docutils">
<dt>integer values</dt>
<dd>are always treated as PMIDs to download PubMed XML data</dd>
<dt>all other values</dt>
<dd>are always treated as MEDLINE XML files to parse
<strong>unless</strong> you use the option <tt class="docutils literal"><span class="pre">--pmid-lists</span></tt></dd>
<dt>files ending in ".gz"</dt>
<dd>are treated as gzipped MEDLINE XML files</dd>
</dl>
</div>
<div class="section" id="requirements">
<h1>Requirements</h1>
<ul class="simple">
<li>Python 3.2+</li>
<li>SQL Alchemy 0.8+</li>
<li>PostgreSQL 8.4+ or SQLite 3.7+</li>
</ul>
<p><em>Note</em> that while any DB supported by SQL Alchemy should work, all other DBs
are <strong>untested</strong>.</p>
</div>
<div class="section" id="loading-medline">
<h1>Loading MEDLINE</h1>
<p>Please be aware that the MEDLINE distribution <strong>is not unique</strong>, meaning that
it contains a few records multiple times (see the section about
<strong>Version IDs</strong>).</p>
<p>Parsing and loading the baseline into a PostgreSQL DB on the same machine:</p>
<pre class="literal-block">
medic parse baseline/medline14n*.xml.gz
for table in citations abstracts authors chemicals databases \
descriptors identifiers keywords publication_types qualifiers sections;
do psql medline -c "COPY $table FROM '`pwd`/${table}.tab';";
done
</pre>
<p>For the update files, you need to go <em>one-by-one</em>, adding each one <em>in order</em>,
and using the flag <tt class="docutils literal"><span class="pre">--update</span></tt> when parsing the XML. After parsing an XML file
and <em>before</em> loading the dump, run <tt class="docutils literal">medic delete delete.txt</tt> to get rid of
all entities that will be updated or should be removed (PMIDs listed as
<tt class="docutils literal">DeleteCitation</tt>s):</p>
<pre class="literal-block">
# parse a MEDLINE update file:
medic --update parse medline14n1234.xml.gz
# delete its updated and DeleteCitation records:
medic delete delete.txt
# load (COPY) all tables for that MEDLINE file:
for table in citations abstracts authors chemicals databases \
descriptors identifiers keywords publication_types qualifiers sections;
do psql medline -c "COPY $table FROM '`pwd`/${table}.tab';";
done
</pre>
<p>Alternatively - simpler but slower - you can just <tt class="docutils literal">update</tt> from the XML
directly:</p>
<pre class="literal-block">
medic update medline14n1234.xml.gz
</pre>
</div>
<div class="section" id="version-ids">
<h1>Version IDs</h1>
<p>MEDLINE has began to use versions to allow publishers to add multiple citations
for the same PMID. This only occurs with 71 articles from one journal,
"PLOS Curr", in the 2013 baseline, creating a total of 149 non-unique records.</p>
<p>As this is the only journal and as there may only be one record per PMID in the
database, alternative versions are currently being ignored. In other words, if
a MedlineCitation has a VersionID value other than "1", those records can be
skipped to avoid DB errors from non-unique records.</p>
<p>For example, in the 2013 baseline, PMID 20029614 is present ten times in the
baseline, each version at a different stage of revision. Because it is the
first entry (in the order they appear in the baseline files) without a
<tt class="docutils literal">VersionID</tt> or a version of "1" that is the relevant record, <tt class="docutils literal">medic</tt> by
default filters citations with other versions than "1". If you do want to
process other versions of a citation, use the option <tt class="docutils literal"><span class="pre">--all</span></tt>.</p>
<p>To summarize, <em>medic</em> by default <strong>removes</strong> alternate citations.</p>
</div>
<div class="section" id="database-tables">
<h1>Database Tables</h1>
<dl class="docutils">
<dt>Citation (citations)</dt>
<dd><strong>pmid</strong>:BIGINT, <em>status</em>:ENUM(state), <em>year</em>:SMALLINT,
<em>title</em>:TEXT, <em>journal</em>:VARCHAR(256),
<em>pub_date</em>:VARCHAR(256), issue:VARCHAR(256), pagination:VARCHAR(256),
<em>created</em>:DATE, completed:DATE, revised:DATE, modified:DATE</dd>
<dt>Abstract (abstracts)</dt>
<dd><strong>pmid</strong>:FK(Citation), <strong>source</strong>:ENUM(type), copyright:TEXT</dd>
<dt>Section (sections)</dt>
<dd><strong>pmid</strong>:FK(Citation), <strong>source</strong>:ENUM(type), <strong>seq</strong>:SMALLINT,
<em>name</em>:ENUM(section), label:VARCHAR(256), <em>content</em>:TEXT, <em>truncated</em>:BOOLEAN</dd>
<dt>Author (authors)</dt>
<dd><strong>pmid</strong>:FK(Citation), <strong>pos</strong>:SMALLINT, <em>name</em>:TEXT,
initials:VARCHAR(128), forename:VARCHAR(128), suffix:VARCHAR(128),</dd>
<dt>PublicationType (publication_types)</dt>
<dd><strong>pmid</strong>:FK(Citation), <strong>value</strong>:VARCHAR(256)</dd>
<dt>Descriptor (descriptors)</dt>
<dd><strong>pmid</strong>:FK(Citation), <strong>num</strong>:SMALLINT, major:BOOL, <em>name</em>:TEXT</dd>
<dt>Qualifier (qualifiers)</dt>
<dd><strong>pmid</strong>:FK(Descriptor), <strong>num</strong>:FK(Descriptor), <strong>sub</strong>:SMALLINT,
major:BOOL, <em>name</em>:TEXT</dd>
<dt>Identifier (identifiers)</dt>
<dd><strong>pmid</strong>:FK(Citation), <strong>namespace</strong>:VARCHAR(32), <em>value</em>:VARCHAR(256)</dd>
<dt>Database (databases)</dt>
<dd><strong>pmid</strong>:FK(Citation), <strong>name</strong>:VARCHAR(32), <strong>accession</strong>:VARCHAR(256)</dd>
<dt>Chemical (chemicals)</dt>
<dd><strong>pmid</strong>:FK(Citation), <strong>idx</strong>:VARCHAR(32), uid:VARCHAR(256),
<em>name</em>:VARCHAR(256)</dd>
<dt>Keyword (keywords)</dt>
<dd><strong>pmid</strong>:FK(Citation), <strong>owner</strong>:ENUM(owner), <strong>cnt</strong>:SMALLINT,
major:BOOL, <em>value</em>:TEXT</dd>
</dl>
<ul class="simple">
<li><strong>bold</strong> (Composite) Primary Key</li>
<li><em>italic</em> NOT NULL (Strings that may not be NULL are also never empty.)</li>
</ul>
</div>
<div class="section" id="supported-xml-elements">
<h1>Supported XML Elements</h1>
<div class="section" id="entities">
<h2>Entities</h2>
<ul class="simple">
<li>MedlineCitation and ArticleTitle (<tt class="docutils literal">Citation</tt> and <tt class="docutils literal">Identifier</tt>)</li>
<li>Abstract and OtherAbstract (<tt class="docutils literal">Abstract</tt> and <tt class="docutils literal">Section</tt>)</li>
<li>Author (<tt class="docutils literal">Author</tt>)</li>
<li>Chemical (<tt class="docutils literal">Chemical</tt>)</li>
<li>DataBank (<tt class="docutils literal">Database</tt>)</li>
<li>Keyword (<tt class="docutils literal">Keyword</tt>)</li>
<li>MeshHeading (<tt class="docutils literal">Descriptor</tt> and <tt class="docutils literal">Qualifier</tt>)</li>
<li>PublicationType (<tt class="docutils literal">PublicationType</tt>)</li>
<li>DeleteCitation (for deleting records when parsing updates)</li>
</ul>
</div>
<div class="section" id="fields-values">
<h2>Fields/Values</h2>
<ul class="simple">
<li>Abstract (with "NLM" as <tt class="docutils literal">Abstract.source</tt>)</li>
<li>AbstractText (<tt class="docutils literal">Section.name</tt> "Abstract" or the <em>NlmCategory</em>, <tt class="docutils literal">Section.content</tt> with <em>Label</em> as <tt class="docutils literal">Section.label</tt>)</li>
<li>AccessionNumber (<tt class="docutils literal">Database.accession</tt>)</li>
<li>ArticleId (<tt class="docutils literal">Identifier.value</tt> with <em>IdType</em> as <tt class="docutils literal">Identifier.namesapce</tt>; only available in online PubMed XML)</li>
<li>ArticleTitle (<tt class="docutils literal">Citation.title</tt>; if empty, use the VernacularTitle or set to "UNKNOWN")</li>
<li>CollectiveName (<tt class="docutils literal">Author.name</tt>)</li>
<li>CopyrightInformation (<tt class="docutils literal">Abstract.copyright</tt>)</li>
<li>DataBankName (<tt class="docutils literal">Database.name</tt>)</li>
<li>DateCompleted (<tt class="docutils literal">Citation.completed</tt>)</li>
<li>DateCreated (<tt class="docutils literal">Citation.created</tt>)</li>
<li>DateRevised (<tt class="docutils literal">Citation.revised</tt>)</li>
<li>DescriptorName (<tt class="docutils literal">Descriptor.name</tt> with <em>MajorTopicYN</em> as <tt class="docutils literal">Descriptor.major</tt>)</li>
<li>ELocationID (<tt class="docutils literal">Identifier.value</tt> with <em>EIdType</em> as <tt class="docutils literal">Identifier.namespace</tt>)</li>
<li>ForeName (<tt class="docutils literal">Author.forename</tt>)</li>
<li>Initials (<tt class="docutils literal">Author.initials</tt>)</li>
<li>Issue (<tt class="docutils literal">Citation.issue</tt>)</li>
<li>Keyword (<tt class="docutils literal">Keyword.value</tt> with <em>Owner</em> as <tt class="docutils literal">Keyword.owner</tt> and <em>MajorTopicYN</em> as <tt class="docutils literal">Keyword.major</tt>)</li>
<li>LastName (<tt class="docutils literal">Author.name</tt>)</li>
<li>MedlineCitation (with <em>Status</em> as <tt class="docutils literal">Citation.status</tt>)</li>
<li>MedlineTA (<tt class="docutils literal">Citation.journal</tt>)</li>
<li>NameOfSubstance (<tt class="docutils literal">Chemical.name</tt>)</li>
<li>MedlinePgn (<tt class="docutils literal">Citation.pagination</tt>)</li>
<li>OtherAbstract (with <em>Type</em> as <tt class="docutils literal">Abstract.source</tt>)</li>
<li>OtherID (<tt class="docutils literal">Identifier.value</tt> iff <em>Source</em> is "PMC" with <tt class="docutils literal">Identifier.namespace</tt> as "pmc")</li>
<li>PMID (<tt class="docutils literal">Citation.pmid</tt>)</li>
<li>PubDate (<tt class="docutils literal">Citation.pub_date</tt> and <tt class="docutils literal">Citation.year</tt>)</li>
<li>PublicationType (<tt class="docutils literal">PublicationType.value</tt>)</li>
<li>QualifierName (<tt class="docutils literal">Qualifier.name</tt> with <em>MajorTopicYN</em> as <tt class="docutils literal">Qualifier.major</tt>)</li>
<li>RegistryNumber (<tt class="docutils literal">Chemical.uid</tt>)</li>
<li>Suffix (<tt class="docutils literal">Author.suffix</tt>)</li>
<li>VernacularTitle (<tt class="docutils literal">Citation.title</tt> if AbstractTitle is empty)</li>
<li>Volume (<tt class="docutils literal">Citation.issue</tt>)</li>
</ul>
</div>
</div>
<div class="section" id="version-history">
<h1>Version History</h1>
<dl class="docutils">
<dt>2.4.1</dt>
<dd><ul class="first last simple">
<li>Fixed a bug while parsing "PubDate" records that asserted the wrong length.
Thanks to Josef Seiser for reporting it.</li>
</ul>
</dd>
<dt>2.4.0</dt>
<dd><ul class="first last">
<li><p class="first">Added a <tt class="docutils literal">year</tt> column to table <tt class="docutils literal">citations</tt> to make it easier to select for
the year of publication. To migrate/update your DB, run these two commands:</p>
<pre class="literal-block">
ALTER TABLE citations ADD "year" smallint NOT NULL DEFAULT 0;
UPDATE citations SET year = substring(pub_date FROM '^[12][890][0-9][0-9]')::int;
</pre>
<p>Note that the (currently) oldest publications in MEDLINE are from 1809,
from the first issue of the journal "Med Chir Trans".</p>
</li>
</ul>
</dd>
<dt>2.3.1</dt>
<dd><ul class="first last simple">
<li>Fixed a bug when fetching all records on PubMed from database with "ALL".</li>
</ul>
</dd>
<dt>2.3.0</dt>
<dd><ul class="first last simple">
<li>Added special argument "ALL" to write/delete all records.</li>
</ul>
</dd>
<dt>2.2.0</dt>
<dd><ul class="first last">
<li><p class="first">Ensured compatibility with the MEDLINE DTD updates for 2015 and cleaned some
code pieces.
Includes a fix for the bad (long) keyword in PMID 25114415 (with a carriage
return).</p>
</li>
<li><p class="first">A column was added to the ORM, resulting in backwards incompatible change:
From this version on, the trailing string "<tt class="docutils literal">(ABSTRACT TRUNCATED AT xxx
WORDS)</tt>" is stripped from AbstractText and instead the flag <tt class="docutils literal">truncated</tt>
has be added to table <tt class="docutils literal">sections</tt> and is set if the string was present (but
has been removed); To migrate your Postgres database, please run:</p>
<pre class="literal-block">
ALTER TABLE sections ADD "truncated" boolean NOT NULL DEFAULT 'false';
</pre>
<p>Note that for one case this produces a Section with just one whitespace
character, because the original content was only the "ABSTRACT TRUNCATED..."
message.</p>
</li>
<li><p class="first">MEDLINE formatted output is now written to STDOUT or a single file, because
it makes selecting specific fields with grep very easy. Records are
separated with an empty line.</p>
</li>
</ul>
</dd>
<dt>2.1.7</dt>
<dd><ul class="first last simple">
<li>Work-around for the limit of SQLite that only lets you use 999 variables per
query.</li>
<li>Corrected the outdated VernacularTitle documentation in this document.</li>
</ul>
</dd>
<dt>2.1.6</dt>
<dd><ul class="first last simple">
<li>Work-around for parsing citations that have an empty ArticleTitle element
(which they shouldn't, according to the DTD): Either use the VernacularTitle
(e.g., PMID 22536004), or otherwise set the title to "UNKNOWN" (the empty
string is not a valid title) and log a warning.</li>
<li>Work-around for non-unique PublicationType entries (e.g., PMID 10500000):
drop non-unique PublicationTypes (with the same PMID and value).</li>
<li>Corrected left-over "Medline" entity names in this document to "Citation".</li>
</ul>
</dd>
<dt>2.1.5</dt>
<dd><ul class="first last simple">
<li>Added page_size=MAX and synchronous=OFF pragmas for SQLite DBs (hat-tip to
Jason)</li>
</ul>
</dd>
<dt>2.1.4</dt>
<dd><ul class="first last simple">
<li>A MEDLINE issue found by Jason: PMID 24073073 has an empty keyword and
keyword list that should not be there; Medic prevents adding improper data
to the DB by raising an AssertionError.
To deal with such cases, medic now ensures each keyword is non-empty before
attempting to generate a database entry and drops empty (i.e.,
whitespace-only) keyword data.</li>
</ul>
</dd>
<dt>2.1.3</dt>
<dd><ul class="first last simple">
<li>Jason Hennessey changed the (absolute) path of medic's man-page, set to
<tt class="docutils literal">/usr/local/share/man</tt> in the setup script, to a relative location
(<tt class="docutils literal">share/man</tt>) to avoid issues when installing medic in a virtualenv</li>
</ul>
</dd>
<dt>2.1.2</dt>
<dd><ul class="first last simple">
<li>fixed a bug where SQLite did not find the implicit FK->PK reference
(thanks to Jason Hennessey for reporting the issue)</li>
</ul>
</dd>
<dt>2.1.1</dt>
<dd><ul class="first last simple">
<li>added SQLite temporary DB example URL to help output</li>
<li>refactored HTML output code</li>
</ul>
</dd>
<dt>2.1.0</dt>
<dd><ul class="first last simple">
<li>DB schema change from: <tt class="docutils literal">records() <span class="pre">-></span> sections(content)</tt>
to: <tt class="docutils literal">citations(title) <span class="pre">-></span> abstracts(copyright) <span class="pre">-></span> sections(content)</tt></li>
<li>name change: the entity/table Medline/records is now called
Citation/citations</li>
<li>title and copyright text is no longer stored in Section/sections</li>
<li>added a new Abstract/abstracts entity/table with a <tt class="docutils literal">copyright</tt> attribute
(formerly stored in <tt class="docutils literal">sections.content</tt> with <tt class="docutils literal">name</tt> = 'Copyright')</li>
<li>added a new <tt class="docutils literal">citations.title</tt> attribute
(formerly stored in <tt class="docutils literal">sections.content</tt> with <tt class="docutils literal">name</tt> = 'Title')</li>
<li>added a new <tt class="docutils literal">source</tt> primary-key attribute to Section and Abstract
(set to either 'NLM' for regular Abstract elements or to
the value of the OtherAbstract Type attribute for other abstracts)</li>
<li>skipping "Abstract available from the publisher."-only abstracts</li>
</ul>
</dd>
<dt>2.0.2</dt>
<dd><ul class="first last simple">
<li>made the use of <tt class="docutils literal"><span class="pre">--pmid-lists</span></tt> for <tt class="docutils literal">delete</tt> and <tt class="docutils literal">write</tt> implicit</li>
<li>added instructions to bootstrap the tables in a PostgreSQL DB</li>
<li>minor improvements to this manual</li>
<li>fixed a bug when inserting/updating from MEDLINE XML files</li>
</ul>
</dd>
<dt>2.0.1</dt>
<dd><ul class="first last simple">
<li>fixed a bug that lead to skipping of abstracts
(thanks to Chris Roeder for detecting the issue)</li>
</ul>
</dd>
<dt>2.0.0</dt>
<dd><ul class="first last simple">
<li>added Keywords and PublicationTypes</li>
<li>added MEDLINE publication date, volume, issue, and pagination support</li>
<li>added MEDLINE output format and made it the default</li>
<li>DB structure change: descriptors.major and qualifiers.major columns swapped</li>
<li>DB structure change: section.name is now an untyped varchar (OtherAbstract
separation)</li>
<li>cleaned up the ORM test cases</li>
</ul>
</dd>
<dt>1.1.1</dt>
<dd><ul class="first last simple">
<li>code cleanup (PEP8, PyFlake)</li>
<li>fixed an issue where the parser would not leave the skipping state</li>
</ul>
</dd>
<dt>1.1.0</dt>
<dd><ul class="first last simple">
<li><tt class="docutils literal"><span class="pre">--update</span> parse</tt> now writes a file to use with <tt class="docutils literal"><span class="pre">--pmid-lists</span> delete</tt></li>
<li>fixed a bug with CRUD manager</li>
<li>added a man page</li>
</ul>
</dd>
<dt>1.0.2</dt>
<dd><ul class="first last simple">
<li>fixes to make the PyPi version and <tt class="docutils literal">pip install medic</tt> work</li>
</ul>
</dd>
<dt>1.0.1</dt>
<dd><ul class="first last simple">
<li>updates to the setup.py and README.rst files</li>
</ul>
</dd>
<dt>1.0.0</dt>
<dd><ul class="first last simple">
<li>initial release</li>
</ul>
</dd>
</dl>
</div>
<div class="section" id="copyright-and-license">
<h1>Copyright and License</h1>
<p>License: <a class="reference external" href="http://www.gnu.org/licenses/gpl-3.0.html">GNU GPL v3</a>.
Copyright 2012-2014 Florian Leitner. All rights reserved.</p>
</div>
</div>
</body>
</html>