KarrLab/wc_model_gen

View on GitHub

Showing 120 of 341 total issues

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

        def gen_species_type(self, kb_species_type, extra_compartment_ids=None):
            """ Generate a model species type
    
            Args:
                kb_species_type (:obj:`wc_kb.SpeciesType`): knowledge base species type
    Severity: Minor
    Found in wc_model_gen/prokaryote/initalize_model.py - About 55 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 calibrate_submodel has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def calibrate_submodel(self):
            """ Calibrate the submodel using data in the KB """
            model = self.model
            beta = self.options.get('beta')
    
    
    Severity: Minor
    Found in wc_model_gen/prokaryote/translation.py - About 55 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

    Avoid deeply nested control flow statements.
    Open

                            if add_transcript in rna_input_seq:
                                seq = rna_input_seq[add_transcript]
                            else:
                                seq = cell.species_types.get_one(id=add_transcript).get_seq()    
                            add_count = gvar.transcript_ntp_usage[add_transcript] = {
    Severity: Major
    Found in wc_model_gen/eukaryote/transcription.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if model.distribution_init_concentrations.get_one(species=participant.species).mean <= \
                                  subunit_equilibrium_level[participant.species]:
                                  if reaction not in for_removal:
                                      for_removal.append(reaction)
                  
      Severity: Major
      Found in wc_model_gen/eukaryote/complexation.py - About 45 mins 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

                                  for kcat in law.expression.parameters:                                                     
                                      kcat.value = kcat.value*value/effective_vmax
                                      kcat.comments = 'Measured value adjusted to relax bound'
                          elif all(numpy.isnan(kcat.value) for kcat in law.expression.parameters):
          Severity: Major
          Found in wc_model_gen/eukaryote/metabolism.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if comp.distribution_init_concentration.mean!=0.0:
                                        kcat.value = shared_vmax/comp.distribution_init_concentration.mean*\
                                            kcat_adjustment_factor                                    
                                        kcat.comments = 'Value imputed based on FVA bound value ' +\
                                            'and adjusted with a factor of {}'.format(kcat_adjustment_factor) 
            Severity: Major
            Found in wc_model_gen/eukaryote/metabolism.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if aa_coefficient:
                                          old_coef = aa_coefficient.coefficient
                                          el_reaction.participants.remove(aa_coefficient)
                                          el_reaction.participants.add(
                                              aa_species.species_coefficients.get_or_create(
              Severity: Major
              Found in wc_model_gen/eukaryote/translation_translocation.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if aa_functions[translation_compartment.id][aa_met][
                                            'function'].id not in expression_terms:
                                            
                                            expression_terms.append(aa_functions[translation_compartment.id][
                                                aa_met]['function'].id)
                Severity: Major
                Found in wc_model_gen/eukaryote/translation_translocation.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          for part in prot_deg_reaction.participants:
                                              if part.species.id in met_requirement:
                                                  met_requirement[part.species.id] += -part.coefficient * prot_concentration * \
                                                      doubling_time / prot_half_life
                  
                  
                  Severity: Major
                  Found in wc_model_gen/eukaryote/metabolism.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if translation_compartment.id == 'c':    
                                                matched_trnas = [trna_functions[translation_compartment.id][i]]
                                            else:
                                                if i in trna_functions[translation_compartment.id]:
                                                    matched_trnas = [trna_functions[translation_compartment.id][i]]
                    Severity: Major
                    Found in wc_model_gen/eukaryote/translation_translocation.py - About 45 mins to fix

                      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!='*')
                      Severity: Major
                      Found in wc_model_gen/eukaryote/initialize_model.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                for comp, kcat in comp_kcat.items():                            
                                                    if comp.distribution_init_concentration.mean!=0.0:
                                                        kcat.value = shared_vmax/comp.distribution_init_concentration.mean*\
                                                            kcat_adjustment_factor
                                                        kcat.comments = 'Value imputed based on FVA bound value ' +\
                        Severity: Major
                        Found in wc_model_gen/eukaryote/metabolism.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if trna_obs not in self._modifiers:
                                                      self._modifiers.append(trna_obs)
                                                  trna = trna_obs.expression.species.get_one(compartment=cytosol)
                          Severity: Major
                          Found in wc_model_gen/prokaryote/translation.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 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))
                              Severity: Major
                              Found in wc_model_gen/eukaryote/initialize_model.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                        if model_compl_species.distribution_init_concentration:
                                                            param.value = self._effective_dissociation_constant['{}[{}]'.format(
                                                                complex_st_id, compl_compartment_id)] * model_compl_species.distribution_init_concentration.mean
                                                        else:
                                                            param.value = self._effective_dissociation_constant['{}[{}]'.format(
                                Severity: Major
                                Found in wc_model_gen/eukaryote/complexation.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                          for part in translocation_reaction.participants:
                                                              if part.species.id in met_requirement:
                                                                  met_requirement[part.species.id] += -part.coefficient * prot_concentration * \
                                                                      (1 + doubling_time / prot_half_life)
                                                      
                                  Severity: Major
                                  Found in wc_model_gen/eukaryote/metabolism.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                            if numpy.isnan(kcat.value):
                                                                kcat.value = median_kcat
                                                                kcat.comments = 'Value imputed as the median of measured k_cat values'         
                                                    elif not any(numpy.isnan(kcat.value) for kcat in law.expression.parameters):
                                    Severity: Major
                                    Found in wc_model_gen/eukaryote/metabolism.py - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language