Function gen_reactions
has a Cognitive Complexity of 192 (exceeds 5 allowed). Consider refactoring. Open
def gen_reactions(self):
""" Generate reactions associated with submodel
Exchange reactions for components in the media will be be created if they do
not exist. The maximum and minimum flux bounds for exchange reactions will also be set.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function impute_kinetic_constant
has a Cognitive Complexity of 118 (exceeds 5 allowed). Consider refactoring. Open
def impute_kinetic_constant(self, bound_values):
""" Impute the values of kcat that have not been measured.
Args:
bound_values (:obj:`dict`): Keys are reaction IDs and values are tuples
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File metabolism.py
has 921 lines of code (exceeds 250 allowed). Consider refactoring. Open
""" Generator for metabolism submodel for eukaryotes
:Author: Yin Hoon Chew <yinhoon.chew@mssm.edu>
:Date: 2020-01-21
:Copyright: 2020, Karr Lab
Function determine_bounds
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
def determine_bounds(self):
""" Determine the minimum and maximum bounds for each reaction. The bounds will be
scaled according to the provided scale factor.
Returns:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function relax_bounds
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def relax_bounds(self, target, lower_bound_adjustable, upper_bound_adjustable):
""" Relax bounds to achieve set target flux(es) while minimizing the total necessary adjustment
to the flux bounds
Args:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function gen_reactions
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
def gen_reactions(self):
""" Generate reactions associated with submodel
Exchange reactions for components in the media will be be created if they do
not exist. The maximum and minimum flux bounds for exchange reactions will also be set.
Function calibrate_submodel
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def calibrate_submodel(self):
""" Calibrate the submodel by adjusting measured kinetic constants to achieve
the measured growth rate while minimizing the total necessary adjustment.
Kinetic constants that have no measured values are then imputed based on
values determined by Flux Variability Analysis.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function flux_variability_analysis
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def flux_variability_analysis(self, conv_model, fraction_of_objective=1.0,
fixed_values=None, target_reactions=None):
""" Conduct flux variability analysis by:
1) Optimizing the model by maximizing the objective function
2) Setting the objective function to the optimal value
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function clean_and_validate_options
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def clean_and_validate_options(self):
""" Apply default options and validate options """
options = self.options
recycled_metabolites = options.get('recycled_metabolites', {})
Function relax_bounds
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def relax_bounds(self, target, lower_bound_adjustable, upper_bound_adjustable):
""" Relax bounds to achieve set target flux(es) while minimizing the total necessary adjustment
to the flux bounds
Args:
Avoid deeply nested control flow statements. Open
for kcat in law.expression.parameters:
kcat.value = kcat.value*value/effective_vmax
kcat.comments = 'Measured value adjusted to relax bound'
elif all(numpy.isnan(kcat.value) for kcat in law.expression.parameters):
Avoid deeply nested control flow statements. Open
if comp.distribution_init_concentration.mean!=0.0:
kcat.value = shared_vmax/comp.distribution_init_concentration.mean*\
kcat_adjustment_factor
kcat.comments = 'Value imputed based on FVA bound value ' +\
'and adjusted with a factor of {}'.format(kcat_adjustment_factor)
Avoid deeply nested control flow statements. Open
for part in prot_deg_reaction.participants:
if part.species.id in met_requirement:
met_requirement[part.species.id] += -part.coefficient * prot_concentration * \
doubling_time / prot_half_life
Avoid deeply nested control flow statements. Open
for comp, kcat in comp_kcat.items():
if comp.distribution_init_concentration.mean!=0.0:
kcat.value = shared_vmax/comp.distribution_init_concentration.mean*\
kcat_adjustment_factor
kcat.comments = 'Value imputed based on FVA bound value ' +\
Avoid deeply nested control flow statements. Open
for part in translocation_reaction.participants:
if part.species.id in met_requirement:
met_requirement[part.species.id] += -part.coefficient * prot_concentration * \
(1 + doubling_time / prot_half_life)
Avoid deeply nested control flow statements. Open
if numpy.isnan(kcat.value):
kcat.value = median_kcat
kcat.comments = 'Value imputed as the median of measured k_cat values'
elif not any(numpy.isnan(kcat.value) for kcat in law.expression.parameters):
Avoid deeply nested control flow statements. Open
if part.species.id in met_requirement:
met_requirement[part.species.id] += -part.coefficient * mean_concentration * \
(1 + doubling_time / half_life)
# Transcription elongation
transcription_el_reaction = model.reactions.get_one(id='transcription_elongation_{}'.format(rna_kb.id))
Avoid deeply nested control flow statements. Open
for comp, kcat in comp_kcat.items():
kcat.value = median_kcat
kcat.comments = 'Value imputed as the median of measured k_cat values'
else:
Avoid deeply nested control flow statements. Open
if part.species.id in met_requirement:
met_requirement[part.species.id] += -part.coefficient * total_concentration * \
(1 + doubling_time / prot_half_life)
# Translation elongation
translation_el_reaction = model.reactions.get_one(id='translation_elongation_{}'.format(rna_kb.id))
Avoid deeply nested control flow statements. Open
if numpy.isnan(kcat.value):
kcat.value = value/conc*kcat_adjustment_factor
kcat.comments = 'Value imputed based on FVA bound value ' +\
'and adjusted with a factor of {}'.format(kcat_adjustment_factor)
elif (value - kcat.value*conc)/value > 0.01:
Avoid deeply nested control flow statements. Open
if part.species.id in met_requirement:
met_requirement[part.species.id] += -part.coefficient * mean_concentration * \
(1 + doubling_time / half_life)
Avoid deeply nested control flow statements. Open
if sp.distribution_init_concentration:
if sp.distribution_init_concentration.mean > 0.:
compartment = sp.compartment
model_met_id = met_id + f'[{compartment.id}]'
if model_met_id in met_requirement:
Avoid deeply nested control flow statements. Open
if part.species.id in met_requirement:
met_requirement[part.species.id] += -part.coefficient * total_concentration * \
(1 + doubling_time / prot_half_life)
Avoid deeply nested control flow statements. Open
if unknown_vmax_count > 0:
shared_vmax = (value - known_vmax)/unknown_vmax_count
for comp, kcat in comp_kcat.items():
Avoid deeply nested control flow statements. Open
if not numpy.isnan(kcat.value):
known_vmax += kcat.value*comp.distribution_init_concentration.mean
else:
comp_kcat[comp] = kcat
if known_vmax < value and (value - known_vmax)/value > 0.01:
Function conv_for_optim
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def conv_for_optim(self):
""" Convert metabolism reactions into an optimization problem model
Returns:
:obj:`conv_opt.Model`: a conv_opt model for optimization
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function gen_rate_laws
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def gen_rate_laws(self):
""" Generate rate laws for carbohydrate and lipid formation reactions. High
rates are assumed so that the macromolecules are formed as soon as the
components are available.
"""
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"