Skip to content

Commit

Permalink
Merge pull request #2 from asiomchen/cleanup
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
asiomchen authored Jun 7, 2024
2 parents 27780d1 + 3d78775 commit 75c081b
Show file tree
Hide file tree
Showing 22 changed files with 880 additions and 2,874 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,4 @@ cython_debug/
#.idea/
test.ipynb
.vscode
lcov.info
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ repos:
- id: requirements-txt-fixer
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.9
rev: v0.4.4
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
111 changes: 107 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pip install git+https://github.com/asiomchen/molharbor
To start using MolHarbour, you need to create an instance of the `Molport` class and log in to the Molport API using your username and password or API key.

```python
from molharbor.checker import Molport
from molharbor import Molport
molport = Molport()
molport.login(username="john.spade", password="fasdga34a3")
```
Expand All @@ -49,7 +49,7 @@ Additionally, you can specify the maximum number of results to return using the
#### Exact search

```python
from molharbor.checker import SearchType
from molharbor import SearchType
molport.find("O=C(O)c1ccccc1", search_type=SearchType.EXACT)

[[MolportCompound(smiles='OC(=O)c1ccccc1', molport_id='Molport-000-871-563', link='https://www.molport.com/shop/compound/Molport-000-871-563'),
Expand Down Expand Up @@ -107,7 +107,7 @@ However, you can access the raw response using the `return_response` parameter.
All the fields have the same name as in Molport API docs, only lowercase and the spaces are replaced with underscores( e.g. Shipment Type -> shipment_type)

```python
from molharbor.checker import SearchType
from molharbor import SearchType
molport.find("O=C(O)c1ccccc1", search_type=SearchType.SUBSTRUCTURE, max_results=1, return_response=False)

[[MolportCompound(smiles='OC(=O)c1cc(C#N)c(Cl)cc1Cl', molport_id='Molport-051-434-827', link='https://www.molport.com/shop/compound/Molport-051-434-827')]]
Expand All @@ -122,4 +122,107 @@ molport.find("O=C(O)c1ccccc1", search_type=SearchType.SUBSTRUCTURE, max_results=

### Supliers search

TBE
Having a Molport ID, you can search for suppliers using the `get_suppliers` method. Similar too `find()` method, you could either recieve a raw pydantic response with all the fields having the same name as in Molport API docs, only lowercase and the spaces are replaced with underscores( e.g. Shipment Type -> shipment_type) or processed dataframe with most important fields

#### Processed dataframe



```python
df = molport.get_suppliers("Molport-001-794-639")
df[["supplier_name", "supplier_type", "amount", "measure",
"price", "currency", "delivery_days",
"stock", "stock_measure", "last_update_date_exact"]].head()
```
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>supplier_name</th>
<th>supplier_type</th>
<th>amount</th>
<th>measure</th>
<th>price</th>
<th>currency</th>
<th>delivery_days</th>
<th>stock</th>
<th>stock_measure</th>
<th>last_update_date_exact</th>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td>BIONET - Key Organics Ltd.</td>
<td>screening_block_suppliers</td>
<td>1.0</td>
<td>mg</td>
<td>45.0</td>
<td>USD</td>
<td>4</td>
<td>1187.6</td>
<td>mg</td>
<td>May 17, 2024</td>
</tr>
<tr>
<th>1</th>
<td>BIONET - Key Organics Ltd.</td>
<td>screening_block_suppliers</td>
<td>5.0</td>
<td>mg</td>
<td>53.0</td>
<td>USD</td>
<td>4</td>
<td>1187.6</td>
<td>mg</td>
<td>May 17, 2024</td>
</tr>
<tr>
<th>2</th>
<td>BIONET - Key Organics Ltd.</td>
<td>screening_block_suppliers</td>
<td>10.0</td>
<td>mg</td>
<td>64.0</td>
<td>USD</td>
<td>4</td>
<td>1187.6</td>
<td>mg</td>
<td>May 17, 2024</td>
</tr>
<tr>
<th>3</th>
<td>BIONET - Key Organics Ltd.</td>
<td>screening_block_suppliers</td>
<td>1.0</td>
<td>mg</td>
<td>45.0</td>
<td>USD</td>
<td>4</td>
<td>1187.6</td>
<td>mg</td>
<td>May 17, 2024</td>
</tr>
<tr>
<th>4</th>
<td>BIONET - Key Organics Ltd.</td>
<td>screening_block_suppliers</td>
<td>2.0</td>
<td>mg</td>
<td>47.0</td>
<td>USD</td>
<td>4</td>
<td>1187.6</td>
<td>mg</td>
<td>May 17, 2024</td>
</tr>
</tbody>
</table>

#### Raw response

```python
molport.get_suppliers("Molport-000-871-563", return_response=True)

ResponseSupplier(result=Result(status=1, message='Molecule found!'), data=DataSupplier(molecule=Molecule2(id=871563, molport_id='Molport-000-871-563', smiles='OC(=O)c1ccccc1', .....
```
Loading

0 comments on commit 75c081b

Please sign in to comment.