{ "cells": [ { "cell_type": "code", "execution_count": 3, "id": "c47a32d8-c857-41de-a70a-cec48046df12", "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 92, "id": "e0c6bd53-3417-44bd-b1b4-81802b37fbfc", "metadata": {}, "outputs": [], "source": [ "df = pd.read_csv('binding_moad/every.csv',header=None,skiprows=2)\n", "df = df.rename(columns={2:'pdb',3: 'ligand_name', 4: 'ligand_valid', 7: 'affinity_val', 8: 'affinity_unit', 9:'smiles'})\n", "#df = df[df['ligand_valid']!='invalid'].copy()" ] }, { "cell_type": "code", "execution_count": 93, "id": "e40b1ddc-9a98-4a3b-b8a6-45e3940a3ea2", "metadata": {}, "outputs": [], "source": [ "df['is_sep'] = df[1] == 'Family. Representative Entry is '" ] }, { "cell_type": "code", "execution_count": 94, "id": "4f00a0d1-78db-4f32-9d12-5e035b70ef98", "metadata": {}, "outputs": [], "source": [ "df['cum_sum'] = df['is_sep'].cumsum()" ] }, { "cell_type": "code", "execution_count": 95, "id": "52c0c66c-1eb0-415b-b019-bc77419ccbd7", "metadata": {}, "outputs": [], "source": [ "from pint import UnitRegistry\n", "ureg = UnitRegistry()\n", "\n", "def to_uM(affinity_unit):\n", " try:\n", " val = ureg(str(affinity_unit[0])+str(affinity_unit[1]))\n", " return val.m_as(ureg.uM)\n", " except Exception:\n", " pass\n", " \n", " try:\n", " val = ureg(str(affinity_unit[0])+str(affinity_unit[1]))\n", " return 1/val.m_as(1/ureg.uM)\n", " except Exception:\n", " pass" ] }, { "cell_type": "code", "execution_count": 96, "id": "e5b4dd41-1389-408d-bee6-6dbeefc1d5c7", "metadata": {}, "outputs": [], "source": [ "groupby = df.groupby('cum_sum')" ] }, { "cell_type": "code", "execution_count": 121, "id": "61b8276c-54fe-4989-af5f-723994e1df7e", "metadata": {}, "outputs": [], "source": [ "def group(df):\n", " pdb = df[df['is_sep']]['pdb'].values\n", " if len(pdb) > 0:\n", " pdb = pdb[0]\n", " df['pdb_ref'] = pdb\n", " return df[df['ligand_valid']=='valid']\n", "df_expand = groupby.apply(group).reset_index(drop=True)" ] }, { "cell_type": "code", "execution_count": 124, "id": "8bb2dfac-5f11-455c-9dee-3607b47b4232", "metadata": {}, "outputs": [], "source": [ "df_expand['affinity_uM'] = df_expand[['affinity_val','affinity_unit']].apply(to_uM,axis=1)" ] }, { "cell_type": "code", "execution_count": 125, "id": "0dc39f62-5b18-4a86-9a44-17d1925da2ad", "metadata": {}, "outputs": [], "source": [ "df_complex = pd.read_parquet('data/moad_complex.parquet')\n", "df_complex['name'] = df_complex['name'].str.upper()" ] }, { "cell_type": "code", "execution_count": 128, "id": "6d158a41-64c6-4fa2-92d5-562aa11e8924", "metadata": {}, "outputs": [], "source": [ "df_all = df_expand.merge(df_complex,left_on='pdb_ref',right_on='name')" ] }, { "cell_type": "code", "execution_count": 129, "id": "901fe6c6-dc8c-4ce4-82c6-1fb0b718287a", "metadata": {}, "outputs": [], "source": [ "df_all = df_all[~df_all['affinity_val'].isnull()]" ] }, { "cell_type": "code", "execution_count": 130, "id": "383f9a1c-ffc6-43da-ac5a-5bcb815be28b", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | 0 | \n", "1 | \n", "pdb | \n", "ligand_name | \n", "ligand_valid | \n", "5 | \n", "6 | \n", "affinity_val | \n", "affinity_unit | \n", "smiles | \n", "10 | \n", "is_sep | \n", "cum_sum | \n", "pdb_ref | \n", "affinity_uM | \n", "name | \n", "seq | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "2PA:C:613 | \n", "valid | \n", "Ki | \n", "= | \n", "0.62 | \n", "nM | \n", "NP(=O)(N)O | \n", "NaN | \n", "False | \n", "1 | \n", "6H8J | \n", "0.000620 | \n", "6H8J | \n", "NYIVPGEYRVAEGEIEINAGREKTTIRVSNTGDRPIQVGSHIHFVE... | \n", "
2 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "HAE:C:800 | \n", "valid | \n", "Ki | \n", "= | \n", "2.60 | \n", "uM | \n", "CC(=O)NO | \n", "NaN | \n", "False | \n", "1 | \n", "6H8J | \n", "2.600000 | \n", "6H8J | \n", "NYIVPGEYRVAEGEIEINAGREKTTIRVSNTGDRPIQVGSHIHFVE... | \n", "
7 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "43W:A:902 | \n", "valid | \n", "ic50 | \n", "= | \n", "580.00 | \n", "nM | \n", "C#CCCOP(=O)(O)OP(=O)(O)O | \n", "NaN | \n", "False | \n", "2 | \n", "4S3F | \n", "0.580000 | \n", "4S3F | \n", "MEGMRRPTPTVYVGRVPIGGAHPIAVQSMTNTPTRDVEATTAQVLE... | \n", "
16 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "0CG:A:902 | \n", "valid | \n", "ic50 | \n", "= | \n", "770.00 | \n", "nM | \n", "C#CCOP(=O)(O)OP(=O)(O)O | \n", "NaN | \n", "False | \n", "2 | \n", "4S3F | \n", "0.770000 | \n", "4S3F | \n", "MEGMRRPTPTVYVGRVPIGGAHPIAVQSMTNTPTRDVEATTAQVLE... | \n", "
17 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "ADN:A:901 | \n", "valid | \n", "Kd | \n", "= | \n", "15.00 | \n", "uM | \n", "c1nc(c2c(n1)n(cn2)[C@H]3[C@@H]([C@@H]([C@H](O3... | \n", "NaN | \n", "False | \n", "5 | \n", "2GL0 | \n", "15.000000 | \n", "2GL0 | \n", "MTDMSIKFELIDVPIPQGTNVIIGQAHFIKTVEDLYEALVTSVPGV... | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
51900 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "MAN NAG:G:1 | \n", "valid | \n", "Ka | \n", "= | \n", "7860.00 | \n", "M^-1 | \n", "NaN | \n", "NaN | \n", "False | \n", "10499 | \n", "2WDB | \n", "127.226463 | \n", "2WDB | \n", "MGSSHHHHHHSSGLVPRGSHMASNPSLIRSESWQVYEGNEANLLDG... | \n", "
51901 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "MAN NAG:F:1 | \n", "valid | \n", "Ka | \n", "= | \n", "7860.00 | \n", "M^-1 | \n", "NaN | \n", "NaN | \n", "False | \n", "10499 | \n", "2WDB | \n", "127.226463 | \n", "2WDB | \n", "MGSSHHHHHHSSGLVPRGSHMASNPSLIRSESWQVYEGNEANLLDG... | \n", "
51902 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NGA NAG:F:1 | \n", "valid | \n", "Ka | \n", "= | \n", "5910.00 | \n", "M^-1 | \n", "NaN | \n", "NaN | \n", "False | \n", "10499 | \n", "2WDB | \n", "169.204738 | \n", "2WDB | \n", "MGSSHHHHHHSSGLVPRGSHMASNPSLIRSESWQVYEGNEANLLDG... | \n", "
51903 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NGA NAG:E:1 | \n", "valid | \n", "Ka | \n", "= | \n", "5910.00 | \n", "M^-1 | \n", "NaN | \n", "NaN | \n", "False | \n", "10499 | \n", "2WDB | \n", "169.204738 | \n", "2WDB | \n", "MGSSHHHHHHSSGLVPRGSHMASNPSLIRSESWQVYEGNEANLLDG... | \n", "
51904 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NGA NAG:H:1 | \n", "valid | \n", "Ka | \n", "= | \n", "5910.00 | \n", "M^-1 | \n", "NaN | \n", "NaN | \n", "False | \n", "10499 | \n", "2WDB | \n", "169.204738 | \n", "2WDB | \n", "MGSSHHHHHHSSGLVPRGSHMASNPSLIRSESWQVYEGNEANLLDG... | \n", "
25425 rows × 17 columns
\n", "