Skip to content

Commit

Permalink
Version 1.1.7 (#471)
Browse files Browse the repository at this point in the history
* single click to trigger jump to metabolite

* Bump to 1.1.7

Co-authored-by: axelvonkamp <[email protected]>
  • Loading branch information
Paulocracy and axelvonkamp authored May 9, 2023
1 parent e270634 commit dcaead5
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 31 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Everyone is welcome to contribute to CNApy's development. [See our contribution

## Using the Windows installer

1. Download the zipped CNApy Windows installer [from here](https://github.com/cnapy-org/CNApy/releases/download/v1.1.6/cnapy-windows-installer.zip).
1. Download the zipped CNApy Windows installer [from here](https://github.com/cnapy-org/CNApy/releases/download/v1.1.7/cnapy-windows-installer.zip).
2. Unzip the file into your desired location. You can do this by right-clicking on the file and selecting the option to extract the files.
3. In the location where you unzipped the file, click on "INSTALL_CNAPY.bat". As soon as the installation is finished, the appearing window closes and you can start CNApy either by double-clicking on the newly created CNApy desktop icon or by searching for CNApy through the task bar search.

Expand All @@ -75,12 +75,12 @@ Click on the operating system you use:
1. Download Miniconda [from here](https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh).
2. Install Miniconda by double-clicking the downloaded file. If the script does not run, right-click on the file, open its settings and select the option to make it executable (alternative: run 'chmod u+x ./Miniconda3-latest-Linux-x86_64.sh' in your terminal). Follow the appearing installation instructions and remember in which folder you install Miniconda. If you already use Anaconda on your computer (for which we also directly provide a conda CNApy package, [see here](#install-cnapy-as-conda-package)), deactivate all installation options which put Miniconda to your console or system PATH to avoid possible problems.
3. Using your file manager, go to the folder where you installed Miniconda. Then, open the appearing sub-folder "condabin".
4. Download the CNApy installation assistant script [from here](https://github.com/cnapy-org/CNApy/releases/download/v1.1.6/cnapy-assistant-script.sh) into the mentioned "condabin" folder.
4. Download the CNApy installation assistant script [from here](https://github.com/cnapy-org/CNApy/releases/download/v1.1.7/cnapy-assistant-script.sh) into the mentioned "condabin" folder.
5. In the file manager, double-click on the newly downloaded installation assistant script which is called "cnapy-assistant-script.sh". If the script does not run, right-click on the file, open its settings and select the option to make it executable (alternative: run 'chmod u+x ./cnapy-assistant-script.sh' in your terminal). Wait until CNApy is downloaded and installed.
6. You can now run CNApy by executing the following two terminal instructions in the mentioned "condabin" folder:

```sh
./conda activate cnapy-1.1.6
./conda activate cnapy-1.1.7
cnapy
```

Expand All @@ -89,12 +89,12 @@ cnapy
1. If you have a (new) Mac with an ARM processor, such as the M1 or M2, download Miniconda [from here](https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.pkg). If you have an (older) Mac with an Intel processor, download Miniconda [from here](https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.pkg). If you are unsure which processor your Mac has, click on the Apple menu in the upper-left of your screen and choose "About This Mac".
2. Install Miniconda by double-clicking the downloaded file. Follow the appearing installation instructions and remember in which folder you install Miniconda. If you already use Anaconda on your computer (for which we directly provide a conda CNApy package, [see here](#install-cnapy-as-conda-package)), deactivate all installation options which put Miniconda to your console or system PATH to avoid possible problems
3. Using Finder, go to the folder where you installed Miniconda. Then, open the appearing sub-folder "condabin".
4. Download the CNApy installation assistant script [from here](https://github.com/cnapy-org/CNApy/releases/download/v1.1.6/cnapy-assistant-script.sh) into the mentioned "condabin" folder.
4. Download the CNApy installation assistant script [from here](https://github.com/cnapy-org/CNApy/releases/download/v1.1.7/cnapy-assistant-script.sh) into the mentioned "condabin" folder.
5. In the file manager, double-click on the newly downloaded installation assistant script which is called "cnapy-installation-script.sh". If the script does not run, right-click on the file, open its settings and select the option to make it executable (alternative: run 'chmod u+x ./cnapy-assistant-script.sh' in your terminal). Wait until CNApy is downloaded and installed.
6. Open the terminal in the mentioned "condabin" folder. You can now run CNApy by executing the following two terminal instructions:

```sh
./conda activate cnapy-1.1.6
./conda activate cnapy-1.1.7
cnapy
```

Expand All @@ -103,13 +103,13 @@ cnapy
1. Create a conda environment with all dependencies

```sh
conda create -n cnapy-1.1.6 -c Gurobi -c IBMDecisionOptimization -c conda-forge -c cnapy cnapy=1.1.6 --yes
conda create -n cnapy-1.1.7 -c Gurobi -c IBMDecisionOptimization -c conda-forge -c cnapy cnapy=1.1.7 --yes
```

2. Activate the cnapy conda environment

```sh
conda activate cnapy-1.1.6
conda activate cnapy-1.1.7
```

3. Run CNApy within you activated conda environment
Expand Down
2 changes: 1 addition & 1 deletion cnapy/appdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AppData:
''' The application data '''

def __init__(self):
self.version = "cnapy-1.1.6"
self.version = "cnapy-1.1.7"
self.format_version = 2
self.unsaved = False
self.project = ProjectData()
Expand Down
7 changes: 7 additions & 0 deletions cnapy/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ def element_exchange_balance(model: cobra.Model, scen_values: Scenario, non_boun
if rxn.boundary:
reaction_fluxes.append((rxn, flux))

metabolites_without_formulas = set()
for rxn, flux in reaction_fluxes:
for met, coeff in rxn.metabolites.items():
val = coeff * flux
Expand All @@ -291,6 +292,8 @@ def element_exchange_balance(model: cobra.Model, scen_values: Scenario, non_boun
flux_dict = efflux
else:
continue
if len(met.elements) == 0:
metabolites_without_formulas.add(met.id)
for el, count in met.elements.items():
if not organic_elements_only or el in organic_elements:
flux_dict[el] += count * val
Expand All @@ -307,6 +310,10 @@ def print_in_out_balance():
elements.remove(el)
for el in elements:
print_in_out_balance()
if len(metabolites_without_formulas) > 0:
print_func("WARNING: Metabolites wihtout formulas encountered:")
print_func(", ".join(met for met in metabolites_without_formulas))
print_func("The results are likely to be incorrect!")
return influx, efflux

def check_biomass_weight(model: cobra.Model, bm_reac_id: str) -> float:
Expand Down
4 changes: 2 additions & 2 deletions cnapy/gui_elements/flux_feasibility_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,8 @@ def show_elemental_balance(self):
elif len(self.bm_reac_id) > 0:
non_boundary_reactions.append(self.bm_reac_id)
biomass_text = " including biomass reaction " + self.bm_reac_id
def print_to_console(txt):
self.main_window.centralWidget().console._append_plain_text(txt + "\n", before_prompt=True)
def print_to_console(*txt):
self.main_window.centralWidget().console._append_plain_text(' '.join(list(txt)) + "\n", before_prompt=True)
print_to_console("\nScenario fluxes" + biomass_text + ":")
element_exchange_balance(self.appdata.project.cobra_py_model, self.appdata.project.scen_values,
non_boundary_reactions, organic_elements_only=True, print_func=print_to_console)
Expand Down
27 changes: 18 additions & 9 deletions cnapy/gui_elements/reaction_table_widget.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from enum import Enum
from qtpy.QtCore import Qt, Signal, Slot
from qtpy.QtWidgets import QApplication, QTableWidget, QTableWidgetItem, QAbstractItemView, QPlainTextEdit
from qtpy.QtGui import QMouseEvent, QTextCursor


class ModelElementType(Enum):
Expand All @@ -11,23 +12,31 @@ class ModelElementType(Enum):
class ReactionString(QPlainTextEdit):
def __init__(self, reaction, metabolite_list):
super().__init__()
reaction_string = reaction.build_reaction_string()
reaction_string = reaction.build_reaction_string() + " " # extra space to be able to click outside the equation without triggering a jump to the metabolite
self.setPlainText(reaction_string)
self.text_width = self.fontMetrics().horizontalAdvance(reaction_string)
self.setReadOnly(True)
self.model = reaction.model
self.metabolite_list = metabolite_list
self.selectionChanged.connect(self.switch_metabolite)

jumpToMetabolite = Signal(str)

@Slot()
def switch_metabolite(self):
selected_text = self.textCursor().selectedText()
if self.model.metabolites.has_id(selected_text):
self.jumpToMetabolite.emit(selected_text)
self.metabolite_list.set_current_item(selected_text)

def mouseReleaseEvent(self, event: QMouseEvent):
if event.button() == Qt.LeftButton:
text_cursor: QTextCursor = self.textCursor()
if not text_cursor.hasSelection():
start: int = text_cursor.position()
text: str = self.toPlainText()
if start >= len(text):
return
while start > 0:
start -= 1
if text[start].isspace():
break
text = text[start:].split(maxsplit=1)[0]
if self.model.metabolites.has_id(text):
self.jumpToMetabolite.emit(text)
self.metabolite_list.set_current_item(text)

class ReactionTableWidget(QTableWidget):
def __init__(self, appdata, element_type: ModelElementType) -> None:
Expand Down
2 changes: 1 addition & 1 deletion constructor/linux/construct.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: CNApy
version: 1.1.6
version: 1.1.7

ignore_duplicate_files: True

Expand Down
4 changes: 2 additions & 2 deletions constructor/win/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ We use conda as package manager to install CNApy. You can use [miniconda](https:

1. Create a conda environment with all dependencies
```sh
conda create -n cnapy-1.1.6 -c conda-forge -c cnapy cnapy=1.1.6
conda create -n cnapy-1.1.7 -c conda-forge -c cnapy cnapy=1.1.7
```

2. Activate the cnapy conda environment
```
conda activate cnapy-1.1.6
conda activate cnapy-1.1.7
```

3. Run CNApy
Expand Down
4 changes: 2 additions & 2 deletions constructor/win/construct.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: CNApy
version: 1.1.6
version: 1.1.7

ignore_duplicate_files: True

Expand All @@ -10,7 +10,7 @@ channels:

specs:
- conda
# - cnapy=1.1.6
# - cnapy=1.1.7
- mamba
- pip
- python=3.8
Expand Down
2 changes: 1 addition & 1 deletion constructor/win/post_install.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
call %~dp0..\Scripts\activate.bat

call mamba install cnapy=1.1.6 -c cnapy -c conda-forge -v --yes
call mamba install cnapy=1.1.7 -c cnapy -c conda-forge -v --yes
call pause
call %~dp0..\Scripts\conda clean --all --yes
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ Everyone is welcome to contribute to CNApy's development. [See our contribution
3. Create a conda environment with all dependencies

```sh
conda create -n cnapy-1.1.6 -c conda-forge -c cnapy cnapy=1.1.6
conda create -n cnapy-1.1.7 -c conda-forge -c cnapy cnapy=1.1.7
```

4. Activate the cnapy conda environment

```sh
conda activate cnapy-1.1.6
conda activate cnapy-1.1.7
```

5. Run CNApy within you activated conda environment
Expand Down
2 changes: 1 addition & 1 deletion recipes/linux/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set version = '1.1.6' %}
{% set version = '1.1.7' %}

package:
name: cnapy
Expand Down
2 changes: 1 addition & 1 deletion recipes/noarch/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set version = '1.1.6' %}
{% set version = '1.1.7' %}

package:
name: cnapy
Expand Down
2 changes: 1 addition & 1 deletion recipes/win/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set version = '1.1.6' %}
{% set version = '1.1.7' %}

package:
name: cnapy
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

setup(
name='cnapy',
version='1.1.6',
version='1.1.7',
url='https://github.com/cnapy-org/CNApy/',
license='GPLv3+',
description='An integrated environment for metabolic network analysis.',
Expand Down

0 comments on commit dcaead5

Please sign in to comment.