|
1 |
| -# pid2bib |
2 |
| -pid2bib (Paper Id to BibTeX), fetch a scientific paper (article) bibliographic entry |
| 1 | +# pubid2bib |
| 2 | + |
| 3 | +pubid2bib (Publication Identifier to BibTeX) is a command line tool to fetch bibliographic |
| 4 | +entries for given publication identifiers using online services offered by |
| 5 | +PubMed, DOI and Google. |
| 6 | + |
| 7 | + |
| 8 | +## Usage: |
| 9 | + |
| 10 | +```bash |
| 11 | +./pubid2bib.py publicationId1 publicationId2 ... publicationIdN |
| 12 | +``` |
| 13 | + |
| 14 | +Where publicationIds are well formed pmids or dois for scientific papers |
| 15 | +or isbns for books. |
| 16 | + |
| 17 | +Example: |
| 18 | + |
| 19 | +```bash |
| 20 | +./pubid2bib.py 31726262 10.1021/acs.jced.5b00684 0735619670 |
| 21 | +``` |
| 22 | + |
| 23 | +Will create three BibTeX files in the current path, named: |
| 24 | + - "Removal of dental alloys and titanium attenuates trace metals and |
| 25 | + biological effects on liver and kidney.bib" |
| 26 | + - "Thermodynamic Properties of R-227ea, R-365mfc, R-115, and R-13I1.bib" |
| 27 | + - "Code Complete.bib" |
| 28 | + |
| 29 | +The filenames will be the publication's titles and the |
| 30 | +bibliographic entries will conform to Bibtex @article and @book |
| 31 | +formats. |
| 32 | + |
| 33 | +## Install |
| 34 | + |
| 35 | +pubid2bib is a standalone Python script. You need Python 3 installed and you |
| 36 | +need to be able to execute Python scripts on your platform. |
| 37 | + |
| 38 | + |
| 39 | +## Inspiration |
| 40 | + |
| 41 | +The fantastic web service <a href="http://www.bioinformatics.org/texmed/">TexMed</a> |
| 42 | +allows to search scientific articles in PubMed and create BibTex bibliographic |
| 43 | +entries for them. This was the inspiration for *pubid2bib*. |
| 44 | + |
| 45 | +In one sense, *pubid2bib* is more limited, it needs you to find the publication |
| 46 | +identifiers first, to create the BibTex entries. But, it is more general in another |
| 47 | +sense, because you can use DOIs for published scientific articles that are not found |
| 48 | +in PubMed and also ISBNs for books. Furthermore, *pubid2bib* can be called from |
| 49 | +scripts. |
| 50 | + |
| 51 | + |
| 52 | +## Scripting |
| 53 | + |
| 54 | +### From bash |
| 55 | + |
| 56 | +Asumming you have a file called publications.txt with publication identifiers in each line, e.g.: |
| 57 | + |
| 58 | +```text |
| 59 | +38942015 |
| 60 | +38917788 |
| 61 | +38935715 |
| 62 | +``` |
| 63 | + |
| 64 | +You can have a bash script that calls pubid2bib for each identifier: |
| 65 | +```bash |
| 66 | +#!/bin/bash |
| 67 | + |
| 68 | +input="publications.txt" |
| 69 | + |
| 70 | +while read -r pmid |
| 71 | +do |
| 72 | + echo "${pmid}" |
| 73 | + pubid2bib.py "${pmid}" |
| 74 | +done < "$input" |
| 75 | +``` |
| 76 | + |
| 77 | +### From Python |
| 78 | + |
| 79 | +You can use the function *dispatch* for each identifier |
| 80 | +```python |
| 81 | +#!/bin/bash |
| 82 | +if __name__ == '__main__': |
| 83 | + from pubid2bib import dispatch |
| 84 | + with open('publications.txt', 'r') as file_object: |
| 85 | + try: |
| 86 | + paperIds = file_object.readlines() |
| 87 | + for pid in paperIds: |
| 88 | + print(pid[:-1]) |
| 89 | + dispatch(pid[:-1]) |
| 90 | + except (IOError, OSError): |
| 91 | + print('Error reading file') |
| 92 | +``` |
| 93 | + |
| 94 | + |
| 95 | +## Abbreviations |
| 96 | + |
| 97 | +pmid: <a href="https://en.wikipedia.org/wiki/PubMed#PubMed_identifier">PubMed identifier</a> |
| 98 | + |
| 99 | +doi: <a href="https://www.doi.org/the-identifier/what-is-a-doi/">Digital Object Identifier</a> |
| 100 | + |
| 101 | +isbn: <a href="https://en.wikipedia.org/wiki/ISBN">International Standard Book Number</a> |
| 102 | + |
0 commit comments