KarrLab/intro_to_wc_modeling

View on GitHub

Showing 42 of 135 total issues

File mrna_and_proteins_using_several_methods.py has 743 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" Stochastic simulation tutorial

:Author: Jonathan Karr <jonrkarr@gmail.com>
:Date: 2017-08-30
:Copyright: 2017, Karr Lab

    File model.py has 671 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    '''
    Reads models specified in Excel into a Python object
    
    @author Jonathan Karr, karr@mssm.edu
    @date 3/22/2016

      File model_composition.py has 614 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """ Model composition tutorial
      
      - Glycolysis model (Teusink et al., 2000)
      - Glycerol synthesis model (Cronwright et al., 2002)
      
      
      Severity: Major
      Found in intro_to_wc_modeling/cell_modeling/model_composition.py - About 1 day to fix

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

        def getModelFromExcel(filename):
            # Reads model from Excel file into a Python object
        
            with warnings.catch_warnings():
                warnings.filterwarnings("ignore", "Discarded range with reserved name", UserWarning)

        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

        GlycolysisModel has 35 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class GlycolysisModel(object):
            """ Glycolysis model (Teusink et al., 2000)
        
            Based on the `version from JWS Online <http://jjj.biochem.sun.ac.za/models/teusink/>`_
        
        
        Severity: Minor
        Found in intro_to_wc_modeling/cell_modeling/model_composition.py - About 4 hrs to fix

          Function simulate has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
          Open

          def simulate(mdl):
              # simulates model
          
              # Get metabolism submodel
              submdl = mdl.getComponentById('Metabolism')

          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 simulate has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

          def simulate(mdl):
              # simulates model
          
              # Get FBA, SSA submodels
              ssaSubmodels = []

          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 main has 69 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def main(examples_dir=os.path.join(os.path.dirname(__file__), 'examples')):
          
              ################################################################
              # This code is used by literalinclude commands in wc_lang_tutorial.rst
              # It contains many separate examples, each prefixed by a comment that delineates the
          Severity: Major
          Found in intro_to_wc_modeling/wc_modeling/wc_lang_tutorial/core.py - About 2 hrs to fix

            Function setupSimulation has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

                def setupSimulation(self):
                    '''setup reaction participant, enzyme counts matrices'''
                    Submodel.setupSimulation(self)
            
                    '''Setup FBA'''

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

                def run(self, value_init=5, time_max=10):
                    """ Runs a simulation for `time_max` seconds starting with `value_init` molecules
            
                    Args:
                        value_init (:obj:`float`, optional): initial number of species

            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 dp_dt has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def dp_dt(self, p_part_vec):
                    """ Calculate the time derivative of the probability of each (mRNA, protein) state
            
                    Args:
                        p_part_vec (:obj:`numpy.array`): vector of probability of each (mRNA, protein) state (dimensionless)

            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 get_steady_state has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_steady_state(self):
                    """ Calculate the steady state probability distribution
            
                    Returns:
                        :obj:`numpy.array`: steay-state probability of each (mRNA, protein) state (dimensionless)

            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 main has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def main():
                # seed random number generator
                numpy.random.seed(0)
            
                # simulate
            Severity: Minor
            Found in intro_to_wc_modeling/cell_modeling/simulation/boolean.py - About 1 hr to fix

              Function main has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              def main():
                  # create a figure with 2x1 subplots
                  fig, axes = pyplot.subplots(nrows=2, ncols=1)
              
                  # plot data on the subplots

                Function main has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                def main(init_concs=None):
                    """ Run dFBA simsulation, plot results, and save plots
                
                    Args:
                        init_concs (:obj:`dict`, optional): initial concentrations
                Severity: Minor
                Found in intro_to_wc_modeling/cell_modeling/simulation/dfba.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 main has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                def main(init_concs=None):
                    """ Run dFBA simsulation, plot results, and save plots
                
                    Args:
                        init_concs (:obj:`dict`, optional): initial concentrations
                Severity: Minor
                Found in intro_to_wc_modeling/cell_modeling/simulation/dfba.py - About 1 hr to fix

                  Function __init__ has 11 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def __init__(self, id='', name='', submodel='', reversible=None, participants=[],

                    Function main has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    def main(out_dir=None):
                        """ Simulate individual models and combined model, plot results, and save plots
                    
                        Args:
                            out_dir (:obj:`str`, optional): path to directory to save results
                    Severity: Minor
                    Found in intro_to_wc_modeling/cell_modeling/model_composition.py - About 1 hr to fix

                      Function insert_records has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      def insert_records(session):
                          # create homo sapiens organism with one reaction
                          organism = Organism(ncbi_id=9606, name='Homo sapiens')
                          session.add(organism)
                      
                      

                        Function __init__ has 10 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def __init__(self, id='', name='', structure='', empiricalFormula='', molecularWeight=None,
                          Severity
                          Category
                          Status
                          Source
                          Language