From c8110260e90c3fb39f18693a1d1275a290bc5793 Mon Sep 17 00:00:00 2001 From: pinyili2 <pinyili2@illinois.edu> Date: Tue, 6 Aug 2024 14:37:48 -0500 Subject: [PATCH] add --- ...no.py.swp => .nfs0000000000093fec000043e9} | Bin mrdna/readers/segmentmodel_from_cadnano.py | 16 +- mrdna/readers/test.ipynb | 172 ++++++++++-------- 3 files changed, 112 insertions(+), 76 deletions(-) rename mrdna/readers/{.segmentmodel_from_cadnano.py.swp => .nfs0000000000093fec000043e9} (100%) diff --git a/mrdna/readers/.segmentmodel_from_cadnano.py.swp b/mrdna/readers/.nfs0000000000093fec000043e9 similarity index 100% rename from mrdna/readers/.segmentmodel_from_cadnano.py.swp rename to mrdna/readers/.nfs0000000000093fec000043e9 diff --git a/mrdna/readers/segmentmodel_from_cadnano.py b/mrdna/readers/segmentmodel_from_cadnano.py index 676ff60..fe6b46c 100644 --- a/mrdna/readers/segmentmodel_from_cadnano.py +++ b/mrdna/readers/segmentmodel_from_cadnano.py @@ -109,7 +109,7 @@ def ntcount(scafs): return 0 else: return 1 n=np.array([judge(i) for i in scafs]) - return np.sum(n) + return n def mrdna_model_from_cadnano(json_data,**model_parameters): @@ -124,12 +124,20 @@ def mrdna_model_from_cadnano(json_data,**model_parameters): vh_props, origins = part.helixPropertiesAndOrigins() except: origins = {hid:part.getVirtualHelixOrigin(hid)[:2] for hid in part.getidNums()} + scaf_id=[ntcount(vslist['scaf'][i]) for i in vslist.index] + stap_id=[ntcount(vslist['stap'][i]) for i in vslist.index] cad_bps=part.getIndices(0) - vslist["scafnt"]=[ntcount(vslist['scaf'][i]) for i in vslist.index] - vslist["stapnt"]=[ntcount(vslist['stap'][i]) for i in vslist.index] + vslist["scafnt"]=np.sum(scaf_id) + vslist["stapnt"]=np.sum(stap_id) totnt=np.sum(vslist["scafnt"])+np.sum(vslist["stapnt"]) nt_prop=pd.DataFrame(index=range(totnt),columns=["vh","zid","r","bp","stack","threeprime","seq","orientation"]) - + ind=0 + for vs in range(len(scaf_id)): + for j in range(len(vs)): + if j ==True + nt_prop.loc[ind]["vh"]=vs + nt_prop.loc[ind]["zid"] + model = model_from_basepair_stack_3prime( r, bp, stack, three_prime, seq, orientation, **model_parameters ) diff --git a/mrdna/readers/test.ipynb b/mrdna/readers/test.ipynb index 34cdcbd..b039b19 100644 --- a/mrdna/readers/test.ipynb +++ b/mrdna/readers/test.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": 2, - "id": "ab3deccf", + "id": "065c6b08", "metadata": { "scrolled": true }, @@ -19,7 +19,7 @@ { "cell_type": "code", "execution_count": 7, - "id": "0de414ce", + "id": "e2409533", "metadata": {}, "outputs": [], "source": [ @@ -30,7 +30,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "fdb603c1", + "id": "f3880b54", "metadata": {}, "outputs": [], "source": [ @@ -41,7 +41,7 @@ { "cell_type": "code", "execution_count": 5, - "id": "6f322908", + "id": "5e4380bc", "metadata": {}, "outputs": [ { @@ -224,7 +224,7 @@ { "cell_type": "code", "execution_count": 14, - "id": "f77c2bad", + "id": "6f670828", "metadata": {}, "outputs": [ { @@ -264,7 +264,7 @@ { "cell_type": "code", "execution_count": 18, - "id": "a1df854a", + "id": "ff3c11b6", "metadata": {}, "outputs": [], "source": [ @@ -286,7 +286,7 @@ { "cell_type": "code", "execution_count": 121, - "id": "a88086bf", + "id": "40fffe7e", "metadata": {}, "outputs": [], "source": [ @@ -340,7 +340,7 @@ { "cell_type": "code", "execution_count": 44, - "id": "221a82ed", + "id": "d640032c", "metadata": {}, "outputs": [ { @@ -362,7 +362,7 @@ { "cell_type": "code", "execution_count": 122, - "id": "25accfa8", + "id": "7559115b", "metadata": { "scrolled": true }, @@ -382,7 +382,7 @@ { "cell_type": "code", "execution_count": 52, - "id": "5a0dec07", + "id": "1c4cd407", "metadata": {}, "outputs": [ { @@ -403,7 +403,7 @@ { "cell_type": "code", "execution_count": 83, - "id": "413e3e88", + "id": "b85be77d", "metadata": {}, "outputs": [], "source": [ @@ -420,7 +420,7 @@ { "cell_type": "code", "execution_count": 84, - "id": "e36edb50", + "id": "1b2f9268", "metadata": {}, "outputs": [], "source": [ @@ -431,7 +431,7 @@ { "cell_type": "code", "execution_count": 123, - "id": "40764fb4", + "id": "5042c85d", "metadata": {}, "outputs": [], "source": [ @@ -446,7 +446,7 @@ { "cell_type": "code", "execution_count": 126, - "id": "f6fc8912", + "id": "b91c2367", "metadata": {}, "outputs": [ { @@ -560,16 +560,30 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "9e5e1d1b", + "execution_count": 128, + "id": "3c1fc0c9", "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "(array([0, 2]),)" + ] + }, + "execution_count": 128, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "s=[True,False,True,False,False]\n", + "np.where(np.array(s)==True)" + ] }, { "cell_type": "code", - "execution_count": 112, - "id": "42d23cd4", + "execution_count": 127, + "id": "59833d98", "metadata": {}, "outputs": [ { @@ -593,6 +607,8 @@ " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", + " <th></th>\n", + " <th>r</th>\n", " <th>bp</th>\n", " <th>stack</th>\n", " <th>threeprime</th>\n", @@ -600,7 +616,9 @@ " <th>orientation</th>\n", " </tr>\n", " <tr>\n", - " <th>r</th>\n", + " <th>vh</th>\n", + " <th>zid</th>\n", + " <th></th>\n", " <th></th>\n", " <th></th>\n", " <th></th>\n", @@ -610,7 +628,9 @@ " </thead>\n", " <tbody>\n", " <tr>\n", - " <th>1.0</th>\n", + " <th>0</th>\n", + " <th>0</th>\n", + " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", @@ -618,7 +638,9 @@ " <td>NaN</td>\n", " </tr>\n", " <tr>\n", - " <th>1.0</th>\n", + " <th>1</th>\n", + " <th>3</th>\n", + " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", @@ -626,7 +648,9 @@ " <td>NaN</td>\n", " </tr>\n", " <tr>\n", - " <th>NaN</th>\n", + " <th>2</th>\n", + " <th>1</th>\n", + " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", @@ -634,7 +658,9 @@ " <td>NaN</td>\n", " </tr>\n", " <tr>\n", - " <th>NaN</th>\n", + " <th>3</th>\n", + " <th>2</th>\n", + " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", @@ -642,7 +668,9 @@ " <td>NaN</td>\n", " </tr>\n", " <tr>\n", - " <th>NaN</th>\n", + " <th>1</th>\n", + " <th>8</th>\n", + " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", @@ -654,16 +682,16 @@ "</div>" ], "text/plain": [ - " bp stack threeprime seq orientation\n", - "r \n", - "1.0 NaN NaN NaN NaN NaN\n", - "1.0 NaN NaN NaN NaN NaN\n", - "NaN NaN NaN NaN NaN NaN\n", - "NaN NaN NaN NaN NaN NaN\n", - "NaN NaN NaN NaN NaN NaN" + " r bp stack threeprime seq orientation\n", + "vh zid \n", + "0 0 NaN NaN NaN NaN NaN NaN\n", + "1 3 NaN NaN NaN NaN NaN NaN\n", + "2 1 NaN NaN NaN NaN NaN NaN\n", + "3 2 NaN NaN NaN NaN NaN NaN\n", + "1 8 NaN NaN NaN NaN NaN NaN" ] }, - "execution_count": 112, + "execution_count": 127, "metadata": {}, "output_type": "execute_result" } @@ -675,7 +703,7 @@ { "cell_type": "code", "execution_count": 100, - "id": "9ed6d92a", + "id": "1139214c", "metadata": {}, "outputs": [ { @@ -700,7 +728,7 @@ { "cell_type": "code", "execution_count": 13, - "id": "41cad09e", + "id": "ca81ed00", "metadata": {}, "outputs": [ { @@ -721,7 +749,7 @@ { "cell_type": "code", "execution_count": 14, - "id": "ee7a5b2f", + "id": "895861eb", "metadata": {}, "outputs": [ { @@ -743,7 +771,7 @@ { "cell_type": "code", "execution_count": 198, - "id": "5308fd27", + "id": "82bc0749", "metadata": {}, "outputs": [ { @@ -765,7 +793,7 @@ { "cell_type": "code", "execution_count": 15, - "id": "a173a0cc", + "id": "1f5791d0", "metadata": {}, "outputs": [ { @@ -786,7 +814,7 @@ { "cell_type": "code", "execution_count": 173, - "id": "3ac307d0", + "id": "b36dc7e5", "metadata": {}, "outputs": [], "source": [ @@ -822,7 +850,7 @@ { "cell_type": "code", "execution_count": 177, - "id": "6c3869e9", + "id": "e0f42e86", "metadata": {}, "outputs": [], "source": [ @@ -858,7 +886,7 @@ { "cell_type": "code", "execution_count": 187, - "id": "a938b5d1", + "id": "0ca50f51", "metadata": {}, "outputs": [ { @@ -1085,7 +1113,7 @@ { "cell_type": "code", "execution_count": 142, - "id": "28fa9e4a", + "id": "6b3a92fd", "metadata": {}, "outputs": [], "source": [ @@ -1122,7 +1150,7 @@ { "cell_type": "code", "execution_count": 117, - "id": "5876b835", + "id": "09ac3efa", "metadata": {}, "outputs": [], "source": [ @@ -1143,7 +1171,7 @@ { "cell_type": "code", "execution_count": 116, - "id": "b27560ea", + "id": "20b8e5fb", "metadata": {}, "outputs": [ { @@ -1355,7 +1383,7 @@ { "cell_type": "code", "execution_count": 157, - "id": "c2ac4f18", + "id": "0978d11f", "metadata": {}, "outputs": [ { @@ -1379,7 +1407,7 @@ { "cell_type": "code", "execution_count": 152, - "id": "11333080", + "id": "b9ffc57d", "metadata": {}, "outputs": [ { @@ -1400,7 +1428,7 @@ { "cell_type": "code", "execution_count": 62, - "id": "c15af839", + "id": "91c8bda1", "metadata": {}, "outputs": [ { @@ -1628,7 +1656,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "eda2056d", + "id": "9d00775e", "metadata": {}, "outputs": [], "source": [ @@ -1754,7 +1782,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "f7efd378", + "id": "fe38ddd0", "metadata": {}, "outputs": [], "source": [ @@ -1775,7 +1803,7 @@ { "cell_type": "code", "execution_count": 20, - "id": "1422eca5", + "id": "47af43f2", "metadata": {}, "outputs": [ { @@ -1837,7 +1865,7 @@ { "cell_type": "code", "execution_count": 25, - "id": "cf5a3dbd", + "id": "92ee5de3", "metadata": {}, "outputs": [ { @@ -1899,7 +1927,7 @@ { "cell_type": "code", "execution_count": null, - "id": "98cb9b38", + "id": "e99ffa71", "metadata": {}, "outputs": [], "source": [ @@ -1912,7 +1940,7 @@ { "cell_type": "code", "execution_count": 13, - "id": "ff952b38", + "id": "9f251d5c", "metadata": {}, "outputs": [ { @@ -1933,7 +1961,7 @@ { "cell_type": "code", "execution_count": 7, - "id": "85083378", + "id": "ddff8ccc", "metadata": {}, "outputs": [ { @@ -1982,7 +2010,7 @@ { "cell_type": "code", "execution_count": 36, - "id": "ded55624", + "id": "9bc201d2", "metadata": {}, "outputs": [ { @@ -2044,7 +2072,7 @@ { "cell_type": "code", "execution_count": 1, - "id": "40a7b76d", + "id": "ab8da587", "metadata": {}, "outputs": [ { @@ -2070,7 +2098,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f994ff10", + "id": "4141882b", "metadata": {}, "outputs": [], "source": [] @@ -2078,7 +2106,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "5144726b", + "id": "ce1031ed", "metadata": {}, "outputs": [ { @@ -2098,7 +2126,7 @@ { "cell_type": "code", "execution_count": 13, - "id": "5c836eac", + "id": "0f02b96f", "metadata": {}, "outputs": [ { @@ -2119,7 +2147,7 @@ { "cell_type": "code", "execution_count": 15, - "id": "2c3ce8b1", + "id": "eb6d271c", "metadata": {}, "outputs": [ { @@ -2189,7 +2217,7 @@ { "cell_type": "code", "execution_count": 16, - "id": "137db876", + "id": "db9fb42a", "metadata": {}, "outputs": [], "source": [ @@ -2200,7 +2228,7 @@ { "cell_type": "code", "execution_count": 26, - "id": "8210cbee", + "id": "6e28886e", "metadata": {}, "outputs": [ { @@ -2309,7 +2337,7 @@ { "cell_type": "code", "execution_count": 25, - "id": "4ef92d58", + "id": "8532c958", "metadata": {}, "outputs": [ { @@ -2330,7 +2358,7 @@ { "cell_type": "code", "execution_count": 10, - "id": "57059a9e", + "id": "42c985e8", "metadata": {}, "outputs": [ { @@ -2361,7 +2389,7 @@ { "cell_type": "code", "execution_count": 1, - "id": "001aef7e", + "id": "d26babc9", "metadata": {}, "outputs": [ { @@ -2858,7 +2886,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "8feaa1ca", + "id": "eacb35b4", "metadata": {}, "outputs": [ { @@ -2892,7 +2920,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "4455fa61", + "id": "0ff274ec", "metadata": {}, "outputs": [ { @@ -2912,7 +2940,7 @@ { "cell_type": "code", "execution_count": 5, - "id": "605a19c2", + "id": "cb4b20bc", "metadata": {}, "outputs": [], "source": [ @@ -2922,7 +2950,7 @@ { "cell_type": "code", "execution_count": 6, - "id": "c45d0282", + "id": "9694a3bb", "metadata": {}, "outputs": [ { @@ -2943,7 +2971,7 @@ { "cell_type": "code", "execution_count": 7, - "id": "f0d25377", + "id": "d8dec327", "metadata": {}, "outputs": [ { @@ -2970,7 +2998,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bf3a74cf", + "id": "6af9f1ff", "metadata": {}, "outputs": [], "source": [] -- GitLab