{"id":21466712,"url":"https://github.com/edinburgh-genome-foundry/bandwagon","last_synced_at":"2025-07-15T05:30:58.579Z","repository":{"id":57413890,"uuid":"81102389","full_name":"Edinburgh-Genome-Foundry/BandWagon","owner":"Edinburgh-Genome-Foundry","description":"🎺 Plot DNA digestion band patterns with Python","archived":false,"fork":false,"pushed_at":"2022-05-07T19:41:38.000Z","size":1965,"stargazers_count":19,"open_issues_count":1,"forks_count":3,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-08T16:17:40.988Z","etag":null,"topics":["agarose-gel","dna","molecular-biology","plotting","synthetic-biology"],"latest_commit_sha":null,"homepage":"http://edinburgh-genome-foundry.github.io/BandWagon/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Edinburgh-Genome-Foundry.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-06T15:38:40.000Z","updated_at":"2024-02-17T18:12:31.000Z","dependencies_parsed_at":"2022-09-12T15:10:24.349Z","dependency_job_id":null,"html_url":"https://github.com/Edinburgh-Genome-Foundry/BandWagon","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edinburgh-Genome-Foundry%2FBandWagon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edinburgh-Genome-Foundry%2FBandWagon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edinburgh-Genome-Foundry%2FBandWagon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edinburgh-Genome-Foundry%2FBandWagon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Edinburgh-Genome-Foundry","download_url":"https://codeload.github.com/Edinburgh-Genome-Foundry/BandWagon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226017166,"owners_count":17560466,"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":["agarose-gel","dna","molecular-biology","plotting","synthetic-biology"],"created_at":"2024-11-23T08:15:01.330Z","updated_at":"2025-07-15T05:30:58.562Z","avatar_url":"https://github.com/Edinburgh-Genome-Foundry.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":".. raw:: html\n\n    \u003cp align=\"center\"\u003e\n    \u003cimg alt=\"BandWagon Logo\" title=\"BandWagon Logo\" src=\"https://raw.githubusercontent.com/Edinburgh-Genome-Foundry/BandWagon/master/docs/_static/images/title.png\" width=\"500\"\u003e\n    \u003cbr /\u003e\u003cbr /\u003e\n    \u003c/p\u003e\n\n.. image:: https://github.com/Edinburgh-Genome-Foundry/BandWagon/actions/workflows/build.yml/badge.svg\n    :target: https://github.com/Edinburgh-Genome-Foundry/BandWagon/actions/workflows/build.yml\n    :alt: GitHub CI build status\n\n.. image:: https://coveralls.io/repos/github/Edinburgh-Genome-Foundry/BandWagon/badge.svg?branch=master\n   :target: https://coveralls.io/github/Edinburgh-Genome-Foundry/BandWagon?branch=master\n\n\nBandWagon (full documentation `here\n\u003chttp://edinburgh-genome-foundry.github.io/BandWagon/\u003e`_) is a Python library to predict and plot migration patterns\nfrom DNA digestions. It supports hundreds of different enzymes (thanks to BioPython),\nsingle- and multiple-enzyme digestions, and custom ladders.\n\nIt uses Matplotlib to produce plots like this one:\n\n.. figure:: https://raw.githubusercontent.com/Edinburgh-Genome-Foundry/BandWagon/master/examples/mixed_digestions.png\n    :align: center\n\nBandWagon\n=========\n\nLicense = MIT\n-------------\n\nBandWagon is an open-source software originally written at the `Edinburgh Genome Foundry\n\u003chttp://edinburgh-genome-foundry.github.io/home.html\u003e`_ by `Zulko \u003chttps://github.com/Zulko\u003e`_\nand `released on Github \u003chttps://github.com/Edinburgh-Genome-Foundry/BandWagon\u003e`_ under\nthe MIT license (Copyright 2019 Edinburgh Genome Foundry, University of Edinburgh).\n\nEveryone is welcome to contribute!\n\nInstallation\n------------\n\nBandWagon can be installed with pip:\n\n.. code:: shell\n\n    pip install bandwagon\n\nTo create interactive Bokeh plots, install additional packages with:\n\n.. code:: shell\n\n    pip install bandwagon[bokeh]\n\n\nExamples of use\n---------------\n\n\nComputing digestion band sizes\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThis first example shows how to compute digestion bands in the case of\na linear fragment, a circular fragment, and a multi-enzymes digestion:\n\n..  code:: python\n\n    from bandwagon import compute_digestion_bands\n\n    # Read the sequence (a string of the form 'ATGTGTGGTA...' etc.)\n    with open(\"example_sequence.txt\", \"r\") as f:\n        sequence = f.read()\n\n    # Compute digestion bands for a linear construct\n    print(compute_digestion_bands(sequence, [\"EcoRI\"], linear=True))\n    # Result \u003e\u003e\u003e [400, 1017, 3583]\n\n    # Compute digestion bands for a circular construct\n    print(compute_digestion_bands(sequence, [\"EcoRI\"], linear=False))\n    # Result \u003e\u003e\u003e [1017, 3983]\n\n    # Compute digestion bands for an enzymatic mix\n    print(compute_digestion_bands(sequence, [\"EcoRI\", \"BamHI\"]))\n    # Result \u003e\u003e\u003e [400, 417, 600, 3583]\n\nPlotting bands\n~~~~~~~~~~~~~~\n\n..  code:: python\n\n    from bandwagon import BandsPattern, BandsPatternsSet, LADDER_100_to_4k\n\n    ladder = LADDER_100_to_4k.modified(label=\"Ladder\", background_color=\"#ffffaf\")\n\n    patterns = [\n        BandsPattern([100, 500, 3500], ladder, label=\"C1\"),\n        BandsPattern([300, 400, 1500], ladder, label=\"C2\"),\n        BandsPattern([100, 1200, 1400, 3000], ladder, label=\"C3\"),\n        BandsPattern([100, 700], ladder, label=\"C4\"),\n    ]\n    patterns_set = BandsPatternsSet(patterns=[ladder] + patterns, ladder=ladder,\n                                    label=\"Test pattern\", ladder_ticks=3)\n    ax = patterns_set.plot()\n    ax.figure.savefig(\"simple_band_patterns.png\", bbox_inches=\"tight\", dpi=200)\n\n.. figure:: https://raw.githubusercontent.com/Edinburgh-Genome-Foundry/BandWagon/master/examples/simple_band_patterns.png\n    :align: center\n\nPlotting a gel simulation\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\nLet us plot digestion patterns produced by different restriction enzymes on the same DNA sequence:\n\n\n.. code:: python\n\n    from bandwagon import (BandsPattern, BandsPatternsSet, LADDER_100_to_4k,\n                           compute_digestion_bands)\n\n    with open(\"example_sequence.txt\", \"r\") as f:\n        sequence = f.read()\n\n    patterns = [\n        BandsPattern(compute_digestion_bands(sequence, [enzyme], linear=True),\n                     ladder=LADDER_100_to_4k, label=enzyme)\n        for enzyme in [\"BamHI\", \"EcoRI\", \"EcoRV\", \"PstI\", \"SpeI\", \"XbaI\"]\n    ]\n    patterns_set = BandsPatternsSet(patterns=[LADDER_100_to_4k] + patterns,\n                                    ladder=LADDER_100_to_4k,\n                                    label=\"Digestion results\", ladder_ticks=3)\n\n    ax = patterns_set.plot()\n    ax.figure.savefig(\"digestion_results.png\", bbox_inches=\"tight\", dpi=200)\n\n.. figure:: https://raw.githubusercontent.com/Edinburgh-Genome-Foundry/BandWagon/master/examples/simple_digestions.png\n    :align: center\n\nIf you have many sequences and digestions you can also use the utility ``plot_records_digestions``\n\n.. code:: python\n\n    from bandwagon import plot_all_digestion_patterns, LADDER_100_to_4k\n\n    axes = plot_all_digestion_patterns(\n        records=records,\n        digestions=[('BamHI', 'NcoI'), ('BsaI', 'XbaI'), ('StyI',)],\n        ladder=LADDER_100_to_4k\n    )\n    axes[0].figure.savefig(\"plot_all_digestion_patterns.png\")\n\n.. figure:: https://raw.githubusercontent.com/Edinburgh-Genome-Foundry/BandWagon/master/examples/plot_all_digestion_patterns.png\n    :align: center\n\nPlotting patterns alongside annotated records\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nYou can also get a full report with indications of where in your sequences the\nbands are formed (which is useful for troubleshooting) as follows:\n\n.. code:: python\n\n    from bandwagon import plot_records_digestions, LADDER_100_to_4k\n\n    plot_records_digestions(\n        records=records,\n        digestions=[('BamHI', 'NcoI'), ('BsaI', 'XbaI'), ('StyI',)],\n        ladder=LADDER_100_to_4k,\n        target=\"records_digestions.pdf\")\n\nYou get a `PDF report \u003chttps://raw.githubusercontent.com/Edinburgh-Genome-Foundry/BandWagon/master/examples/plot_records_digestions_example.pdf\u003e`_\nwith one page per construct and digestion, looking like this:\n\n.. figure:: https://raw.githubusercontent.com/Edinburgh-Genome-Foundry/BandWagon/master/examples/plot_records_digestions_example.png\n    :align: center\n\nUsing a custom ladder\n~~~~~~~~~~~~~~~~~~~~~\n\nYou can define a custom ladder by providing a dictionary of the form\n\n.. code:: python\n\n    { actual_size_of_the_fragment: observed_migration_distance }\n\nFor instance here is how the  100b-4kb ladder (provided with BandWagon) is defined:\n\n.. code:: python\n\n    from bandwagon import custom_ladder\n\n    LADDER_100_to_4k = custom_ladder(\"100-4k\", {\n        100: 205,\n        200: 186,\n        300: 171,\n        400: 158,\n        500: 149,\n        650: 139,\n        850: 128,\n        1000: 121,\n        1650: 100,\n        2000: 90,\n        3000: 73,\n        4000: 65\n    })\n\nThe unit of the \"migration distance\" from the starting point is not very important,\nit could be millimeters on a gel, pixels in an image, etc.\n\nIf you are lucky enough to have an AATI automated fragment analyzer like us at the\nFoundry, it will output a ``.csv`` calibration file after each run, from which you\ncan generate a ladder with:\n\n..  code:: python\n\n    from bandwagon import ladder_from_aati_fa_calibration_table\n\n    ladder = ladder_from_aati_fa_calibration_table(\"Calibration.csv\",\n                                                   label=\"todays_ladder\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedinburgh-genome-foundry%2Fbandwagon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedinburgh-genome-foundry%2Fbandwagon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedinburgh-genome-foundry%2Fbandwagon/lists"}