KarrLab/wc_model_gen

View on GitHub

Showing 341 of 341 total issues

Function gen_reactions has a Cognitive Complexity of 222 (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/complexation.py - About 4 days 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_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.
Severity: Minor
Found in wc_model_gen/eukaryote/metabolism.py - About 3 days 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 translation_translocation.py has 1320 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" Generator for translation, protein folding and translocation submodel for eukaryotes
:Author: Yin Hoon Chew <yinhoon.chew@mssm.edu>
:Date: 2019-06-14
:Copyright: 2019, Karr Lab
:License: MIT
Severity: Major
Found in wc_model_gen/eukaryote/translation_translocation.py - About 3 days to fix

    Function gen_rate_laws has a Cognitive Complexity of 164 (exceeds 5 allowed). Consider refactoring.
    Open

        def gen_rate_laws(self):
            """ Generate rate laws for the reactions in the submodel """
            model = self.model
            cell = self.knowledge_base.cell
    
    
    Severity: Minor
    Found in wc_model_gen/eukaryote/translation_translocation.py - About 3 days 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 142 (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/translation_translocation.py - About 2 days 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

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

            for rna_kb, reaction in zip(rnas_kb, self.submodel.reactions):
    
                rna_product = model.species_types.get_one(id=rna_kb.id).species.get_one(compartment=cytosol)
                half_life = rna_kb.properties.get_one(property='half_life').get_value()
                mean_concentration = rna_product.distribution_init_concentration.mean
    Severity: Major
    Found in wc_model_gen/prokaryote/transcription.py and 1 other location - About 2 days to fix
    wc_model_gen/prokaryote/translation.py on lines 184..207

    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 298.

    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

            for protein_kb, reaction in zip(protein_kb, self.submodel.reactions):
    
                protein_product = model.species_types.get_one(id=protein_kb.id).species.get_one(compartment=cytosol)
                half_life = protein_kb.properties.get_one(property='half_life').get_value()
                mean_concentration = protein_product.distribution_init_concentration.mean
    Severity: Major
    Found in wc_model_gen/prokaryote/translation.py and 1 other location - About 2 days to fix
    wc_model_gen/prokaryote/transcription.py on lines 122..145

    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 298.

    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

    File transcription.py has 1089 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """ Generator for transcription submodels for eukaryotes
    
    :Author: Yin Hoon Chew <yinhoon.chew@mssm.edu>
    :Date: 2019-01-07
    :Copyright: 2019, Karr Lab
    Severity: Major
    Found in wc_model_gen/eukaryote/transcription.py - About 2 days to fix

      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 
      Severity: Minor
      Found in wc_model_gen/eukaryote/metabolism.py - About 2 days 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 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
      Severity: Major
      Found in wc_model_gen/eukaryote/metabolism.py - About 2 days to fix

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

                for rnap, factors in elongation_negative_factors.items():
                    elongation_negative_factor_functions[rnap] = {}
                    compartment = mitochondrion if 'polm' in rnap else nucleus
                    n = 1
                    for factor in factors:
        Severity: Major
        Found in wc_model_gen/eukaryote/transcription.py and 2 other locations - About 2 days to fix
        wc_model_gen/eukaryote/transcription.py on lines 757..784
        wc_model_gen/eukaryote/transcription.py on lines 788..815

        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 236.

        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 rnap, factors in elongation_termination_factors.items():
                    elongation_termination_factor_functions[rnap] = {}
                    compartment = mitochondrion if 'polm' in rnap else nucleus
                    n = 1
                    for factor in factors:
        Severity: Major
        Found in wc_model_gen/eukaryote/transcription.py and 2 other locations - About 2 days to fix
        wc_model_gen/eukaryote/transcription.py on lines 757..784
        wc_model_gen/eukaryote/transcription.py on lines 819..846

        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 236.

        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 rnap, factors in init_factors.items():
                    init_factor_functions[rnap] = {}
                    compartment = mitochondrion if 'polm' in rnap else nucleus
                    n = 1
                    for factor in factors:
        Severity: Major
        Found in wc_model_gen/eukaryote/transcription.py and 2 other locations - About 2 days to fix
        wc_model_gen/eukaryote/transcription.py on lines 788..815
        wc_model_gen/eukaryote/transcription.py on lines 819..846

        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 236.

        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

        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
        Severity: Minor
        Found in wc_model_gen/eukaryote/initialize_model.py - About 2 days 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 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
        Severity: Major
        Found in wc_model_gen/eukaryote/initialize_model.py - About 2 days to fix

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

                  for comp, factors in {cytosol: cytoplasmic_initiation_factors, mitochondrion: mitochondrial_initiation_factors}.items():
                      n = 1
                      for factor in factors:
                          factor_exp, all_species, all_parameters, all_volumes, all_observables = utils.gen_response_functions(
                              model, beta, 'translation_init_{}'.format(comp.id), 'translation_init_{}'.format(comp.id), comp, [factor])
          Severity: Major
          Found in wc_model_gen/eukaryote/translation_translocation.py and 1 other location - About 1 day to fix
          wc_model_gen/eukaryote/translation_translocation.py on lines 715..739

          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 212.

          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

                  for comp, factors in {cytosol: cytoplasmic_elongation_factors, mitochondrion: mitochondrial_elongation_factors}.items():
                      n = 1
                      for factor in factors:
                          factor_exp, all_species, all_parameters, all_volumes, all_observables = utils.gen_response_functions(
                              model, beta, 'translation_el_{}'.format(comp.id), 'translation_el_{}'.format(comp.id), comp, [factor])
          Severity: Major
          Found in wc_model_gen/eukaryote/translation_translocation.py and 1 other location - About 1 day to fix
          wc_model_gen/eukaryote/translation_translocation.py on lines 687..711

          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 212.

          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 4 locations. Consider refactoring.
          Open

                      for species in init_reaction.rate_laws[0].expression.species:
                          init_species_counts[species.id] = species.distribution_init_concentration.mean
                          model_Km = model.parameters.get_one(
                                  id='K_m_{}_{}'.format(init_reaction.id, species.species_type.id))
                          if model_Km:
          Severity: Major
          Found in wc_model_gen/eukaryote/translation_translocation.py and 3 other locations - About 1 day to fix
          wc_model_gen/eukaryote/transcription.py on lines 1232..1245
          wc_model_gen/eukaryote/translation_translocation.py on lines 1237..1250
          wc_model_gen/eukaryote/translation_translocation.py on lines 1294..1307

          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 171.

          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 4 locations. Consider refactoring.
          Open

                      for species in reaction.rate_laws[0].expression.species:
                          init_species_counts[species.id] = species.distribution_init_concentration.mean
                          model_Km = model.parameters.get_one(
                                  id='K_m_{}_{}'.format(reaction.id, species.species_type.id))
                          if model_Km:
          Severity: Major
          Found in wc_model_gen/eukaryote/transcription.py and 3 other locations - About 1 day to fix
          wc_model_gen/eukaryote/translation_translocation.py on lines 1194..1207
          wc_model_gen/eukaryote/translation_translocation.py on lines 1237..1250
          wc_model_gen/eukaryote/translation_translocation.py on lines 1294..1307

          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 171.

          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 4 locations. Consider refactoring.
          Open

                      for species in el_reaction.rate_laws[0].expression.species:
                          el_species_counts[species.id] = species.distribution_init_concentration.mean
                          model_Km = model.parameters.get_one(
                                  id='K_m_{}_{}'.format(el_reaction.id, species.species_type.id))
                          if model_Km:
          Severity: Major
          Found in wc_model_gen/eukaryote/translation_translocation.py and 3 other locations - About 1 day to fix
          wc_model_gen/eukaryote/transcription.py on lines 1232..1245
          wc_model_gen/eukaryote/translation_translocation.py on lines 1194..1207
          wc_model_gen/eukaryote/translation_translocation.py on lines 1294..1307

          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 171.

          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

          Severity
          Category
          Status
          Source
          Language