smizip


Namesmizip JSON
Version 1.0.1 PyPI version JSON
download
home_page
SummaryAn implementation of Roger Sayle's SmiZip algorithm for compressing short strings
upload_time2023-09-21 16:54:19
maintainer
docs_urlNone
author
requires_python
licenseMIT License Copyright (c) 2023 SoseiHeptares Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords chemistry cheminformatics smiles compression zip
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            SmiZip
======

SmiZip is a compression method for short strings. It was developed by
Roger Sayle in 1998 while at Metaphorics LLC to compress SMILES strings.

This repo is an implementation in Python by Noel O'Boyle of the SmiZip algorithm as
described by Roger in a Mug01 presentation in 2001:
https://www.daylight.com/meetings/mug01/Sayle/SmiZip/index.htm

Quick start
-----------

Install as follows::

   pip install smizip

Let's compress and decompress a .smi file that contains canonical SMILES from RDKit
using n-grams trained for this purpose listed in ``rdkit.slow.json`` (available from
the GitHub site)::

  smizip    -i test.smi  -o test.smiz  -n example-ngrams/rdkit.slow.json
  smizip -d -i test.smiz -o test.2.smi -n example-ngrams/rdkit.slow.json

To create your own JSON file of n-grams, you can train on a dataset (``find_best_ngrams``),
or modify an existing JSON (``add_char_to_json``).

To use from Python::

  import json
  from smizip import SmiZip

  json_file = "rdkit.slow.json"
  with open(json_file) as inp:
     ngrams = json.load(inp)

  zipper = SmiZip(ngrams)
  zipped = zipper.zip("c1ccccc1C(=O)Cl") # gives bytes
  unzipped = zipper.unzip(zipped)

Note
----

You should include ``\n`` (carraige-return) as a single-character n-gram if you intend to store the zipped representation in a file with lines terminated by ``\n``. Otherwise, the byte value of ``\n`` will be assigned to a multi-gram, and zipped SMILES will be generated containing ``\n``.

A similar warning goes for any SMILES termination character in a file. If you expect to store zipped SMILES that terminate in a TAB or SPACE character, you should add these characters as single-character n-grams. Otherwise the zipped representation may contain these and you won't know which TABs are terminations and which are part of the representation.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "smizip",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "chemistry,cheminformatics,SMILES,compression,zip",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/f9/00/8998e0b581a7668db506d997396c69f97951c9a26655d543a4525d418b28/smizip-1.0.1.tar.gz",
    "platform": null,
    "description": "SmiZip\n======\n\nSmiZip is a compression method for short strings. It was developed by\nRoger Sayle in 1998 while at Metaphorics LLC to compress SMILES strings.\n\nThis repo is an implementation in Python by Noel O'Boyle of the SmiZip algorithm as\ndescribed by Roger in a Mug01 presentation in 2001:\nhttps://www.daylight.com/meetings/mug01/Sayle/SmiZip/index.htm\n\nQuick start\n-----------\n\nInstall as follows::\n\n   pip install smizip\n\nLet's compress and decompress a .smi file that contains canonical SMILES from RDKit\nusing n-grams trained for this purpose listed in ``rdkit.slow.json`` (available from\nthe GitHub site)::\n\n  smizip    -i test.smi  -o test.smiz  -n example-ngrams/rdkit.slow.json\n  smizip -d -i test.smiz -o test.2.smi -n example-ngrams/rdkit.slow.json\n\nTo create your own JSON file of n-grams, you can train on a dataset (``find_best_ngrams``),\nor modify an existing JSON (``add_char_to_json``).\n\nTo use from Python::\n\n  import json\n  from smizip import SmiZip\n\n  json_file = \"rdkit.slow.json\"\n  with open(json_file) as inp:\n     ngrams = json.load(inp)\n\n  zipper = SmiZip(ngrams)\n  zipped = zipper.zip(\"c1ccccc1C(=O)Cl\") # gives bytes\n  unzipped = zipper.unzip(zipped)\n\nNote\n----\n\nYou should include ``\\n`` (carraige-return) as a single-character n-gram if you intend to store the zipped representation in a file with lines terminated by ``\\n``. Otherwise, the byte value of ``\\n`` will be assigned to a multi-gram, and zipped SMILES will be generated containing ``\\n``.\n\nA similar warning goes for any SMILES termination character in a file. If you expect to store zipped SMILES that terminate in a TAB or SPACE character, you should add these characters as single-character n-grams. Otherwise the zipped representation may contain these and you won't know which TABs are terminations and which are part of the representation.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 SoseiHeptares  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "An implementation of Roger Sayle's SmiZip algorithm for compressing short strings",
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://github.com/SoseiHeptares/smizip"
    },
    "split_keywords": [
        "chemistry",
        "cheminformatics",
        "smiles",
        "compression",
        "zip"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3f406b137f43a245ac3a469d7b682332a7f126c6bb0ce1bfb91962d9e2230e4b",
                "md5": "709f3a4ca3974d282a589de7cb55df06",
                "sha256": "310119fc94792c6d54840815faa36c896ff2418a66512fb9421c4a47f459c854"
            },
            "downloads": -1,
            "filename": "smizip-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "709f3a4ca3974d282a589de7cb55df06",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 10949,
            "upload_time": "2023-09-21T16:54:18",
            "upload_time_iso_8601": "2023-09-21T16:54:18.068167Z",
            "url": "https://files.pythonhosted.org/packages/3f/40/6b137f43a245ac3a469d7b682332a7f126c6bb0ce1bfb91962d9e2230e4b/smizip-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f9008998e0b581a7668db506d997396c69f97951c9a26655d543a4525d418b28",
                "md5": "8f30218e3ec75ce45f68a4b76f1e1abe",
                "sha256": "9398c6ee6e73185458389a57daa6418c020fe1188cfbcef9c529ce465bd10866"
            },
            "downloads": -1,
            "filename": "smizip-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "8f30218e3ec75ce45f68a4b76f1e1abe",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9810,
            "upload_time": "2023-09-21T16:54:19",
            "upload_time_iso_8601": "2023-09-21T16:54:19.832043Z",
            "url": "https://files.pythonhosted.org/packages/f9/00/8998e0b581a7668db506d997396c69f97951c9a26655d543a4525d418b28/smizip-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-21 16:54:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SoseiHeptares",
    "github_project": "smizip",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "smizip"
}
        
Elapsed time: 0.24674s