Showing 120 of 341 total issues
Function gen_reactions
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def gen_reactions(self):
""" Generate reactions assocated with min model
Raises:
:obj:`ValueError:` if any phosphate species are missing from the model
Function gen_species_type
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
def gen_species_type(self, kb_species_type, extra_compartment_ids=None):
""" Generate a model species type
Args:
kb_species_type (:obj:`wc_kb.SpeciesType`): knowledge base species type
- 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 calibrate_submodel
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
def calibrate_submodel(self):
""" Calibrate the submodel using data in the KB """
model = self.model
beta = self.options.get('beta')
- 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
Avoid deeply nested control flow statements. Open
Open
if add_transcript in rna_input_seq:
seq = rna_input_seq[add_transcript]
else:
seq = cell.species_types.get_one(id=add_transcript).get_seq()
add_count = gvar.transcript_ntp_usage[add_transcript] = {
Avoid deeply nested control flow statements. Open
Open
if model.distribution_init_concentrations.get_one(species=participant.species).mean <= \
subunit_equilibrium_level[participant.species]:
if reaction not in for_removal:
for_removal.append(reaction)
Avoid deeply nested control flow statements. Open
Open
if species == self._rxn_species_modifier[reaction.id][0]:
modifier_reactants.append(species)
else:
Avoid deeply nested control flow statements. Open
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
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
Open
if aa_coefficient:
old_coef = aa_coefficient.coefficient
el_reaction.participants.remove(aa_coefficient)
el_reaction.participants.add(
aa_species.species_coefficients.get_or_create(
Avoid deeply nested control flow statements. Open
Open
if aa_functions[translation_compartment.id][aa_met][
'function'].id not in expression_terms:
expression_terms.append(aa_functions[translation_compartment.id][
aa_met]['function'].id)
Avoid deeply nested control flow statements. Open
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
Open
if translation_compartment.id == 'c':
matched_trnas = [trna_functions[translation_compartment.id][i]]
else:
if i in trna_functions[translation_compartment.id]:
matched_trnas = [trna_functions[translation_compartment.id][i]]
Avoid deeply nested control flow statements. Open
Open
if subunit.species_type.transcript.gene.id in selenoproteome:
processed_seq = raw_seq[:-1] if raw_seq.endswith('*') else raw_seq
protein_seq = ''.join(i if i!='*' else 'U' for i in processed_seq)
else:
protein_seq = ''.join(i for i in raw_seq if i!='*')
Avoid deeply nested control flow statements. Open
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
Open
if trna_obs not in self._modifiers:
self._modifiers.append(trna_obs)
trna = trna_obs.expression.species.get_one(compartment=cytosol)
Avoid deeply nested control flow statements. Open
Open
if not proteasome_st:
proteasome_st = model.species_types.get_one(name=proteasome)
Avoid deeply nested control flow statements. Open
Open
if proton_participant:
proton_coef = [i for i in model_rxn.participants if i.species.species_type==proton_species_type][0]
model_rxn.participants.discard(proton_coef)
model_rxn.participants.add(
proton_coef.species.species_coefficients.get_or_create(coefficient=proton_coef.coefficient-delta_charge))
Avoid deeply nested control flow statements. Open
Open
if model_compl_species.distribution_init_concentration:
param.value = self._effective_dissociation_constant['{}[{}]'.format(
complex_st_id, compl_compartment_id)] * model_compl_species.distribution_init_concentration.mean
else:
param.value = self._effective_dissociation_constant['{}[{}]'.format(
Avoid deeply nested control flow statements. Open
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
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):