From 27f996ebaffb27488a846ac36d6a40efc64f84f9 Mon Sep 17 00:00:00 2001 From: Don Kirkby Date: Tue, 18 Jul 2023 16:43:35 -0700 Subject: [PATCH] Fix Alignment and Plasmid to make examples work. Also bump version number. --- examples/Genetracks.ipynb | 373 ++++++++------------------------------ genetracks/elements.py | 2 +- genetracks/plasmid.py | 2 +- setup.py | 2 +- 4 files changed, 78 insertions(+), 301 deletions(-) diff --git a/examples/Genetracks.ipynb b/examples/Genetracks.ipynb index 2eb307d..8a4b2ca 100644 --- a/examples/Genetracks.ipynb +++ b/examples/Genetracks.ipynb @@ -9,8 +9,13 @@ }, { "cell_type": "code", - "execution_count": 3, - "metadata": {}, + "execution_count": 22, + "metadata": { + "ExecuteTime": { + "end_time": "2023-07-18T23:42:53.883255337Z", + "start_time": "2023-07-18T23:42:53.866093429Z" + } + }, "outputs": [], "source": [ "from genetracks import Figure, Track, Alignment, Multitrack, Label" @@ -18,42 +23,21 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 23, "metadata": { - "scrolled": false + "scrolled": false, + "ExecuteTime": { + "end_time": "2023-07-18T23:42:53.884400604Z", + "start_time": "2023-07-18T23:42:53.872393883Z" + } }, "outputs": [ { "data": { - "image/svg+xml": [ - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "Another sequence\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "Sequence 1\n", - "\n", - "\n", - "" - ], - "text/plain": [ - "" - ] + "text/plain": "", + "image/svg+xml": "\n\n\n\n\n\n\n\n\nAnother sequence\n\n\n\n\n\n\n\nSequence 1\n\n\n" }, - "execution_count": 4, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } @@ -79,75 +63,20 @@ }, { "cell_type": "code", - "execution_count": 5, - "metadata": {}, + "execution_count": 24, + "metadata": { + "ExecuteTime": { + "end_time": "2023-07-18T23:42:53.918296167Z", + "start_time": "2023-07-18T23:42:53.879691288Z" + } + }, "outputs": [ { "data": { - "image/svg+xml": [ - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "Read 1, forward\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "Read 1, reverse\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "Read 2, forward\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "Read 2, reverse\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "Read 3, forward\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "Read 3, reverse\n", - "\n", - "\n", - "\n", - "" - ], - "text/plain": [ - "" - ] + "text/plain": "", + "image/svg+xml": "\n\n\n\n\n\n\n\n\n\nRead 1, forward\n\n\n\n\n\n\nRead 1, reverse\n\n\n\n\n\n\n\n\n\nRead 2, forward\n\n\n\n\n\n\nRead 2, reverse\n\n\n\n\n\n\n\n\n\nRead 3, forward\n\n\n\n\n\n\nRead 3, reverse\n\n\n\n" }, - "execution_count": 5, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -173,56 +102,20 @@ }, { "cell_type": "code", - "execution_count": 8, - "metadata": {}, + "execution_count": 25, + "metadata": { + "ExecuteTime": { + "end_time": "2023-07-18T23:42:53.918891057Z", + "start_time": "2023-07-18T23:42:53.911621618Z" + } + }, "outputs": [ { "data": { - "image/svg+xml": [ - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "Forward read\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "Reverse read\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "Read-through\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "Reads overlap\n", - "\n", - "\n", - "" - ], - "text/plain": [ - "" - ] + "text/plain": "", + "image/svg+xml": "\n\n\n\n\n\n\n\n\n\nForward read\n\n\n\n\n\n\nReverse read\n\n\n\n\n\n\n\n\n\nRead-through\n\n\n\n\n\nReads overlap\n\n\n" }, - "execution_count": 8, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -249,47 +142,25 @@ "metadata": {}, "source": [ "### Alignment\n", - "Regions beetween two tracts can be illustrated with an `Alignment`." + "Regions between two tracts can be illustrated with an `Alignment`." ] }, { "cell_type": "code", - "execution_count": 9, - "metadata": {}, + "execution_count": 26, + "metadata": { + "ExecuteTime": { + "end_time": "2023-07-18T23:42:53.919044924Z", + "start_time": "2023-07-18T23:42:53.911750803Z" + } + }, "outputs": [ { "data": { - "image/svg+xml": [ - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "" - ], - "text/plain": [ - "" - ] + "text/plain": "", + "image/svg+xml": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" }, - "execution_count": 9, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } @@ -312,108 +183,20 @@ }, { "cell_type": "code", - "execution_count": 10, - "metadata": {}, + "execution_count": 27, + "metadata": { + "ExecuteTime": { + "end_time": "2023-07-18T23:42:53.919182746Z", + "start_time": "2023-07-18T23:42:53.911809826Z" + } + }, "outputs": [ { "data": { - "image/svg+xml": [ - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "5' LTR\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "gag\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "vif\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "tat\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "nef\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "tat\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "vpu\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "rev\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "3' LTR\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "pol\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "vpr\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "rev\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "env\n", - "\n", - "\n", - "\n", - "" - ], - "text/plain": [ - "" - ] + "text/plain": "", + "image/svg+xml": "\n\n\n\n\n\n\n\n5' LTR\n\n\n\n\n\ngag\n\n\n\n\n\nvif\n\n\n\n\n\ntat\n\n\n\n\n\nnef\n\n\n\n\n\n\n\ntat\n\n\n\n\n\nvpu\n\n\n\n\n\nrev\n\n\n\n\n\n3' LTR\n\n\n\n\n\n\n\npol\n\n\n\n\n\nvpr\n\n\n\n\n\nrev\n\n\n\n\n\nenv\n\n\n\n" }, - "execution_count": 10, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } @@ -461,32 +244,21 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 28, "metadata": { - "scrolled": false + "scrolled": false, + "ExecuteTime": { + "end_time": "2023-07-18T23:42:53.919313137Z", + "start_time": "2023-07-18T23:42:53.911926703Z" + } }, "outputs": [ { "data": { - "image/svg+xml": [ - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "" - ], - "text/plain": [ - "" - ] + "text/plain": "", + "image/svg+xml": "\n\n\n\n\n\n\n\n\n\n" }, - "execution_count": 11, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -504,15 +276,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, + "execution_count": 28, + "metadata": { + "ExecuteTime": { + "end_time": "2023-07-18T23:42:53.975218686Z", + "start_time": "2023-07-18T23:42:53.911985311Z" + } + }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -526,7 +303,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.6" + "version": "3.10.6" } }, "nbformat": 4, diff --git a/genetracks/elements.py b/genetracks/elements.py index c6d1c0b..83680fe 100644 --- a/genetracks/elements.py +++ b/genetracks/elements.py @@ -195,7 +195,7 @@ def __init__(self, track1, track2, connections, text=None, style=None, self.w = max(track1.w, track2.w) def draw(self, x=0, y=0, xscale=1.0): - d = draw.Group(transform="translate({} {})".format(x, y)) + d = draw.Group(transform="translate({} {})".format(x, y-self.gap)) d.append(self.t1.draw(xscale=xscale)) d.append(self.t2.draw(y=self.t1.h+self.gap, xscale=xscale)) diff --git a/genetracks/plasmid.py b/genetracks/plasmid.py index 8257b38..1fbe4d7 100644 --- a/genetracks/plasmid.py +++ b/genetracks/plasmid.py @@ -30,5 +30,5 @@ def __init__(self, a, b, color='lightgrey'): self.b = b def draw(self, circ): - return draw.Arc(0, 0, 0.5, self.a, self.b, stroke_width='0.04', + return draw.Arc(0, 0, 0.5, self.b/circ*360, self.a/circ*360, stroke_width='0.04', stroke=self.color, fill_opacity='0.0') diff --git a/setup.py b/setup.py index 27295cb..0498372 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="genetracks", - version="0.2.dev0", + version="0.2.dev1", author="jeff-k", author_email="jeff_k@fastmail.com", description="Generate track diagrams for genomic alignments",