Skip to content

Commit

Permalink
Chore upgrade all (#262)
Browse files Browse the repository at this point in the history
* Dropping Python2 support

* Dropping Python 2 support, fixing typos

* Removed six from RTD requirements

* Typo parenthesis

* Fixing same typo on same line...

* Extracting first unique element of dictionary by list()

* Fixed typo

* Fixed wrong translation from iteritems

* Removed Python2 travis tests

* chore: update networkx

* chore: pin optlang for cobrapy 0.20

* chore: update pandas

* chore: downgrade networks lower requirement so that is py3.5 compatible

* docs: update package metadata

* Dropping Python2 support

* Dropping Python 2 support, fixing typos

* Extracting first unique element of dictionary by list()

* Fixed typo

* chore: update networkx

* chore: pin optlang for cobrapy 0.20

* chore: update pandas

* chore: downgrade networks lower requirement so that is py3.5 compatible

* docs: update package metadata

* style: apply flake8

* test: upgrade CI for 3.6,3.7,3.8

* docs: remove support for py35

* test: update travis dist to xenial

* test: remove six as dependency for tests

* fix: use the right tox envs

* test: force export TRAVIS to children processes

* test: pass travis variable through tox

* test: fix env variables tox
  • Loading branch information
carrascomj authored Oct 21, 2020
1 parent 13571b9 commit 0770669
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 28 deletions.
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: python
sudo: required
dist: trusty
dist: xenial

env:
global:
Expand All @@ -9,12 +9,14 @@ env:
matrix:
fast_finish: true
include:
- python: '3.5'
- python: '3.6'
env: TOXENV=flake8
- python: '3.5'
env: TOXENV=py35
- python: '3.6'
env: TOXENV=py36
- python: '3.7'
env: TOXENV=py37
- python: '3.8'
env: TOXENV=py38

branches:
only:
Expand Down
2 changes: 1 addition & 1 deletion cameo/flux_analysis/structural.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def find_coupled_reactions_nullspace(model, ns=None, tol=1e-10):
left = non_blocked_ns[i]
group = next((g for g in groups if reaction_i in g), None)
if group:
reaction_i = next(l for l, c in group.items() if c == 1)
reaction_i = next(reac for reac, c in group.items() if c == 1)
left = non_blocked_ns[reaction_index[reaction_i]]
else:
group = {reaction_i: 1}
Expand Down
2 changes: 1 addition & 1 deletion cameo/network_analysis/networkx_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,5 @@ def remove_highly_connected_nodes(network, max_degree=10, ignore=[]):
-------
None
"""
to_remove = [node for node, degree in network.degree_iter() if degree > max_degree and node not in ignore]
to_remove = [node for node, degree in network.degree if degree > max_degree and node not in ignore]
network.remove_nodes_from(to_remove)
4 changes: 2 additions & 2 deletions cameo/strain_design/deterministic/flux_variability_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def __init__(self, solutions, phase_plane, reference_fva, **kwargs):
self.reference_fva = reference_fva
self.solutions = solutions
self.groups = self.solutions.groupby(
('biomass', 'production'), as_index=False, sort=False
['biomass', 'production'], as_index=False, sort=False
)

@classmethod
Expand Down Expand Up @@ -525,7 +525,7 @@ def _generate_designs(cls, solutions, reference_fva):
A list of cameo.core.strain_design.StrainDesign for each DataFrame in solutions.
"""
designs = []
for _, solution in solutions.groupby(('biomass', 'production'), as_index=False, sort=False):
for _, solution in solutions.groupby(['biomass', 'production'], as_index=False, sort=False):
targets = []
relevant_targets = solution[
(solution['normalized_gaps'].abs() > non_zero_flux_threshold) & (
Expand Down
6 changes: 4 additions & 2 deletions cameo/strain_design/pathway_prediction/pathway_predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ def __str__(self):
for i, pathway in enumerate(self.pathways):
string += 'Pathway No. {}'.format(i + 1)
for reaction in pathway.reactions:
string += '{}, {}:'.format(reaction.id, reaction.name,
reaction.build_reaction_string(use_metabolite_names=True))
string += '{}, {}: {}'.format(
reaction.id, reaction.name,
reaction.build_reaction_string(use_metabolite_names=True)
)
return string

def plot(self, grid=None, width=None, height=None, title=None):
Expand Down
4 changes: 2 additions & 2 deletions cameo/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,8 @@ def partition(ite, n):
return [list(islice(iterator, 0, round(division * (i + 1)) - round(division * i))) for i in range(n)]


def flatten(l):
return [item for sublist in l for item in sublist]
def flatten(input_list):
return [item for sublist in input_list for item in sublist]


def generate_colors(n):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-e .
-e . --use-feature=2020-resolver
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
requirements = ['numpy>=1.9.1',
'scipy>=0.14.0',
'blessings>=1.5.1',
'pandas>=0.24.0',
'pandas>=1.1.3',
'ordered-set>=1.2',
'cobra>=0.11.1',
'future>=0.15.2',
'optlang>=1.2.1',
'optlang==1.4.2',
'numexpr>=2.4',
'requests>=2.10.0',
'networkx==1.9.1',
'networkx>=2.4',
'escher>=1.1.2',
'IProgress>=0.4',
'inspyred>=1.0',
Expand Down Expand Up @@ -85,9 +85,9 @@
classifiers=[
'Development Status :: 3 - Alpha',
'Topic :: Utilities',
'Programming Language :: Python :: 2.5',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'License :: OSI Approved :: Apache Software License'
],
)
14 changes: 7 additions & 7 deletions tests/test_network_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ def test_distance_based_on_molecular_formula(salmonella):


def test_model_to_network(salmonella):
assert model_to_network(salmonella).edges() == reactions_to_network(salmonella.reactions).edges()
assert model_to_network(salmonella).edges == reactions_to_network(salmonella.reactions).edges
network = model_to_network(salmonella)
assert len(network.nodes()) == 1761
assert len(network.edges()) == 4924
assert len(network.nodes) == 1761
assert len(network.edges) == 4924
network = model_to_network(salmonella, max_distance=1.)
# nodes = network.nodes()
# print(set(nodes).difference(set(core_model_one.metabolites)))
# print(set(core_model_one.metabolites).difference(set(nodes)))
assert len(network.nodes()) == 1800
assert len(network.edges()) == 12853
assert len(network.nodes) == 1800
assert len(network.edges) == 12853


def test_remove_highly_connected_nodes(salmonella):
network = model_to_network(salmonella)
assert salmonella.metabolites.atp_c in network.nodes()
assert salmonella.metabolites.adp_c in network.nodes()
remove_highly_connected_nodes(network, max_degree=10, ignore=[salmonella.metabolites.atp_c])
assert len(network.nodes()) == 1671
assert len(network.edges()) == 2342
assert len(network.nodes) == 1671
assert len(network.edges) == 2342
assert salmonella.metabolites.atp_c in network.nodes()
assert salmonella.metabolites.adp_c not in network.nodes()
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = flake8, py27, py34, py35, py36
envlist = flake8, py36, py37, py38

[testenv]
deps =
Expand All @@ -8,6 +8,8 @@ deps =
pytest-benchmark
whitelist_externals =
obabel
setenv =
TRAVIS = True
commands =
pytest --cov=cameo {posargs: -v -rsx --cov-report=xml --cov-report=term --benchmark-skip tests}

Expand All @@ -16,6 +18,7 @@ skip_install = True
deps = flake8
commands = flake8 cameo


[pytest]
filterwarnings =
ignore::DeprecationWarning:cobra.core.reaction
Expand Down Expand Up @@ -45,7 +48,6 @@ known_first_party = cameo
known_third_party =
cobra
future
six

[coverage:paths]
source =
Expand Down

0 comments on commit 0770669

Please sign in to comment.