Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

15 filter the presence of seeds in the scope by removing seeds absent from the network #17

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install setuptools wheel twine build
pip install -r requirements.txt
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERS }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
python -m build
twine upload dist/*
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

# MeneTools v3.4.0 (2024-02-28)

## Modify

* Filter the presence of seeds in the scope by removing seeds absent from the network (issue #15)
* Modify if statement that will be deprecated in the future
* Replace use of pkg_resources that will become deprecated
* Move from `setup.py`/`setup.cfg` to `pyproject.toml`
* Update license year

# MeneTools v3.3.0 (2023-01-05)

## Add
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ from menetools import run_menescope
model = run_menescope(draft_sbml='required',seeds_sbml='required',output='optional')
```

The outputs for menecope are

- As a control: seeds that were provided but do not appear in the metabolic network.
- The _scope_ i.e. compounds that are in the seeds and those that are produced from the seeds
- Two subsets to distinguish seed status
- those that can be produced by the metabolic network. For such seeds, the organism would have the metabolic capability to renew the production in addition to what was available in the environement.
- those that cannot be produced by the metabolic network. For such seeds, there is no alternative other than relying on the environmental composition.

### MENEACTI

Meneacti is a python3 tool that retrieve the activable reactions from
Expand Down Expand Up @@ -296,4 +304,3 @@ model = run_menescope_inc(draft_sbml='required',seeds_sbml='required',targets_sb
Many thanks to
* [@Aluriak](https://github.com/Aluriak) for his awesome work with [Clyngor](https://github.com/Aluriak/clyngor).
* [@mablt](https://github.com/mablt) for his contribution to MeneSeed.

4 changes: 2 additions & 2 deletions menetools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2017-2023 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# Copyright (C) 2017-2024 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
Expand All @@ -22,6 +22,6 @@
from menetools.menescope_inc import run_menescope_inc


__version__="3.3.0"
__version__="3.4.0"
"""Define the version of the package.
"""
8 changes: 3 additions & 5 deletions menetools/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2017-2023 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# Copyright (C) 2017-2024 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
Expand All @@ -14,9 +14,7 @@

import argparse
import logging
import pkg_resources
import sys
import time

logger = logging.getLogger('menetools')
logger.setLevel(logging.DEBUG)
Expand All @@ -26,6 +24,7 @@
logger.addHandler(out_hdlr)
logger.propagate = True

from menetools import __version__ as VERSION
from menetools.menescope import run_menescope
from menetools.meneacti import run_meneacti
from menetools.menecheck import run_menecheck
Expand All @@ -36,7 +35,6 @@
from menetools.menescope_inc import run_menescope_inc
from shutil import which

VERSION = pkg_resources.get_distribution("menetools").version
LICENSE = """Copyright (C) Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -217,7 +215,7 @@ def main():

scope_parser = subparsers.add_parser(
"scope",
help="Get producible metabolites in a metabolic network, starting from seeds.",
help="Get producible metabolites in a metabolic network, starting from seeds. The outputs for menecope are (i) As a control: seeds that were provided but do not appear in the metabolic network., (ii) The _scope_ i.e. compounds that are in the seeds and those that are produced from the seeds, (iii) Two subsets to distinguish seed status. (iii-a) those that can be produced by the metabolic network. For such seeds, the organism would have the metabolic capability to renew the production in addition to what was available in the environement. (iii-b) those that cannot be produced by the metabolic network. For such seeds, there is no alternative other than relying on the environmental composition.",
parents=[
parent_parser_d, parent_parser_s, parent_parser_o
]
Expand Down
18 changes: 15 additions & 3 deletions menetools/encodings/get_scope.lp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@
% You should have received a copy of the GNU Lesser General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>

% filter seeds by removing those that never occur in the metabolic network
true_seed(M) :- seed(M), reactant(M, _).
true_seed(M) :- seed(M), product(M, _).

absent_seed(M) :- seed(M), not true_seed(M).

% scope of the seeds in the metabolic network
dscope(M) :- product(M,R), dreaction(R),
dscope(M2) : reactant(M2,R).
dscope(M) :- reactant(M,R), dreaction(R), reversible(R),
dscope(M2) : product(M2,R).
dscope(M) :- seed(M).
dscope(M) :- true_seed(M).

% activated reactions in the metabolic network
activated(R) :- dreaction(R),
Expand All @@ -24,8 +30,14 @@ activated(R) :- dreaction(R), reversible(R),
dscope(M2) : product(M2,R).

% seeds that can also be produced
produced_seed(M):- product(M,R), dreaction(R), activated(R), seed(M).
produced_seed(M):- reactant(M,R), dreaction(R), activated(R), reversible(R), seed(M).
produced_seed(M):- product(M,R), dreaction(R), activated(R), true_seed(M).
produced_seed(M):- reactant(M,R), dreaction(R), activated(R), reversible(R), true_seed(M).

non_produced_seed(M):- true_seed(M), not produced_seed(M).


#show dscope/1.
#show produced_seed/1.
#show non_produced_seed/1.
#show absent_seed/1.
#show activated/1.
2 changes: 1 addition & 1 deletion menetools/meneacti.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python3
#-*- coding: utf-8 -*-

# Copyright (C) 2017-2023 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# Copyright (C) 2017-2024 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
Expand Down
2 changes: 1 addition & 1 deletion menetools/menecheck.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!python
# -*- coding: utf-8 -*-

# Copyright (C) 2017-2023 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# Copyright (C) 2017-2024 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
Expand Down
2 changes: 1 addition & 1 deletion menetools/menecof.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
#-*- coding: utf-8 -*-

# Copyright (C) 2017-2023 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# Copyright (C) 2017-2024 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
Expand Down
2 changes: 1 addition & 1 deletion menetools/menedead.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!python
# -*- coding: utf-8 -*-

# Copyright (C) 2017-2023 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# Copyright (C) 2017-2024 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
Expand Down
2 changes: 1 addition & 1 deletion menetools/menepath.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python3
#-*- coding: utf-8 -*-

# Copyright (C) 2017-2023 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# Copyright (C) 2017-2024 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
Expand Down
18 changes: 16 additions & 2 deletions menetools/menescope.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python3
#-*- coding: utf-8 -*-

# Copyright (C) 2017-2023 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# Copyright (C) 2017-2024 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
Expand Down Expand Up @@ -62,17 +62,31 @@ def run_menescope(draft_sbml,seeds_sbml,output=None):
model = query.get_scope(draftnet, seeds)
scope = []
produced_seeds = []
non_produced_seeds = []
absent_seeds = []
for pred in model:
if pred == 'dscope':
for a in model[pred, 1]:
scope.append(a[0])
if pred == 'produced_seed':
for a in model[pred, 1]:
produced_seeds.append(a[0])
if pred == 'non_produced_seed':
for a in model[pred, 1]:
non_produced_seeds.append(a[0])
if pred == 'absent_seed':
for a in model[pred, 1]:
absent_seeds.append(a[0])
logger.info(' ' + str(len(scope)) + ' compounds on scope:')
logger.info('\n'.join(scope))
logger.info(' ' + str(len(produced_seeds)) + ' seeds are producible:')
logger.info('\n'.join(produced_seeds))
logger.info(' ' + str(len(non_produced_seeds)) + ' seeds are not producible:')
logger.info('\n'.join(non_produced_seeds))
logger.info(' ' + str(len(absent_seeds)) + ' seeds that were provided as input are absent from the network:')
logger.info('\n'.join(absent_seeds))

results = {'scope': scope, 'produced_seeds': produced_seeds}
results = {'scope': scope, 'produced_seeds': produced_seeds, 'non_produced_seeds': non_produced_seeds, 'absent_seeds': absent_seeds}
if output:
with open(output, "w") as output_file:
json.dump(results, output_file, indent=True, sort_keys=True)
Expand Down
2 changes: 1 addition & 1 deletion menetools/menescope_inc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python3
#-*- coding: utf-8 -*-

# Copyright (C) 2017-2023 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# Copyright (C) 2017-2024 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
Expand Down
2 changes: 1 addition & 1 deletion menetools/meneseed.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!python
# -*- coding: utf-8 -*-

# Copyright (C) 2017-2023 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# Copyright (C) 2017-2024 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
Expand Down
2 changes: 1 addition & 1 deletion menetools/query.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2017-2023 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# Copyright (C) 2017-2024 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
Expand Down
4 changes: 2 additions & 2 deletions menetools/sbml.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

# Copyright (C) 2017-2023 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# Copyright (C) 2017-2024 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
Expand Down Expand Up @@ -245,7 +245,7 @@ def readSBMLspecies_clyngor(filename, speciestype) :
model = get_model(sbml)

listOfSpecies = get_listOfSpecies(model)
if listOfSpecies:
if listOfSpecies is not None:
for e in listOfSpecies:
if e.tag[0] == "{":
uri, tag = e.tag[1:].split("}")
Expand Down
2 changes: 1 addition & 1 deletion menetools/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# Copyright (C) 2017-2023 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# Copyright (C) 2017-2024 Clémence Frioux & Arnaud Belcour - Inria Dyliss - Pleiade
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
Expand Down
39 changes: 39 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "MeneTools"
dynamic = ["version"]
authors = [{name = "Clemence Frioux", email = "clemence.frioux@inria.fr"}]
readme = "README.md"
description = "Metabolic Network Topology Analysis Tools"
license = {text = "LGPL-3.0-or-later"}
dependencies = [
'clyngor_with_clingo',
'clyngor'
]

classifiers =[
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Unix',
]

[project.scripts]
mene = "menetools.__main__:main"

[project.urls]
Homepage = "https://github.com/cfrioux/MeneTools"
Changelog = "https://github.com/cfrioux/MeneTools/blob/main/CHANGELOG.md"

[tool.setuptools]
packages = ['menetools']
package-dir = {'menetools' = 'menetools'}
package-data = {'menetools' = ['encodings/*.lp']}

[tool.setuptools.dynamic]
version = { attr = "menetools.__version__" }
dependencies = {file = ["requirements.txt"]}
4 changes: 0 additions & 4 deletions setup.cfg

This file was deleted.

43 changes: 0 additions & 43 deletions setup.py

This file was deleted.

Loading
Loading