# pubmed-mapper: A Python Library that map PubMed XML to Python object

## UML

# todo: add UML here.

## installation

```shell
pip install pubmed-mapper
```

## usage

### use as API

```python
from lxml import etree
from pubmed_mapper import Article


infile = 'xxx.xml'
with open(infile) as fp:
    root = etree.parse(fp)


articles = []
for pubmed_article_element in root.xpath('/PubmedArticleSet/PubmedArticle'):
    article =  Article.parse_element(pubmed_article_element)
    articles.append(article)
```

### use as command line software

#### parse single PubMed XML file

```
pubmed-mapper file -i data/pubmed21n0001.xml -o output/pubmed21n0001.jl
```

#### parse a directory who contains multiple PubMed XML files

```
pubmed-mapper directory -i data/ -o output/pubmed-mapper.jl
```

#### FAQs

##### 1. What is pubmed-mapper.log generated by pubmed-mapper?

pubmed-mapper.log is the default log file generate by pubmed-mapper,
you can change the file by using *--log-file* options:

```
pubmed-mapper --log-file my-custom.log file -i data/pubmed21n0001.xml -o output/pubmed21n0001.jl
```

You can go to this log file to find out more parsing details.

##### 2. I want log detail message in my log file?

Using *--log-level* can log more detail message:

```
pubmed-mapper --log-file my-custom.log --log-level DEBUG file -i data/pubmed21n0001.xml -o output/pubmed21n0001.jl
```
