Metadata-Version: 2.4
Name: preon
Version: 0.1.2
Home-page: https://github.com/ermshaua/preon
Author: Arik Ermshaus
Author-email: Arik Ermshaus <ermshaua@informatik.hu-berlin.de>
License: BSD 3-Clause License
        
        Copyright (c) 2021, Arik Ermshaus
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: repository, https://github.com/ermshaua/preon
Keywords: precision-oncology,data-integration,text-mining,normalization,drug-names,cancer-types
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development
Classifier: Topic :: Scientific/Engineering
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Operating System :: MacOS
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.7,<3.13
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: daproli>=0.22
Requires-Dist: jellyfish>=0.9.0
Requires-Dist: nltk>=3.9
Requires-Dist: numpy<2.3.0,>=1.21.0
Requires-Dist: pandas<2.4.0,>=2.0.0
Requires-Dist: pronto>=2.5.0
Requires-Dist: tqdm>=4.66.3
Requires-Dist: lxml>=4.6.3
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# preon (PREcision Oncology Normalization)
preon is a fuzzy search tool for medical entities.

## Installation

You can install preon with PyPi:
`python -m pip install preon`

## Examples

Let's first import the normalizer and EBI drug names with CHEMBL ids.

```python3
>>> from preon.normalization import PrecisionOncologyNormalizer
>>> from preon.drug import store_ebi_drugs, load_ebi_drugs
```

Please download the <a href="https://www.ebi.ac.uk/chembl/explore/compounds/">EBI compound CSV file</a> and store it as a local resource. This step only has to be performed when the resource file is created or updated. 

```python3
>>> store_ebi_drugs("/Users/Username/Downloads/compounds.csv")
```

Next, we can fit the normalizer with the drug names and ids as its reference data.

```python3
>>> drug_names, chembl_ids = load_ebi_drugs()
>>> normalizer = PrecisionOncologyNormalizer().fit(drug_names, chembl_ids)
```

We can now search for drug names and retrieve their CHEMBL ids. Let's search for the cancer drug "Avastin".

```python3
>>> normalizer.query("Avastin")
(['avastin'], [['CHEMBL1201583']], {'match_type': 'exact'})
```

As a result for our query, we get list of matching normalized drug names (in this case `['avastin']`), a list of associated CHEMBL ids for every returned drug name `[['CHEMBL1201583']]` and some meta information about the matching `{'match_type': 'exact'}`. We can also search for multi-token drug names like "Ixabepilone Epothilone B analog" and find CHEMBL ids for the relevant tokens.

```python3
>>> normalizer.query("Ixabepilone Epothilone B analog")
(['ixabepilone'], [['CHEMBL1201752']], {'match_type': 'substring'})
```

We find the relevant drug name `['ixabepilone']` and preon provides the meta information that the matching is based on a substring. On default, preon only looks for 1 matching token. It can also look for n-grams by setting the `n_grams` parameter in the query method. Let's take a harder example, say "Isavuconazonium", but misspell it as "Isavuconaconium".

```python3
>>> normalizer.query("Isavuconaconium")
(['isavuconazonium'], [['CHEMBL1183349']], {'match_type': 'partial', 'edit_distance': 0.067})
```

preon finds the correct drug "Isavuconazonium" and provides the meta information that it is a partial match with 7% distance. It returns drug names with a distance smaller than 20% on default. In order to change this parameter, set the `threshold` argument in the query method. If preon cannot normalize the query, it returns `None` and issues a user warning.

```python3
>>> normalizer.query("risolipase en.")
preon/normalization.py:50: UserWarning: Cannot match risolipase en. to reference data. Try changing the partial matching threshold or number of n-grams.
```

For automatic data integrations, warnings can be stored in a logging file, see e.g. <a href="https://github.com/ermshaua/preon/blob/main/preon/examples/drug_name_normalization.ipynb">here</a>. In a similar fashion, you can also normalize cancer types or genes. We provide gold standards for preon with which we test it. For more detail, see the example <a href="https://github.com/ermshaua/preon/tree/main/preon/examples">notebooks</a>. We also use preon in practice to normalize and integrate medical data in the PREDICT project.

## Citation

The preon package is actively maintained, updated and intended for application. If you use it in your scientific publication, we would appreciate the following <a href="https://doi.org/10.1093/bioinformatics/btae085" target="_blank">citation</a>:

```
@article{preon2023,
  title={preon: Fast and accurate entity normalization for drug names and cancer types in precision oncology},
  author={Arik Ermshaus and Michael Piechotta and Gina R{\"u}ter and Ulrich Keilholz and Ulf Leser and Manuela Benary},
  journal={Bioinformatics},
  year={2023},
  volume={40}
}
```
