suffix-tree


Namesuffix-tree JSON
Version 0.1.2 PyPI version JSON
download
home_page
SummaryA Generalized Suffix Tree for any iterable, with Lowest Common Ancestor retrieval
upload_time2023-10-09 13:59:50
maintainer
docs_urlNone
author
requires_python>=3.9
license
keywords gusfield lca suffix suffixtree tree ukkonen
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ===========================
 A Generalized Suffix Tree
===========================

.. |py39| image:: docs/_images/badge-py39.svg

.. |py310| image:: docs/_images/badge-py310.svg

.. |py311| image:: docs/_images/badge-py311.svg

.. |py312| image:: docs/_images/badge-py312.svg

.. |pypy39| image:: docs/_images/badge-pypy39.svg

.. |coverage| image:: docs/_images/badge-coverage.svg

|py39| |py310| |py311| |py312| |pypy39| |coverage|

A Generalized Suffix Tree for any Python sequence, with Lowest Common Ancestor
retrieval.

.. code-block:: shell

   pip install suffix-tree

.. code-block:: python

   >>> from suffix_tree import Tree

   >>> tree = Tree({"A": "xabxac"})
   >>> tree.find("abx")
   True
   >>> tree.find("abc")
   False


This suffix tree:

- works with any Python sequence, not just strings, if the items are hashable,
- is a generalized suffix tree for sets of sequences,
- is implemented in pure Python,
- builds the tree in time proportional to the length of the input,
- does constant-time Lowest Common Ancestor retrieval.

Being implemented in Python this tree is not very fast nor memory efficient.  The
building of the tree takes time proportional to the length of the string of symbols.
The query time is proportional to the length of the query string.

To get the best performance turn the python optimizer on: python -O.

Documentation: https://cceh.github.io/suffix-tree/

PyPi: https://pypi.org/project/suffix-tree/


Usage examples:
===============

.. code-block:: python

   >>> from suffix_tree import Tree
   >>> tree = Tree()
   >>> tree.add(1, "xabxac")
   >>> tree.add(2, "awyawxawxz")
   >>> tree.find("abx")
   True
   >>> tree.find("awx")
   True
   >>> tree.find("abc")
   False

.. code-block:: python

   >>> tree = Tree({"A": "xabxac", "B": "awyawxawxz"})
   >>> tree.find_id("A", "abx")
   True
   >>> tree.find_id("B", "abx")
   False
   >>> tree.find_id("B", "awx")
   True

.. code-block:: python

   >>> tree = Tree(
   ...     {
   ...         "A": "sandollar",
   ...         "B": "sandlot",
   ...         "C": "handler",
   ...         "D": "grand",
   ...         "E": "pantry",
   ...     }
   ... )
   >>> for k, length, path in tree.common_substrings():
   ...     print(k, length, path)
   ...
   2 4 s a n d
   3 3 a n d
   4 3 a n d
   5 2 a n

.. code-block:: python

   >>> tree = Tree({"A": "xabxac", "B": "awyawxawxz"})
   >>> for C, path in sorted(tree.maximal_repeats()):
   ...     print(C, path)
   ...
   1 a w
   1 a w x
   2 a
   2 x
   2 x a

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "suffix-tree",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "gusfield,lca,suffix,suffixtree,tree,ukkonen",
    "author": "",
    "author_email": "Marcello Perathoner <marcello@perathoner.de>",
    "download_url": "https://files.pythonhosted.org/packages/32/eb/932d92d37e56629d1a9fb5126cd07d3bdc5166a6ea654fb06d4e83961c93/suffix_tree-0.1.2.tar.gz",
    "platform": null,
    "description": "===========================\n A Generalized Suffix Tree\n===========================\n\n.. |py39| image:: docs/_images/badge-py39.svg\n\n.. |py310| image:: docs/_images/badge-py310.svg\n\n.. |py311| image:: docs/_images/badge-py311.svg\n\n.. |py312| image:: docs/_images/badge-py312.svg\n\n.. |pypy39| image:: docs/_images/badge-pypy39.svg\n\n.. |coverage| image:: docs/_images/badge-coverage.svg\n\n|py39| |py310| |py311| |py312| |pypy39| |coverage|\n\nA Generalized Suffix Tree for any Python sequence, with Lowest Common Ancestor\nretrieval.\n\n.. code-block:: shell\n\n   pip install suffix-tree\n\n.. code-block:: python\n\n   >>> from suffix_tree import Tree\n\n   >>> tree = Tree({\"A\": \"xabxac\"})\n   >>> tree.find(\"abx\")\n   True\n   >>> tree.find(\"abc\")\n   False\n\n\nThis suffix tree:\n\n- works with any Python sequence, not just strings, if the items are hashable,\n- is a generalized suffix tree for sets of sequences,\n- is implemented in pure Python,\n- builds the tree in time proportional to the length of the input,\n- does constant-time Lowest Common Ancestor retrieval.\n\nBeing implemented in Python this tree is not very fast nor memory efficient.  The\nbuilding of the tree takes time proportional to the length of the string of symbols.\nThe query time is proportional to the length of the query string.\n\nTo get the best performance turn the python optimizer on: python -O.\n\nDocumentation: https://cceh.github.io/suffix-tree/\n\nPyPi: https://pypi.org/project/suffix-tree/\n\n\nUsage examples:\n===============\n\n.. code-block:: python\n\n   >>> from suffix_tree import Tree\n   >>> tree = Tree()\n   >>> tree.add(1, \"xabxac\")\n   >>> tree.add(2, \"awyawxawxz\")\n   >>> tree.find(\"abx\")\n   True\n   >>> tree.find(\"awx\")\n   True\n   >>> tree.find(\"abc\")\n   False\n\n.. code-block:: python\n\n   >>> tree = Tree({\"A\": \"xabxac\", \"B\": \"awyawxawxz\"})\n   >>> tree.find_id(\"A\", \"abx\")\n   True\n   >>> tree.find_id(\"B\", \"abx\")\n   False\n   >>> tree.find_id(\"B\", \"awx\")\n   True\n\n.. code-block:: python\n\n   >>> tree = Tree(\n   ...     {\n   ...         \"A\": \"sandollar\",\n   ...         \"B\": \"sandlot\",\n   ...         \"C\": \"handler\",\n   ...         \"D\": \"grand\",\n   ...         \"E\": \"pantry\",\n   ...     }\n   ... )\n   >>> for k, length, path in tree.common_substrings():\n   ...     print(k, length, path)\n   ...\n   2 4 s a n d\n   3 3 a n d\n   4 3 a n d\n   5 2 a n\n\n.. code-block:: python\n\n   >>> tree = Tree({\"A\": \"xabxac\", \"B\": \"awyawxawxz\"})\n   >>> for C, path in sorted(tree.maximal_repeats()):\n   ...     print(C, path)\n   ...\n   1 a w\n   1 a w x\n   2 a\n   2 x\n   2 x a\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A Generalized Suffix Tree for any iterable, with Lowest Common Ancestor retrieval",
    "version": "0.1.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/cceh/suffix-tree/issues",
        "Homepage": "https://github.com/cceh/suffix-tree"
    },
    "split_keywords": [
        "gusfield",
        "lca",
        "suffix",
        "suffixtree",
        "tree",
        "ukkonen"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a6b08f6adff523678f5cf23da20f6b3a00727c97287dca39746f2ffdb4ef1b06",
                "md5": "58ad92487b52e035b6e7b9f41089e940",
                "sha256": "c7f01f9bf16f88eed830d6be97b3448648c48ea763cf0092a1f29dccd2b13862"
            },
            "downloads": -1,
            "filename": "suffix_tree-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "58ad92487b52e035b6e7b9f41089e940",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 32561,
            "upload_time": "2023-10-09T13:59:48",
            "upload_time_iso_8601": "2023-10-09T13:59:48.519421Z",
            "url": "https://files.pythonhosted.org/packages/a6/b0/8f6adff523678f5cf23da20f6b3a00727c97287dca39746f2ffdb4ef1b06/suffix_tree-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "32eb932d92d37e56629d1a9fb5126cd07d3bdc5166a6ea654fb06d4e83961c93",
                "md5": "c2da967dc4610cf54ad7dcd4fcd6a7b3",
                "sha256": "e5a927d205956c0161ed4fc90959e55326f67bccea1291fa476b408f347d92ef"
            },
            "downloads": -1,
            "filename": "suffix_tree-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "c2da967dc4610cf54ad7dcd4fcd6a7b3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 686030,
            "upload_time": "2023-10-09T13:59:50",
            "upload_time_iso_8601": "2023-10-09T13:59:50.579697Z",
            "url": "https://files.pythonhosted.org/packages/32/eb/932d92d37e56629d1a9fb5126cd07d3bdc5166a6ea654fb06d4e83961c93/suffix_tree-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-09 13:59:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cceh",
    "github_project": "suffix-tree",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "suffix-tree"
}
        
Elapsed time: 2.46895s