KarrLab/wc_model_gen

View on GitHub
wc_model_gen/prokaryote/metabolism.py

Summary

Maintainability
F
5 days
Test Coverage
B
86%

File metabolism.py has 293 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" Generator for metabolism submodels based on KBs for random in silico organisms

:Author: Balazs Szigeti <balazs.szigeti@mssm.edu>
:Author: Jonathan Karr <karr@mssm.edu>
:Author: Ashwin Srinivasan <ashwins@mit.edu>
Severity: Minor
Found in wc_model_gen/prokaryote/metabolism.py - About 3 hrs to fix

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

        def gen_reactions(self):
            """ Generate reactions assocated with min model
    
            Raises:
                :obj:`ValueError:` if any phosphate species are missing from the model
    Severity: Minor
    Found in wc_model_gen/prokaryote/metabolism.py - About 2 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 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def gen_rate_laws(self):
            """ Generate rate laws associated with min metabolism model
    
                Raises:
                    :obj:`ValueError:` if any phosphate species are missing from the model
    Severity: Minor
    Found in wc_model_gen/prokaryote/metabolism.py - About 1 hr 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 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def gen_reactions(self):
            """ Generate reactions assocated with min model
    
            Raises:
                :obj:`ValueError:` if any phosphate species are missing from the model
    Severity: Minor
    Found in wc_model_gen/prokaryote/metabolism.py - About 1 hr to fix

      Function calc_gtp_per_translate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def calc_gtp_per_translate(self):
              """ Calculates the average GTP needed for a translation reaction """
              submodel = self.model.submodels.get_one(id='translation')
      
              gtp_per_translation = []
      Severity: Minor
      Found in wc_model_gen/prokaryote/metabolism.py - About 25 mins 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 calc_h_per_transcript has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def calc_h_per_transcript(self):
              """ Calculates the average H needed for a transcription reaction """
              submodel = self.model.submodels.get_one(id='transcription')
      
              h_per_transcript = []
      Severity: Minor
      Found in wc_model_gen/prokaryote/metabolism.py - About 25 mins 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

          def calc_rna_copy_num(self):
              """ Calculates the # of RNA molecules at t=0 """
      
              volume = self.knowledge_base.cell.parameters.get_one(id='mean_volume').value
              cytosol_kb = self.knowledge_base.cell.compartments.get_one(id='c')
      Severity: Major
      Found in wc_model_gen/prokaryote/metabolism.py and 1 other location - About 1 day to fix
      wc_model_gen/prokaryote/metabolism.py on lines 405..420

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

      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

          def calc_prot_copy_num(self):
              """ Calculates the # of RNA molecules at t=0 """
              # TODO: check if conc is in CN already
      
              volume = self.knowledge_base.cell.parameters.get_one(id='mean_volume').value
      Severity: Major
      Found in wc_model_gen/prokaryote/metabolism.py and 1 other location - About 1 day to fix
      wc_model_gen/prokaryote/metabolism.py on lines 389..403

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

      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

          def calc_aa_transfer_rate(self):
              """ Calculates the rate of monophosphate transfer from the extracellular space """
      
              # Calculate # of new AA molecules needed = # of AA molecules tied up in prots at t=0
              avg_aa_per_prot = self.calc_aa_per_prot()
      Severity: Major
      Found in wc_model_gen/prokaryote/metabolism.py and 1 other location - About 7 hrs to fix
      wc_model_gen/prokaryote/metabolism.py on lines 226..239

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

      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

          def calc_mpp_transfer_rate(self):
              """ Calculates the rate of monophosphate transfer from the extracellular space """
      
              # Calculate # of new TPP molecules needed = # of TPP molecules tied up in RNAs at T=0
              avg_tpp_per_rna = self.calc_tpp_per_rna()
      Severity: Major
      Found in wc_model_gen/prokaryote/metabolism.py and 1 other location - About 7 hrs to fix
      wc_model_gen/prokaryote/metabolism.py on lines 241..254

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

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

                  param = model.parameters.create(id='k_cat_{}'.format(rxn.id),
                                                  type=wc_ontology['WC:k_cat'],
                                                  units=unit_registry.parse_units('s^-1'))
      Severity: Major
      Found in wc_model_gen/prokaryote/metabolism.py and 4 other locations - About 1 hr to fix
      wc_model_gen/eukaryote/complexation.py on lines 325..327
      wc_model_gen/eukaryote/transcription.py on lines 1050..1053
      wc_model_gen/eukaryote/translation_translocation.py on lines 980..983
      wc_model_gen/eukaryote/translation_translocation.py on lines 1056..1059

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

      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 id in ['udp', 'adp', 'cdp', 'gdp']:
                  dpps[id] = model.species_types.get_one(id=id)
      Severity: Minor
      Found in wc_model_gen/prokaryote/metabolism.py and 2 other locations - About 30 mins to fix
      wc_model_gen/prokaryote/metabolism.py on lines 51..52
      wc_model_gen/prokaryote/metabolism.py on lines 59..60

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

      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 id in ['ump', 'amp', 'cmp', 'gmp']:
                  mpps[id] = model.species_types.get_one(id=id)
      Severity: Minor
      Found in wc_model_gen/prokaryote/metabolism.py and 2 other locations - About 30 mins to fix
      wc_model_gen/prokaryote/metabolism.py on lines 55..56
      wc_model_gen/prokaryote/metabolism.py on lines 59..60

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

      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 id in ['utp', 'atp', 'ctp', 'gtp']:
                  tpps[id] = model.species_types.get_one(id=id)
      Severity: Minor
      Found in wc_model_gen/prokaryote/metabolism.py and 2 other locations - About 30 mins to fix
      wc_model_gen/prokaryote/metabolism.py on lines 51..52
      wc_model_gen/prokaryote/metabolism.py on lines 55..56

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

      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