{"id":20174037,"url":"https://github.com/joergen7/lib_dp","last_synced_at":"2025-04-10T03:35:21.233Z","repository":{"id":57516070,"uuid":"73189012","full_name":"joergen7/lib_dp","owner":"joergen7","description":"Dynamic Programming in Erlang.","archived":false,"fork":false,"pushed_at":"2017-08-10T12:19:18.000Z","size":19,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-03-14T20:04:56.027Z","etag":null,"topics":["alignment","erlang","needleman-wunsch","similarity-score","smith-waterman"],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joergen7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-08T13:34:38.000Z","updated_at":"2019-04-04T23:57:51.000Z","dependencies_parsed_at":"2022-08-28T16:50:32.451Z","dependency_job_id":null,"html_url":"https://github.com/joergen7/lib_dp","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joergen7%2Flib_dp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joergen7%2Flib_dp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joergen7%2Flib_dp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joergen7%2Flib_dp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joergen7","download_url":"https://codeload.github.com/joergen7/lib_dp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248153060,"owners_count":21056353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alignment","erlang","needleman-wunsch","similarity-score","smith-waterman"],"created_at":"2024-11-14T01:41:11.569Z","updated_at":"2025-04-10T03:35:21.200Z","avatar_url":"https://github.com/joergen7.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lib_dp\n###### Dynamic Programming in Erlang.\n\n[![hex.pm](https://img.shields.io/hexpm/v/lib_dp.svg?style=flat-square)](https://hex.pm/packages/lib_dp) [![Build Status](https://travis-ci.org/joergen7/lib_dp.svg?branch=master)](https://travis-ci.org/joergen7/lib_dp)\n\nThis library allows the inexact matching of a pair of sequences via Dynamic\nProgramming. The library supports three different matching schemes:\n\n- global alignment (Needleman-Wunsch)\n- global end-space free alignment\n- local alignment (Smith-Waterman)\n\nFurthermore, it is possible to provide custom substitution matrices and to set\nthe score of insertions and deletions. After alignment the similarity score of\nboth sequences can be queried and different kinds of edit scripts can be\nproduced.\n\nThe algorithm has O(n^2) complexity regarding the length of the input sequences\nin both processing time as well as memory consumption.\n\n## Compiling from Source\n\nThe following packages should be installed on your machine:\n\n- [git](https://git-scm.com)\n- [erlang](http://www.erlang.org/) (OTP 18.0 or higher)\n- [rebar3](https://github.com/erlang/rebar3)\n\nDownload the git repository and change into the repository's directory:\n\n    git clone https://github.com/joergen7/lib_dp.git\n    cd lib_dp\n\nNow, compile the library with rebar3\n\n    rebar3 compile\n\nIn addition, you can run unit tests or check the library for discrepancies with\nthe following two commands:\n\n    rebar3 eunit\n    rebar3 dialyzer\n\nYou can build the documentation by entering:\n\n    rebar3 edoc\n\nAfter compilation you can start a shell with the `lib_dp` library available by\nentering:\n\n    rebar3 shell\n\n## Example\n\nStart an Erlang shell by entering:\n\n    rebar3 shell\n\n`lib_dp` allows the matching of lists of any given elements. Since Erlang\nstrings are internally represented as lists of integers, it is straightforward\nto match them. Note, however, that the lists must be flat in order for the\nmatching to be successful.\n\nFor this example, we will, however, consider lists of atoms. Let us define two\nsimilar sequences (lists of atoms):\n\n    A = [v, i, n, t, n, e, r].\n    B = [w, i, n, t, e, r, s].\n\nFirst, we initialize a stateful module which holds general parameters about the\nway, we want to perform alignments. Here, we will perform a global alignment\n(Needleman-Wunsch). Thus we initialize the stateful module by entering:\n\n    Dp = lib_dp:new( global ).\n\nNow, we compile the Dynamic Programming score table from the two strings `A`\nand `B`:\n\n    Tbl = Dp:scoretbl( A, B ).\n\nIf the score table is small (in this example it is) we can output it on the\nconsole and inspect it:\n\n    lib_dp:print_tbl( Tbl ).\n\nThe table will look something like this:\n\n    \\ -1 - -2 - -3 - -4 - -5 - -6 - -7 \n    | -2 \\  0 - -1 - -2 - -3 - -4 - -5 \n    | -3 | -1 \\  1 -  0 - -1 - -2 - -3 \n    | -4 | -2 |  0 \\  2 -  1 -  0 - -1 \n    | -5 | -3 | -1 |  1 \\  1 -  0 - -1 \n    | -6 | -4 | -2 |  0 \\  2 -  1 -  0 \n    | -7 | -5 | -3 | -1 |  1 \\  3 -  2 \n\nIt displays the score associated with each position pair as well as the\nback-links that memorize from which direction the score was generated. Higher\nscores mean higher similarity.\n\nFor global alignments, the similarity score of both sequences is the value in\nthe lower right corner of the score table, here: 2. We can extract the\nsimilarity score from a score table by applying the function `get_score`:\n\n    Dp:get_score( Tbl ).\n\nNote that the score will change depending on the alignment strategy.\n\nWe can now cunstruct an edit script from the programming table by entering:\n\n    EditScr = Dp:editscr( A, B, Tbl ).\n\nThe edit script is a list of pairs in which the first element represents a\nsymbol from sequence `A` and the second represents a symbol from sequence `B`.\nThe edit script for this example is the following:\n\n    [{v,w},{i,i},{n,n},{t,t},{n,indel},{e,e},{r,r},{indel,s}]\n\nEventually, we can simplify the edit script to a summary script, which is just\nanother way to represent an edit script in memory:\n\n    lib_dp:sumscr( EditScr ).\n\nThe resulting summary script looks like this:\n\n    [{mismatch,[v],[w]},\n     {match,[i,n,t]},\n     {ins,[n]},\n     {match,[e,r]},\n     {del,[s]}]\n\n## System Requirements\n\n- Erlang OTP 18.0 or higher\n- Rebar3 3.0.0 or higher\n\n## Authors\n\n- Jörgen Brandt (joergen7) [joergen.brandt@onlinehome.de](mailto:joergen.brandt@onlinehome.de)\n\n## License\n\n[Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0.html)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoergen7%2Flib_dp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoergen7%2Flib_dp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoergen7%2Flib_dp/lists"}