{ "info": { "author": "Andrew Nisbet", "author_email": "", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: CPython" ], "description": "# paired\n\nPaired is a Python package for pairwise alignment of arbitrary sequences. \n\nPython has lots of great packages for sequence alignment and warping, but mostly for biological or numerical data. Paired performs global alignment on lists of arbitrary Python objects, and lets you define how element pairs are matched and scored.\n\n\n## Basic usage\n\n```python\nimport paired\n\nseq_1 = 'The quick brown fox jumped over the lazy dog'.split(' ')\nseq_2 = 'The brown fox leaped over the lazy dog'.split(' ')\nalignment = paired.align(seq_1, seq_2)\n\nprint(alignment)\n# [(0, 0), (1, None), (2, 1), (3, 2), (4, 3), (5, 4), (6, 5), (7, 6), (8, 7)]\n\nfor i_1, i_2 in alignment:\n print((seq_1[i_1] if i_1 is not None else '').ljust(15), end='')\n print(seq_2[i_2] if i_2 is not None else '')\n\n# The The\n# quick \n# brown brown\n# fox fox\n# jumped leaped\n# over over\n# the the\n# lazy lazy\n# dog dog\n```\n\n\n\n## Custom scores\n\nPaired uses the [Needleman-Wunsch algorithm](https://en.wikipedia.org/wiki/Needleman%E2%80%93Wunsch_algorithm). The scoring for the different operations (match, mismatch, gap) can be specified:\n\n```python\nalignment = paired.align(seq_1, seq_2, match_score=5, mismatch_score=-1, gap_score=-5)\n```\n\n\n## Custom similarity\n\nBy default, two elements are said to match if `element_1 == element_2`. Paired also allows you to pass a function to return a match/mismatch score for a given pair of elements. For example, you could give different scores to case-sensitive and case-insensitive matches of strings:\n\n\n```python\n\ndef scorer(a, b):\n if a == b:\n return 2\n elif a.lower() == b.lower():\n return 1\n else:\n return -1\n\nalignment = paired.align(seq_1, seq_2, scorer=scorer, gap_score=-3)\n```\n\n\n\n\n## Installation\n\nPaired is on [PyPi](https://pypi.org/project/paired/) and can be installed with pip. It has no dependencies.\n\n```shell\npip install paired\n```\n\n\n## API\n\n`pairwise.align(x, y, match_score=1, mismatch_score=-1, gap_score=-1, scorer=None)`\n\nGet the global alignment of two sequences.\n\nArguments:\n\n* **x**, **y** (*list*): Sequences of objects to align.\n* **match_score** (*numeric*): Score when matching elements are paired.\n* **mismatch_score** (*numeric*): Score when mismatching elements are paired.\n* **gap_score** (*numeric*): Score for an insertion/deletion, when an element is paired with no other element.\n* **scorer** (*callable*): Function that takes two elements as inputs, and returns a numerical score based on how well they match. If `None` is passed, the default function used is equivalent to `lamdba a, b: match_score if a==b else mismatch_score`.\n\nReturns: \n\n* **alignment** (*list of tuples*): The aligned sequence, as a list of pairs of indices into `x` and `y` respectively. A gap is represented by `None` instead of an integer index.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ajnisbet/paired", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "paired", "package_url": "https://pypi.org/project/paired/", "platform": "", "project_url": "https://pypi.org/project/paired/", "project_urls": { "Documentation": "https://github.com/ajnisbet/paired", "Homepage": "https://github.com/ajnisbet/paired", "Source": "https://github.com/ajnisbet/paired" }, "release_url": "https://pypi.org/project/paired/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "Sequence alignment of Python objects.", "version": "0.0.1" }, "last_serial": 3728070, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "9efd7eb4288541a4c7b31c4e6754d6e0", "sha256": "8f1a82813eed4ac17f769fc80d9d4563e6c2696759254a64fd2fc8f2a58cfee8" }, "downloads": -1, "filename": "paired-0.0.1.tar.gz", "has_sig": false, "md5_digest": "9efd7eb4288541a4c7b31c4e6754d6e0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4662, "upload_time": "2018-04-03T00:18:49", "url": "https://files.pythonhosted.org/packages/89/9a/1d4059c96a2fe27e3e15da883b03a88dd4d708d10bdaf42eeeb9a6cdcc56/paired-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9efd7eb4288541a4c7b31c4e6754d6e0", "sha256": "8f1a82813eed4ac17f769fc80d9d4563e6c2696759254a64fd2fc8f2a58cfee8" }, "downloads": -1, "filename": "paired-0.0.1.tar.gz", "has_sig": false, "md5_digest": "9efd7eb4288541a4c7b31c4e6754d6e0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4662, "upload_time": "2018-04-03T00:18:49", "url": "https://files.pythonhosted.org/packages/89/9a/1d4059c96a2fe27e3e15da883b03a88dd4d708d10bdaf42eeeb9a6cdcc56/paired-0.0.1.tar.gz" } ] }