@fbraza/pi-cite 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,436 @@
1
+ # PubMed Search Syntax and Field Tags
2
+
3
+ ## Boolean Operators
4
+
5
+ PubMed supports standard Boolean operators to combine search terms:
6
+
7
+ ### AND
8
+ Retrieves results containing all search terms. PubMed automatically applies AND between separate concepts.
9
+
10
+ **Example**:
11
+ ```
12
+ diabetes AND hypertension
13
+ ```
14
+
15
+ ### OR
16
+ Retrieves results containing at least one of the search terms. Useful for synonyms or related concepts.
17
+
18
+ **Example**:
19
+ ```
20
+ heart attack OR myocardial infarction
21
+ ```
22
+
23
+ ### NOT
24
+ Excludes results containing the specified term. Use cautiously as it may eliminate relevant results.
25
+
26
+ **Example**:
27
+ ```
28
+ cancer NOT lung
29
+ ```
30
+
31
+ **Precedence**: Operations are processed left to right. Use parentheses to control evaluation order:
32
+ ```
33
+ (heart attack OR myocardial infarction) AND treatment
34
+ ```
35
+
36
+ ## Phrase Searching
37
+
38
+ ### Double Quotes
39
+ Enclose exact phrases in double quotes to search for terms in specific order:
40
+
41
+ ```
42
+ "kidney allograft"
43
+ "machine learning"
44
+ "systematic review"
45
+ ```
46
+
47
+ ### Field Tags
48
+ Alternative method using field tags:
49
+ ```
50
+ kidney allograft[Title]
51
+ ```
52
+
53
+ ## Wildcards
54
+
55
+ Use asterisk (*) to substitute for zero or more characters:
56
+
57
+ **Rules**:
58
+ - Minimum 4 characters before first wildcard
59
+ - Matches word variations and plurals
60
+
61
+ **Examples**:
62
+ ```
63
+ vaccin* → matches vaccine, vaccination, vaccines, vaccinate
64
+ pediatr* → matches pediatric, pediatrics, pediatrician
65
+ colo*r → matches color, colour
66
+ ```
67
+
68
+ **Limitations**:
69
+ - Cannot use at beginning of search term
70
+ - May retrieve unexpected variations
71
+
72
+ ## Proximity Searching
73
+
74
+ Search for terms within a specified distance from each other. Only available in Title, Title/Abstract, and Affiliation fields.
75
+
76
+ **Syntax**: `"search terms"[field:~N]`
77
+ - N = maximum number of words between terms
78
+
79
+ **Examples**:
80
+ ```
81
+ "vitamin C"[Title:~3] → vitamin within 3 words of C in title
82
+ "breast cancer screening"[TIAB:~5] → terms within 5 words in title/abstract
83
+ ```
84
+
85
+ ## Search Field Tags
86
+
87
+ Field tags limit searches to specific parts of PubMed records. Format: `term[tag]`
88
+
89
+ ### Author Searching
90
+
91
+ | Tag | Field | Example |
92
+ |-----|-------|---------|
93
+ | [au] | Author | smith j[au] |
94
+ | [1au] | First Author | jones m[1au] |
95
+ | [lastau] | Last Author | wilson k[lastau] |
96
+ | [fau] | Full Author Name | smith john a[fau] |
97
+
98
+ **Author Search Notes**:
99
+ - Full author names searchable from 2002 forward
100
+ - Format: last name + initials (e.g., `smith ja[au]`)
101
+ - Can search without field tag, but [au] ensures accuracy
102
+
103
+ **Corporate Authors**:
104
+ Search organizations as authors:
105
+ ```
106
+ world health organization[au]
107
+ ```
108
+
109
+ ### Title and Abstract
110
+
111
+ | Tag | Field | Example |
112
+ |-----|-------|---------|
113
+ | [ti] | Title | diabetes[ti] |
114
+ | [ab] | Abstract | treatment[ab] |
115
+ | [tiab] | Title/Abstract | cancer screening[tiab] |
116
+ | [tw] | Text Word | cardiovascular[tw] |
117
+
118
+ **Notes**:
119
+ - [tw] searches title, abstract, and other text fields
120
+ - [tiab] is most commonly used for comprehensive searching
121
+
122
+ ### Journal Information
123
+
124
+ | Tag | Field | Example |
125
+ |-----|-------|---------|
126
+ | [ta] | Journal Title Abbreviation | Science[ta] |
127
+ | [jour] | Journal | New England Journal of Medicine[jour] |
128
+ | [issn] | ISSN | 0028-4793[issn] |
129
+
130
+ ### Date Fields
131
+
132
+ | Tag | Field | Format | Example |
133
+ |-----|-------|--------|---------|
134
+ | [dp] | Publication Date | YYYY/MM/DD | 2023[dp] |
135
+ | [edat] | Entrez Date | YYYY/MM/DD | 2023/01/15[edat] |
136
+ | [crdt] | Create Date | YYYY/MM/DD | 2023[crdt] |
137
+ | [mhda] | MeSH Date | YYYY/MM/DD | 2023[mhda] |
138
+
139
+ **Date Ranges**:
140
+ Use colon to specify ranges:
141
+ ```
142
+ 2020:2023[dp] → publications from 2020 to 2023
143
+ 2023/01/01:2023/06/30[dp] → first half of 2023
144
+ ```
145
+
146
+ **Relative Dates**:
147
+ PubMed filters provide common ranges:
148
+ - Last 1 year
149
+ - Last 5 years
150
+ - Last 10 years
151
+ - Custom date range
152
+
153
+ ### MeSH and Subject Headings
154
+
155
+ | Tag | Field | Example |
156
+ |-----|-------|---------|
157
+ | [mh] | MeSH Terms | diabetes mellitus[mh] |
158
+ | [majr] | MeSH Major Topic | hypertension[majr] |
159
+ | [mesh] | MeSH Terms | cancer[mesh] |
160
+ | [sh] | MeSH Subheading | therapy[sh] |
161
+
162
+ **MeSH Searching**:
163
+ - Medical Subject Headings provide controlled vocabulary
164
+ - [mh] includes narrower terms automatically
165
+ - [majr] limits to articles where topic is main focus
166
+ - Combine with subheadings: `diabetes mellitus/therapy[mh]`
167
+
168
+ **Common MeSH Subheadings**:
169
+ - /diagnosis
170
+ - /drug therapy
171
+ - /epidemiology
172
+ - /etiology
173
+ - /prevention & control
174
+ - /therapy
175
+
176
+ ### Publication Types
177
+
178
+ | Tag | Field | Example |
179
+ |-----|-------|---------|
180
+ | [pt] | Publication Type | clinical trial[pt] |
181
+ | [ptyp] | Publication Type | review[ptyp] |
182
+
183
+ **Common Publication Types**:
184
+ - Clinical Trial
185
+ - Meta-Analysis
186
+ - Randomized Controlled Trial
187
+ - Review
188
+ - Systematic Review
189
+ - Case Reports
190
+ - Letter
191
+ - Editorial
192
+ - Guideline
193
+
194
+ **Example**:
195
+ ```
196
+ cancer AND systematic review[pt]
197
+ ```
198
+
199
+ ### Other Useful Fields
200
+
201
+ | Tag | Field | Example |
202
+ |-----|-------|---------|
203
+ | [la] | Language | english[la] |
204
+ | [affil] | Affiliation | harvard[affil] |
205
+ | [pmid] | PubMed ID | 12345678[pmid] |
206
+ | [pmc] | PMC ID | PMC123456[pmc] |
207
+ | [doi] | DOI | 10.1234/example[doi] |
208
+ | [gr] | Grant Number | R01CA123456[gr] |
209
+ | [isbn] | ISBN | 9780123456789[isbn] |
210
+ | [pg] | Pagination | 123-145[pg] |
211
+ | [vi] | Volume | 45[vi] |
212
+ | [ip] | Issue | 3[ip] |
213
+
214
+ ### Supplemental Concepts
215
+
216
+ | Tag | Field | Example |
217
+ |-----|-------|---------|
218
+ | [nm] | Substance Name | aspirin[nm] |
219
+ | [ps] | Personal Name | darwin charles[ps] |
220
+
221
+ ## Automatic Term Mapping (ATM)
222
+
223
+ When searching without field tags, PubMed automatically:
224
+
225
+ 1. **Searches MeSH translation table** for matching MeSH terms
226
+ 2. **Searches journal translation table** for journal names
227
+ 3. **Searches author index** for author names
228
+ 4. **Searches full text** for remaining terms
229
+
230
+ **Bypass ATM**:
231
+ - Use double quotes: `"breast cancer"`
232
+ - Use field tags: `breast cancer[tiab]`
233
+
234
+ **View Translation**:
235
+ Use Advanced Search to see how PubMed translated your query in the Search Details box.
236
+
237
+ ## Filters and Limits
238
+
239
+ ### Article Types
240
+ - Clinical Trial
241
+ - Meta-Analysis
242
+ - Randomized Controlled Trial
243
+ - Review
244
+ - Systematic Review
245
+
246
+ ### Text Availability
247
+ - Free full text
248
+ - Full text
249
+ - Abstract
250
+
251
+ ### Publication Date
252
+ - Last 1 year
253
+ - Last 5 years
254
+ - Last 10 years
255
+ - Custom date range
256
+
257
+ ### Species
258
+ - Humans
259
+ - Animals (specific species available)
260
+
261
+ ### Sex
262
+ - Female
263
+ - Male
264
+
265
+ ### Age Groups
266
+ - Child (0-18 years)
267
+ - Infant (birth-23 months)
268
+ - Child, Preschool (2-5 years)
269
+ - Child (6-12 years)
270
+ - Adolescent (13-18 years)
271
+ - Adult (19+ years)
272
+ - Aged (65+ years)
273
+ - 80 and over
274
+
275
+ ### Languages
276
+ - English
277
+ - Spanish
278
+ - French
279
+ - German
280
+ - Chinese
281
+ - And many others
282
+
283
+ ### Other Filters
284
+ - Journal categories
285
+ - Subject area
286
+ - Article attributes (e.g., has abstract, free PMC article)
287
+
288
+ ## Advanced Search Strategies
289
+
290
+ ### Clinical Queries
291
+ PubMed provides specialized filters for clinical research:
292
+
293
+ **Study Categories**:
294
+ - Therapy (narrow/broad)
295
+ - Diagnosis (narrow/broad)
296
+ - Etiology (narrow/broad)
297
+ - Prognosis (narrow/broad)
298
+ - Clinical prediction guides
299
+
300
+ **Medical Genetics**:
301
+ - Diagnosis
302
+ - Differential diagnosis
303
+ - Clinical description
304
+ - Management
305
+ - Genetic counseling
306
+
307
+ ### Hedges and Filters
308
+ Pre-built search strategies for specific purposes:
309
+ - Systematic review filters
310
+ - Quality filters for study types
311
+ - Geographic filters
312
+
313
+ ### Combining Searches
314
+ Use Advanced Search to combine previous queries:
315
+ ```
316
+ #1 AND #2
317
+ #3 OR #4
318
+ #5 NOT #6
319
+ ```
320
+
321
+ ### Search History
322
+ - Saves up to 100 searches
323
+ - Expires after 8 hours of inactivity
324
+ - Access via Advanced Search page
325
+ - Combine using # references
326
+
327
+ ## Best Practices
328
+
329
+ ### 1. Start Broad, Then Narrow
330
+ Begin with general terms and add specificity:
331
+ ```
332
+ diabetes → too broad
333
+ diabetes mellitus type 2 → better
334
+ diabetes mellitus type 2[mh] AND treatment[tiab] → more specific
335
+ ```
336
+
337
+ ### 2. Use Synonyms with OR
338
+ Include alternative terms:
339
+ ```
340
+ heart attack OR myocardial infarction OR MI
341
+ ```
342
+
343
+ ### 3. Combine Concepts with AND
344
+ Link different aspects of your research question:
345
+ ```
346
+ (heart attack OR myocardial infarction) AND (aspirin OR acetylsalicylic acid) AND prevention
347
+ ```
348
+
349
+ ### 4. Leverage MeSH Terms
350
+ Use MeSH for consistent indexing:
351
+ ```
352
+ diabetes mellitus[mh] AND hypertension[mh]
353
+ ```
354
+
355
+ ### 5. Use Filters Strategically
356
+ Apply filters to refine results:
357
+ - Publication date for recent research
358
+ - Article type for specific study designs
359
+ - Free full text for accessible articles
360
+
361
+ ### 6. Review Search Details
362
+ Check how PubMed interpreted your search in Advanced Search to ensure accuracy.
363
+
364
+ ### 7. Save Effective Searches
365
+ Create My NCBI account to:
366
+ - Save searches
367
+ - Set up email alerts
368
+ - Create collections
369
+
370
+ ## Common Search Patterns
371
+
372
+ ### Systematic Review Search
373
+ ```
374
+ (breast cancer[tiab] OR breast neoplasm[mh]) AND (screening[tiab] OR early detection[tiab]) AND systematic review[pt]
375
+ ```
376
+
377
+ ### Clinical Trial Search
378
+ ```
379
+ diabetes mellitus type 2[mh] AND metformin[nm] AND randomized controlled trial[pt] AND 2020:2024[dp]
380
+ ```
381
+
382
+ ### Recent Research by Author
383
+ ```
384
+ smith ja[au] AND cancer[tiab] AND 2023:2024[dp] AND english[la]
385
+ ```
386
+
387
+ ### Drug Treatment Studies
388
+ ```
389
+ hypertension[mh] AND (amlodipine[nm] OR losartan[nm]) AND drug therapy[sh] AND humans[mh]
390
+ ```
391
+
392
+ ### Geographic-Specific Research
393
+ ```
394
+ malaria[tiab] AND (africa[affil] OR african[tiab]) AND 2020:2024[dp]
395
+ ```
396
+
397
+ ## Special Characters
398
+
399
+ | Character | Purpose | Example |
400
+ |-----------|---------|---------|
401
+ | * | Wildcard | colo*r |
402
+ | " " | Phrase search | "breast cancer" |
403
+ | ( ) | Group terms | (A OR B) AND C |
404
+ | : | Range | 2020:2023[dp] |
405
+ | - | Hyphenated terms | COVID-19 |
406
+ | / | MeSH subheading | diabetes/therapy[mh] |
407
+
408
+ ## Troubleshooting
409
+
410
+ ### Too Many Results
411
+ - Add more specific terms
412
+ - Use field tags to limit search scope
413
+ - Apply date restrictions
414
+ - Use filters for article type
415
+ - Add additional concepts with AND
416
+
417
+ ### Too Few Results
418
+ - Remove restrictive terms
419
+ - Use OR to add synonyms
420
+ - Check spelling and terminology
421
+ - Remove field tags for broader search
422
+ - Expand date range
423
+ - Remove filters
424
+
425
+ ### No Results
426
+ - Check spelling using ESpell
427
+ - Try alternative terminology
428
+ - Remove field tags
429
+ - Verify correct database (PubMed vs. PMC)
430
+ - Broaden search terms
431
+
432
+ ### Unexpected Results
433
+ - Review Search Details to see query translation
434
+ - Use field tags to prevent automatic term mapping
435
+ - Check for common synonyms that may be included
436
+ - Refine with additional limiting terms
@@ -0,0 +1,53 @@
1
+ """Export markdown, CSV, and pickle outputs for the unified literature skill."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import pickle
7
+ from typing import Dict, List, Optional
8
+
9
+ from generate_table import build_table_rows, rows_to_markdown, write_csv
10
+ from synthesis import synthesize_literature
11
+
12
+
13
+ def export_all(
14
+ papers: List[Dict],
15
+ output_dir: str,
16
+ topic: str = "",
17
+ mode: str = "general",
18
+ experiments: Optional[List[Dict]] = None,
19
+ ) -> Dict:
20
+ os.makedirs(output_dir, exist_ok=True)
21
+
22
+ synthesis = synthesize_literature(papers, experiments=experiments, topic=topic, mode=mode)
23
+ rows = build_table_rows(papers, experiments=experiments, mode=mode)
24
+
25
+ markdown_path = os.path.join(output_dir, "literature_report.md")
26
+ csv_path = os.path.join(output_dir, "paper_summary_table.csv")
27
+ pickle_path = os.path.join(output_dir, "analysis_object.pkl")
28
+
29
+ with open(markdown_path, "w", encoding="utf-8") as handle:
30
+ handle.write("# Literature Report\n\n")
31
+ handle.write(synthesis["narrative_markdown"])
32
+ handle.write("\n\n")
33
+ handle.write(rows_to_markdown(rows))
34
+
35
+ write_csv(rows, csv_path)
36
+
37
+ payload = {
38
+ "topic": topic,
39
+ "mode": mode,
40
+ "papers": papers,
41
+ "experiments": experiments or [],
42
+ "synthesis": synthesis,
43
+ "table_rows": rows,
44
+ }
45
+ with open(pickle_path, "wb") as handle:
46
+ pickle.dump(payload, handle)
47
+
48
+ return {
49
+ "markdown": markdown_path,
50
+ "csv": csv_path,
51
+ "pickle": pickle_path,
52
+ "rows": len(rows),
53
+ }