KarrLab/wc_model_gen

View on GitHub
wc_model_gen/eukaryote/protein_degradation.py

Summary

Maintainability
F
3 days
Test Coverage
A
97%

Function gen_reactions has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

    def gen_reactions(self):
        """ Generate reactions associated with submodel """
        model = self.model
        cell = self.knowledge_base.cell

Severity: Minor
Found in wc_model_gen/eukaryote/protein_degradation.py - About 6 hrs to fix

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 40 (exceeds 5 allowed). Consider refactoring.
Open

    def gen_rate_laws(self):
        """ Generate rate laws for the reactions in the submodel """
        model = self.model
        compartment_proteasomes = self.options['compartment_proteasomes']
        
Severity: Minor
Found in wc_model_gen/eukaryote/protein_degradation.py - About 6 hrs to fix

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 25 (exceeds 5 allowed). Consider refactoring.
Open

    def calibrate_submodel(self):
        """ Calibrate the submodel using data in the KB """
        
        model = self.model        
        cell = self.knowledge_base.cell
Severity: Minor
Found in wc_model_gen/eukaryote/protein_degradation.py - About 3 hrs to fix

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 protein_degradation.py has 259 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" Generator for protein degradation submodel for eukaryotes
:Author: Yin Hoon Chew <yinhoon.chew@mssm.edu>
:Date: 2019-06-11
:Copyright: 2019, Karr Lab
:License: MIT
Severity: Minor
Found in wc_model_gen/eukaryote/protein_degradation.py - About 2 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                            if species == self._rxn_species_modifier[reaction.id][0]:
                                modifier_reactants.append(species)
                    else:
    Severity: Major
    Found in wc_model_gen/eukaryote/protein_degradation.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if not proteasome_st:
                                  proteasome_st = model.species_types.get_one(name=proteasome)
                              
      Severity: Major
      Found in wc_model_gen/eukaryote/protein_degradation.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if proteasome_species == self._rxn_species_modifier[reaction.id][0]:
                                    modifier_reactants.append(proteasome_species)
                            
        Severity: Major
        Found in wc_model_gen/eukaryote/protein_degradation.py - About 45 mins to fix

          Identical blocks of code found in 3 locations. Consider refactoring.
          Open

                          if protein_kb.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)
          Severity: Major
          Found in wc_model_gen/eukaryote/protein_degradation.py and 2 other locations - About 2 hrs to fix
          wc_model_gen/eukaryote/complexation.py on lines 191..193
          wc_model_gen/eukaryote/translation_translocation.py on lines 292..294

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 55.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                          model_rxn.participants.add(
                              h2o.species_coefficients.get_or_create(
                              coefficient=-(sum(aa_content.values())-1)))
          Severity: Major
          Found in wc_model_gen/eukaryote/protein_degradation.py and 1 other location - About 1 hr to fix
          wc_model_gen/eukaryote/complexation.py on lines 223..225

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 39.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 3 locations. Consider refactoring.
          Open

                  Avogadro = self.model.parameters.get_or_create(
                      id='Avogadro',
                      type=None,
                      value=scipy.constants.Avogadro,
                      units=unit_registry.parse_units('molecule mol^-1'))       
          Severity: Major
          Found in wc_model_gen/eukaryote/protein_degradation.py and 2 other locations - About 50 mins to fix
          wc_model_gen/eukaryote/rna_degradation.py on lines 200..204
          wc_model_gen/eukaryote/translation_translocation.py on lines 1124..1128

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 36.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                              for species in modifier.expression.species:
                                  if species == self._rxn_species_modifier[reaction.id][0]:
                                      modifier_reactants.append(species)
          Severity: Major
          Found in wc_model_gen/eukaryote/protein_degradation.py and 2 other locations - About 45 mins to fix
          wc_model_gen/eukaryote/protein_degradation.py on lines 178..179
          wc_model_gen/eukaryote/protein_degradation.py on lines 200..201

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 35.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                          if modifier == self._rxn_species_modifier[reaction.id][0]:
                              modifier_reactants.append(modifier)
          Severity: Major
          Found in wc_model_gen/eukaryote/protein_degradation.py and 2 other locations - About 45 mins to fix
          wc_model_gen/eukaryote/protein_degradation.py on lines 184..186
          wc_model_gen/eukaryote/protein_degradation.py on lines 200..201

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 35.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                                  if proteasome_species == self._rxn_species_modifier[reaction.id][0]:
                                      modifier_reactants.append(proteasome_species)
          Severity: Major
          Found in wc_model_gen/eukaryote/protein_degradation.py and 2 other locations - About 45 mins to fix
          wc_model_gen/eukaryote/protein_degradation.py on lines 178..179
          wc_model_gen/eukaryote/protein_degradation.py on lines 184..186

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 35.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                              proteasome_total_exp, error = wc_lang.ObservableExpression.deserialize(
                                  ' + '.join(modifier_species.keys()),
                                  {wc_lang.Species: modifier_species})            
          Severity: Minor
          Found in wc_model_gen/eukaryote/protein_degradation.py and 1 other location - About 35 mins to fix
          wc_model_gen/eukaryote/transcription.py on lines 733..735

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 33.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          There are no issues that match your filters.

          Category
          Status