selfies
Advanced tools
+37
-9
| Metadata-Version: 2.1 | ||
| Name: selfies | ||
| Version: 1.0.0 | ||
| Version: 1.0.1 | ||
| Summary: SELFIES (SELF-referencIng Embedded Strings) is a general-purpose, sequence-based, robust representation of semantically constrained graphs. | ||
@@ -11,4 +11,9 @@ Home-page: https://github.com/aspuru-guzik-group/selfies | ||
| [](https://GitHub.com/aspuru-guzik-group/selfies/releases/) | ||
|  | ||
| [](https://opensource.org/licenses/Apache-2.0) | ||
| [](https://GitHub.com/aspuru-guzik-group/selfies/graphs/commit-activity) | ||
| [](https://GitHub.com/aspuru-guzik-group/selfies/issues/) | ||
| [](http://selfies.readthedocs.io/?badge=latest) | ||
| [](https://GitHub.com/aspuru-guzik-group/selfies/graphs/contributors/) | ||
@@ -25,3 +30,3 @@ | ||
| Pascal Friederich, and Alan Aspuru-Guzik at | ||
| arXiv (https://arxiv.org/abs/1905.13741). | ||
| https://arxiv.org/abs/1905.13741. | ||
@@ -36,2 +41,23 @@ | ||
| To check if the correct version of ``selfies`` is installed | ||
| (see [CHANGELOG](https://github.com/aspuru-guzik-group/selfies/blob/master/CHANGELOG.md) | ||
| to verify the latest version), use the following pip command: | ||
| ```bash | ||
| pip show selfies | ||
| ``` | ||
| To upgrade to the latest release of ``selfies`` if you are using an | ||
| older version, use the following pip command: | ||
| ```bash | ||
| pip install selfies --upgrade | ||
| ``` | ||
| ## Documentation | ||
| The documentation can be found on | ||
| [ReadTheDocs](https://selfies.readthedocs.io/en/latest/). | ||
| Alternatively, it can be built from the ``docs/`` directory. | ||
| ## Usage | ||
@@ -120,9 +146,3 @@ | ||
| ## Documentation | ||
| The documentation can be found on | ||
| [ReadTheDocs](https://selfies-mirror.readthedocs.io/en/latest/?). | ||
| Alternatively, it can be built from the ``docs/`` directory. | ||
| ## Tests | ||
@@ -161,2 +181,5 @@ SELFIES uses `pytest` with `tox` as its testing framework. | ||
| ## Version History | ||
| See [CHANGELOG](https://github.com/aspuru-guzik-group/selfies/blob/master/CHANGELOG.md). | ||
| ## Credits | ||
@@ -174,5 +197,10 @@ | ||
| Classifier: Programming Language :: Python :: 3 | ||
| Classifier: Programming Language :: Python :: 3.5 | ||
| Classifier: Programming Language :: Python :: 3.6 | ||
| Classifier: Programming Language :: Python :: 3.7 | ||
| Classifier: Programming Language :: Python :: 3.8 | ||
| Classifier: Programming Language :: Python :: 3 :: Only | ||
| Classifier: License :: OSI Approved :: Apache Software License | ||
| Classifier: Operating System :: OS Independent | ||
| Requires-Python: >=3.7 | ||
| Requires-Python: >=3.5 | ||
| Description-Content-Type: text/markdown |
+30
-7
| # SELFIES | ||
| [](https://GitHub.com/aspuru-guzik-group/selfies/releases/) | ||
|  | ||
| [](https://opensource.org/licenses/Apache-2.0) | ||
| [](https://GitHub.com/aspuru-guzik-group/selfies/graphs/commit-activity) | ||
| [](https://GitHub.com/aspuru-guzik-group/selfies/issues/) | ||
| [](http://selfies.readthedocs.io/?badge=latest) | ||
| [](https://GitHub.com/aspuru-guzik-group/selfies/graphs/contributors/) | ||
@@ -16,3 +21,3 @@ | ||
| Pascal Friederich, and Alan Aspuru-Guzik at | ||
| arXiv (https://arxiv.org/abs/1905.13741). | ||
| https://arxiv.org/abs/1905.13741. | ||
@@ -27,2 +32,23 @@ | ||
| To check if the correct version of ``selfies`` is installed | ||
| (see [CHANGELOG](https://github.com/aspuru-guzik-group/selfies/blob/master/CHANGELOG.md) | ||
| to verify the latest version), use the following pip command: | ||
| ```bash | ||
| pip show selfies | ||
| ``` | ||
| To upgrade to the latest release of ``selfies`` if you are using an | ||
| older version, use the following pip command: | ||
| ```bash | ||
| pip install selfies --upgrade | ||
| ``` | ||
| ## Documentation | ||
| The documentation can be found on | ||
| [ReadTheDocs](https://selfies.readthedocs.io/en/latest/). | ||
| Alternatively, it can be built from the ``docs/`` directory. | ||
| ## Usage | ||
@@ -111,9 +137,3 @@ | ||
| ## Documentation | ||
| The documentation can be found on | ||
| [ReadTheDocs](https://selfies-mirror.readthedocs.io/en/latest/?). | ||
| Alternatively, it can be built from the ``docs/`` directory. | ||
| ## Tests | ||
@@ -152,2 +172,5 @@ SELFIES uses `pytest` with `tox` as its testing framework. | ||
| ## Version History | ||
| See [CHANGELOG](https://github.com/aspuru-guzik-group/selfies/blob/master/CHANGELOG.md). | ||
| ## Credits | ||
@@ -154,0 +177,0 @@ |
| Metadata-Version: 2.1 | ||
| Name: selfies | ||
| Version: 1.0.0 | ||
| Version: 1.0.1 | ||
| Summary: SELFIES (SELF-referencIng Embedded Strings) is a general-purpose, sequence-based, robust representation of semantically constrained graphs. | ||
@@ -11,4 +11,9 @@ Home-page: https://github.com/aspuru-guzik-group/selfies | ||
| [](https://GitHub.com/aspuru-guzik-group/selfies/releases/) | ||
|  | ||
| [](https://opensource.org/licenses/Apache-2.0) | ||
| [](https://GitHub.com/aspuru-guzik-group/selfies/graphs/commit-activity) | ||
| [](https://GitHub.com/aspuru-guzik-group/selfies/issues/) | ||
| [](http://selfies.readthedocs.io/?badge=latest) | ||
| [](https://GitHub.com/aspuru-guzik-group/selfies/graphs/contributors/) | ||
@@ -25,3 +30,3 @@ | ||
| Pascal Friederich, and Alan Aspuru-Guzik at | ||
| arXiv (https://arxiv.org/abs/1905.13741). | ||
| https://arxiv.org/abs/1905.13741. | ||
@@ -36,2 +41,23 @@ | ||
| To check if the correct version of ``selfies`` is installed | ||
| (see [CHANGELOG](https://github.com/aspuru-guzik-group/selfies/blob/master/CHANGELOG.md) | ||
| to verify the latest version), use the following pip command: | ||
| ```bash | ||
| pip show selfies | ||
| ``` | ||
| To upgrade to the latest release of ``selfies`` if you are using an | ||
| older version, use the following pip command: | ||
| ```bash | ||
| pip install selfies --upgrade | ||
| ``` | ||
| ## Documentation | ||
| The documentation can be found on | ||
| [ReadTheDocs](https://selfies.readthedocs.io/en/latest/). | ||
| Alternatively, it can be built from the ``docs/`` directory. | ||
| ## Usage | ||
@@ -120,9 +146,3 @@ | ||
| ## Documentation | ||
| The documentation can be found on | ||
| [ReadTheDocs](https://selfies-mirror.readthedocs.io/en/latest/?). | ||
| Alternatively, it can be built from the ``docs/`` directory. | ||
| ## Tests | ||
@@ -161,2 +181,5 @@ SELFIES uses `pytest` with `tox` as its testing framework. | ||
| ## Version History | ||
| See [CHANGELOG](https://github.com/aspuru-guzik-group/selfies/blob/master/CHANGELOG.md). | ||
| ## Credits | ||
@@ -174,5 +197,10 @@ | ||
| Classifier: Programming Language :: Python :: 3 | ||
| Classifier: Programming Language :: Python :: 3.5 | ||
| Classifier: Programming Language :: Python :: 3.6 | ||
| Classifier: Programming Language :: Python :: 3.7 | ||
| Classifier: Programming Language :: Python :: 3.8 | ||
| Classifier: Programming Language :: Python :: 3 :: Only | ||
| Classifier: License :: OSI Approved :: Apache Software License | ||
| Classifier: Operating System :: OS Independent | ||
| Requires-Python: >=3.7 | ||
| Requires-Python: >=3.5 | ||
| Description-Content-Type: text/markdown |
@@ -28,3 +28,3 @@ #!/usr/bin/env python | ||
| __version__ = "1.0.0" | ||
| __version__ = "1.0.1" | ||
@@ -31,0 +31,0 @@ __all__ = ['encoder', 'decoder', |
@@ -0,1 +1,2 @@ | ||
| from collections import OrderedDict | ||
| from typing import Dict, Iterable, List, Optional, Tuple, Union | ||
@@ -44,4 +45,3 @@ | ||
| if print_error: | ||
| print(err) | ||
| print("Could not decode SELFIES. Please contact authors.") | ||
| print("Decoding error '{}': {}.".format(selfies, err)) | ||
| return None | ||
@@ -261,3 +261,3 @@ | ||
| # so that only valid rings are left and placed into <ring_locs>. | ||
| ring_locs = {} | ||
| ring_locs = OrderedDict() | ||
@@ -264,0 +264,0 @@ for left_idx, right_idx, bond_symbol in rings: |
+26
-12
@@ -61,2 +61,5 @@ from typing import Dict, Iterable, List, Optional, Tuple | ||
| try: | ||
| if '*' in smiles: | ||
| raise ValueError("wildcard atom '*' not supported") | ||
| all_selfies = [] # process dot-separated fragments separately | ||
@@ -69,4 +72,3 @@ for s in smiles.split("."): | ||
| if print_error: | ||
| print(err) | ||
| print('Could not encode SMILES. Please contact authors.') | ||
| print("Encoding error '{}': {}.".format(smiles, err)) | ||
| return None | ||
@@ -118,3 +120,3 @@ | ||
| elif smiles[i] in ('(', ')'): # open and closed branch brackets | ||
| bond = smiles[i + 1] | ||
| bond = smiles[i + 1: i + 2] | ||
| symbol = smiles[i] | ||
@@ -130,2 +132,8 @@ symbol_type = BRANCH_TYPE | ||
| # quick chirality specification check | ||
| chiral_i = symbol.find('@') | ||
| if symbol[chiral_i + 1].isalpha() and symbol[chiral_i + 1] != 'H': | ||
| raise ValueError("chiral specification '{}' not supported" | ||
| .format(symbol)) | ||
| elif smiles[i].isdigit(): # one-digit ring number | ||
@@ -142,3 +150,3 @@ symbol = smiles[i] | ||
| else: | ||
| raise ValueError(f"Unknown symbol '{smiles[i]}' in SMILES.") | ||
| raise ValueError("unrecognized symbol '{}'".format(smiles[i])) | ||
@@ -174,2 +182,6 @@ yield bond, symbol, symbol_type | ||
| if rings: | ||
| raise ValueError("malformed ring numbering or ring numbering " | ||
| "across a dot symbol") | ||
| return selfies | ||
@@ -205,8 +217,8 @@ | ||
| if symbol[0] == '[': | ||
| selfies += f"[{bond}{symbol[1:-1]}expl]" | ||
| selfies += "[{}{}expl]".format(bond, symbol[1:-1]) | ||
| else: | ||
| selfies += f"[{bond}{symbol}]" | ||
| selfies += "[{}{}]".format(bond, symbol) | ||
| prev_idx = counter[0] | ||
| counter[0] += 1 | ||
| selfies_len += 1 | ||
| prev_idx = counter[0] | ||
@@ -225,3 +237,3 @@ elif symbol_type == BRANCH_TYPE: | ||
| selfies += f"[Branch{len(N_as_symbols)}_{bond_num}]" | ||
| selfies += "[Branch{}_{}]".format(len(N_as_symbols), bond_num) | ||
| selfies += ''.join(N_as_symbols) + branch | ||
@@ -244,7 +256,9 @@ selfies_len += 1 + len(N_as_symbols) + branch_len | ||
| if left_bond != '': | ||
| selfies += f"[Expl{left_bond}Ring{len(N_as_symbols)}]" | ||
| selfies += "[Expl{}Ring{}]".format(left_bond, | ||
| len(N_as_symbols)) | ||
| elif right_bond != '': | ||
| selfies += f"[Expl{right_bond}Ring{len(N_as_symbols)}]" | ||
| selfies += "[Expl{}Ring{}]".format(right_bond, | ||
| len(N_as_symbols)) | ||
| else: | ||
| selfies += f"[Ring{len(N_as_symbols)}]" | ||
| selfies += "[Ring{}]".format(len(N_as_symbols)) | ||
@@ -255,4 +269,4 @@ selfies += ''.join(N_as_symbols) | ||
| else: | ||
| rings[ring_id] = (bond, counter[0]) | ||
| rings[ring_id] = (bond, prev_idx) | ||
| return selfies, selfies_len |
+13
-12
@@ -39,5 +39,5 @@ from itertools import product | ||
| if a in organic_subset: | ||
| symbol = f"[{b}{a}]" | ||
| symbol = "[{}{}]".format(b, a) | ||
| else: | ||
| symbol = f"[{b}{a}expl]" | ||
| symbol = "[{}{}expl]".format(b, a) | ||
@@ -48,7 +48,7 @@ alphabet_subset.add(symbol) | ||
| for i in range(1, 4): | ||
| alphabet_subset.add(f"[Ring{i}]") | ||
| alphabet_subset.add(f"[Expl=Ring{i}]") | ||
| alphabet_subset.add("[Ring{}]".format(i)) | ||
| alphabet_subset.add("[Expl=Ring{}]".format(i)) | ||
| for j in range(1, 4): | ||
| alphabet_subset.add(f"[Branch{i}_{j}]") | ||
| alphabet_subset.add("[Branch{}_{}]".format(i, j)) | ||
@@ -115,7 +115,8 @@ return alphabet_subset | ||
| if '?' not in bond_constraints: | ||
| raise ValueError("'?' not a key in bond_constraints") | ||
| raise ValueError("bond_constraints missing '?' as a key.") | ||
| for key, value in bond_constraints.items(): | ||
| if not (1 <= value <= 8): | ||
| raise ValueError("Value in bond_constraints not in [1, 8]") | ||
| raise ValueError("bond_constraints['{}'] not between " | ||
| "1 and 8 inclusive.".format(key)) | ||
@@ -151,3 +152,3 @@ _bond_constraints = dict(bond_constraints) | ||
| if symbol[-5:] == 'expl]': # e.g. [C@@Hexpl] | ||
| smiles_symbol = f"[{symbol[1 + len(bond):-5]}]" | ||
| smiles_symbol = "[{}]".format(symbol[1 + len(bond):-5]) | ||
| else: | ||
@@ -162,3 +163,3 @@ smiles_symbol = symbol[1 + len(bond):-1] | ||
| else: | ||
| atom_or_ion = f"{element}{charge:+}" | ||
| atom_or_ion = "{}{:+}".format(element, charge) | ||
@@ -169,4 +170,4 @@ max_bonds = _bond_constraints.get(atom_or_ion, | ||
| if h_count >= max_bonds: | ||
| raise ValueError(f"Too many Hs in SELFIES Symbol '{symbol}'. " | ||
| f"Consider adjusting bond constraints.") | ||
| raise ValueError("too many Hs in symbol '{}'; consider " | ||
| "adjusting bond constraints".format(symbol)) | ||
| max_bonds -= h_count # hydrogens consume 1 bond | ||
@@ -210,3 +211,3 @@ | ||
| if not (1 <= branch_type <= 3): | ||
| raise ValueError(f"Unknown branch symbol: {branch_symbol}") | ||
| raise ValueError("unknown branch symbol '{}'".format(branch_symbol)) | ||
@@ -213,0 +214,0 @@ if 2 <= state <= 8: |
+8
-16
@@ -1,3 +0,1 @@ | ||
| from __future__ import annotations | ||
| from typing import Dict, Iterable, List, Set, Tuple, Union | ||
@@ -46,3 +44,3 @@ | ||
| def _build_molecular_graph(graph: MolecularGraph, | ||
| def _build_molecular_graph(graph, | ||
| smiles_symbols: List[List[Union[str, int]]], | ||
@@ -109,3 +107,3 @@ rings: Dict[int, Tuple[int, int]], | ||
| def _kekulize(mol_graph: MolecularGraph) -> None: | ||
| def _kekulize(mol_graph) -> None: | ||
| """Kekulizes the molecular graph. | ||
@@ -123,3 +121,3 @@ | ||
| if not success: | ||
| raise ValueError("Kekulization Failed.") | ||
| raise ValueError("kekulization algorithm failed") | ||
@@ -173,4 +171,4 @@ mol_graph.write_to_smiles_symbols() | ||
| if element not in _aromatic_valences: | ||
| raise ValueError(f"Kekulization Failed: aromatic symbol {atom_symbol} " | ||
| f"not recognized.") | ||
| raise ValueError("unrecognized aromatic symbol '{}'" | ||
| .format(atom_symbol)) | ||
| return True | ||
@@ -206,3 +204,4 @@ | ||
| if h_count > 1: | ||
| raise ValueError(f"Kekulization Failed: {atom_symbol} not supported.") | ||
| raise ValueError("unrecognized aromatic symbol '{}'" | ||
| .format(atom_symbol)) | ||
@@ -234,5 +233,2 @@ elif h_count == 1: # e.g. [nH] | ||
| """ | ||
| smiles_symbols: List[List[Union[str, int]]] | ||
| graph: Dict[int, List[Bond]] | ||
| aro_indices: Set[int] | ||
@@ -386,3 +382,3 @@ def __init__(self, smiles_symbols: List[List[Union[str, int]]]): | ||
| matched_nodes: Set[int], | ||
| matched_edges: Set[Bond]) -> bool: | ||
| matched_edges) -> bool: | ||
| """After calling ``prune_to_pi_subgraph``, this method assigns | ||
@@ -500,6 +496,2 @@ double bonds between pairs of nodes such that every node is | ||
| """ | ||
| idx_a: int | ||
| idx_b: int | ||
| bond_symbol: str | ||
| bond_idx: int | ||
@@ -506,0 +498,0 @@ def __init__(self, idx_a, idx_b, bond_symbol, bond_idx): |
+7
-2
@@ -10,3 +10,3 @@ #!/usr/bin/env python | ||
| name="selfies", | ||
| version="1.0.0", | ||
| version="1.0.1", | ||
| author="Mario Krenn", | ||
@@ -23,6 +23,11 @@ author_email="mario.krenn@utoronto.ca, alan@aspuru.com", | ||
| "Programming Language :: Python :: 3", | ||
| "Programming Language :: Python :: 3.5", | ||
| "Programming Language :: Python :: 3.6", | ||
| "Programming Language :: Python :: 3.7", | ||
| "Programming Language :: Python :: 3.8", | ||
| "Programming Language :: Python :: 3 :: Only", | ||
| "License :: OSI Approved :: Apache Software License", | ||
| "Operating System :: OS Independent", | ||
| ], | ||
| python_requires='>=3.7' | ||
| python_requires='>=3.5' | ||
| ) |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
81887
7.1%1213
0.83%