Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
Robaina committed Sep 11, 2023
1 parent 8de18ee commit 7b89911
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 41 deletions.
1 change: 1 addition & 0 deletions envs/brendapyrser-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ dependencies:
- mkdocstrings[python]
- ruff
- black
- black[jupyter]
- argmark
- coverage
100 changes: 60 additions & 40 deletions examples/examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"from brendapyrser import BRENDA\n",
"\n",
"\n",
"dataFile = 'data/brenda_download.txt'"
"dataFile = \"data/brenda_download.txt\""
]
},
{
Expand Down Expand Up @@ -98,14 +98,13 @@
],
"source": [
"# Plot all Km values in the database\n",
"BRENDA_KMs = np.array([v for r in brenda.reactions \n",
" for v in r.KMvalues.get_values()])\n",
"BRENDA_KMs = np.array([v for r in brenda.reactions for v in r.KMvalues.get_values()])\n",
"values = BRENDA_KMs[(BRENDA_KMs < 1000) & (BRENDA_KMs >= 0)]\n",
"plt.hist(values)\n",
"plt.title(f'Median KM value: {np.median(values)}')\n",
"plt.xlabel('KM (mM)')\n",
"plt.title(f\"Median KM value: {np.median(values)}\")\n",
"plt.xlabel(\"KM (mM)\")\n",
"plt.show()\n",
"print(f'Minimum and maximum values in database: {values.min()} mM, {values.max()} mM')"
"print(f\"Minimum and maximum values in database: {values.min()} mM, {values.max()} mM\")"
]
},
{
Expand Down Expand Up @@ -135,14 +134,15 @@
],
"source": [
"# Plot all Km values in the database\n",
"BRENDA_Kcats = np.array([v for r in brenda.reactions \n",
" for v in r.Kcatvalues.get_values()])\n",
"BRENDA_Kcats = np.array(\n",
" [v for r in brenda.reactions for v in r.Kcatvalues.get_values()]\n",
")\n",
"values = BRENDA_Kcats[(BRENDA_Kcats < 1000) & (BRENDA_Kcats >= 0)]\n",
"plt.hist(values)\n",
"plt.title(f'Median Kcat value: {np.median(values)}')\n",
"plt.xlabel('Kcat (1/s)')\n",
"plt.title(f\"Median Kcat value: {np.median(values)}\")\n",
"plt.xlabel(\"Kcat (1/s)\")\n",
"plt.show()\n",
"print(f'Minimum and maximum values in database: {values.min()} 1/s, {values.max()} 1/s')"
"print(f\"Minimum and maximum values in database: {values.min()} 1/s, {values.max()} 1/s\")"
]
},
{
Expand Down Expand Up @@ -172,15 +172,19 @@
],
"source": [
"# Plot all enzyme optimal temperature values in the database\n",
"BRENDA_TO = np.array([v for r in brenda.reactions \n",
" for v in r.temperature.filter_by_condition(\n",
" 'optimum').get_values()])\n",
"BRENDA_TO = np.array(\n",
" [\n",
" v\n",
" for r in brenda.reactions\n",
" for v in r.temperature.filter_by_condition(\"optimum\").get_values()\n",
" ]\n",
")\n",
"values = BRENDA_TO[(BRENDA_TO >= 0)]\n",
"plt.hist(values)\n",
"plt.title(f'Median Optimum Temperature: {np.median(values)}')\n",
"plt.xlabel('TO (${}^oC$)')\n",
"plt.title(f\"Median Optimum Temperature: {np.median(values)}\")\n",
"plt.xlabel(\"TO (${}^oC$)\")\n",
"plt.show()\n",
"print(f'Minimum and maximum values in database: {values.min()} °C, {values.max()} °C')"
"print(f\"Minimum and maximum values in database: {values.min()} °C, {values.max()} °C\")"
]
},
{
Expand Down Expand Up @@ -219,15 +223,22 @@
],
"source": [
"# Plot all enzyme optimal temperature values in the database\n",
"species = 'Thermotoga'\n",
"BRENDA_TO = np.array([v for r in brenda.reactions.filter_by_organism(species)\n",
" for v in r.temperature.filter_by_condition('optimum').filter_by_organism(species).get_values()])\n",
"species = \"Thermotoga\"\n",
"BRENDA_TO = np.array(\n",
" [\n",
" v\n",
" for r in brenda.reactions.filter_by_organism(species)\n",
" for v in r.temperature.filter_by_condition(\"optimum\")\n",
" .filter_by_organism(species)\n",
" .get_values()\n",
" ]\n",
")\n",
"values = BRENDA_TO[(BRENDA_TO >= 0)]\n",
"plt.hist(values)\n",
"plt.title(f'Median Optimum Temperature: {np.median(values)}')\n",
"plt.xlabel('TO (${}^oC$)')\n",
"plt.title(f\"Median Optimum Temperature: {np.median(values)}\")\n",
"plt.xlabel(\"TO (${}^oC$)\")\n",
"plt.show()\n",
"print(f'Minimum and maximum values in database: {values.min()} °C, {values.max()} °C')"
"print(f\"Minimum and maximum values in database: {values.min()} °C, {values.max()} °C\")"
]
},
{
Expand Down Expand Up @@ -279,7 +290,7 @@
],
"source": [
"# We can retrieve an enzyme entry by its EC number like this\n",
"r = brenda.reactions.get_by_id('2.7.1.40')\n",
"r = brenda.reactions.get_by_id(\"2.7.1.40\")\n",
"r"
]
},
Expand All @@ -303,11 +314,11 @@
],
"source": [
"# Here are all the KM values for phosphoenolpyruvate associated with this enzyme class\n",
"compound = 'phosphoenolpyruvate'\n",
"compound = \"phosphoenolpyruvate\"\n",
"kms = r.KMvalues.filter_by_compound(compound).get_values()\n",
"plt.hist(kms)\n",
"plt.xlabel('KM (mM)')\n",
"plt.title(f'{r.name} ({compound})')\n",
"plt.xlabel(\"KM (mM)\")\n",
"plt.title(f\"{r.name} ({compound})\")\n",
"plt.show()"
]
},
Expand All @@ -331,11 +342,11 @@
],
"source": [
"# Here are all the KM values for phosphoenolpyruvate associated with this enzyme class\n",
"compound = 'phosphoenolpyruvate'\n",
"compound = \"phosphoenolpyruvate\"\n",
"KMs = r.KMvalues.filter_by_compound(compound).get_values()\n",
"plt.hist(KMs)\n",
"plt.xlabel('KM (mM)')\n",
"plt.title(f'{r.name} ({compound})')\n",
"plt.xlabel(\"KM (mM)\")\n",
"plt.title(f\"{r.name} ({compound})\")\n",
"plt.show()"
]
},
Expand All @@ -357,7 +368,9 @@
],
"source": [
"# And further filtered by organism\n",
"r.KMvalues.filter_by_organism('Bos taurus').filter_by_compound('phosphoenolpyruvate').get_values()"
"r.KMvalues.filter_by_organism(\"Bos taurus\").filter_by_compound(\n",
" \"phosphoenolpyruvate\"\n",
").get_values()"
]
},
{
Expand All @@ -380,11 +393,11 @@
],
"source": [
"# Here are all the Kcat values for phosphoenolpyruvate associated with this enzyme class\n",
"compound = 'phosphoenolpyruvate'\n",
"compound = \"phosphoenolpyruvate\"\n",
"kcats = r.Kcatvalues.filter_by_compound(compound).get_values()\n",
"plt.hist(kcats)\n",
"plt.xlabel('Kcat ($s^{-1}$)')\n",
"plt.title(f'{r.name} ({compound})')\n",
"plt.xlabel(\"Kcat ($s^{-1}$)\")\n",
"plt.title(f\"{r.name} ({compound})\")\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -415,17 +428,24 @@
}
],
"source": [
"species, compound = 'Escherichia coli', 'NADH'\n",
"KMs = np.array([v for r in brenda.reactions.filter_by_organism(species)\n",
" for v in r.KMvalues.filter_by_compound(compound).filter_by_organism(species).get_values()])\n",
"species, compound = \"Escherichia coli\", \"NADH\"\n",
"KMs = np.array(\n",
" [\n",
" v\n",
" for r in brenda.reactions.filter_by_organism(species)\n",
" for v in r.KMvalues.filter_by_compound(compound)\n",
" .filter_by_organism(species)\n",
" .get_values()\n",
" ]\n",
")\n",
"\n",
"if len(KMs) > 0:\n",
" plt.hist(KMs)\n",
" plt.xlabel('KM (mM)')\n",
" plt.title(f'{species} KMs ({compound}), median = {np.median((KMs))}')\n",
" plt.xlabel(\"KM (mM)\")\n",
" plt.title(f\"{species} KMs ({compound}), median = {np.median((KMs))}\")\n",
" plt.show()\n",
"else:\n",
" print('No KM values for compound')"
" print(\"No KM values for compound\")"
]
},
{
Expand Down
1 change: 0 additions & 1 deletion src/brendapyrser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class BRENDA:
"""

def __init__(self, path_to_database):

with open(path_to_database, encoding="iso-8859-1") as file:
self.__data = file.read()
self.__ec_numbers = [
Expand Down

0 comments on commit 7b89911

Please sign in to comment.