Function gen_species_type
has a Cognitive Complexity of 108 (exceeds 5 allowed). Consider refactoring. Open
def gen_species_type(self, kb_species_type, extra_compartment_ids=None):
""" Generate a model species type and species
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
File initialize_model.py
has 861 lines of code (exceeds 250 allowed). Consider refactoring. Open
""" Initialize the construction of wc_lang-encoded models from wc_kb-encoded knowledge base.
:Author: Yin Hoon Chew <yinhoon.chew@mssm.edu>
:Date: 2019-01-09
:Copyright: 2019, Karr Lab
Function gen_distribution_init_concentrations
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def gen_distribution_init_concentrations(self):
""" Generate concentrations for the model from knowledge base """
kb = self.knowledge_base
model = self.model
media = self.options['media']
- 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_kb_reactions
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def gen_kb_reactions(self):
""" Generate reactions encoded within KB
"""
kb = self.knowledge_base
- 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_kb_rate_laws
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def gen_kb_rate_laws(self):
""" Generate the rate laws for reactions encoded in the knowledge base """
kb = self.knowledge_base
model = self.model
- 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_parameters
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def gen_parameters(self):
""" Generate parameters for the model from knowledge base """
kb = self.knowledge_base
model = self.model
- 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 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
def clean_and_validate_options(self):
""" Apply default options and validate options """
options = self.options
culture_volume = options.get('culture_volume', 1.)
Function determine_protein_structure_from_aa
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def determine_protein_structure_from_aa(self,
polymer_id, count):
""" Determine the empirical formula, molecular weight and charge of
a protein based on the structural information of its metabolite
amino acid monomers to ensure consistency with the pH
- 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 run
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def run(self):
""" Run all the components for initializing model from knowledge base """
self.clean_and_validate_options()
options = self.options
- 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
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
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
if model_compartment.init_density.function_expressions:
volume = model_compartment.init_density.function_expressions[0].function
unit_adjusted_term = '{} * {} * {}'.format(param.id, Avogadro.id, volume.id)
else:
volume = model_compartment.init_volume.mean
Avoid deeply nested control flow statements. Open
if not determined:
formula += subunit.species_type.get_empirical_formula(seq_input=protein_seq) * coef
charge += subunit.species_type.get_charge(seq_input=protein_seq) * coef
weight += subunit.species_type.get_mol_wt(seq_input=protein_seq) * coef
else:
Avoid deeply nested control flow statements. Open
if subunit_id not in gvar.transcript_ntp_usage:
seq = subunit.species_type.get_seq()
gvar.transcript_ntp_usage[subunit.species_type.id] = {
'A': seq.upper().count('A'),
'C': seq.upper().count('C'),
Function gen_compartments
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def gen_compartments(self):
""" Generate compartments for the model from knowledge base """
kb = self.knowledge_base
model = self.model
- 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"