KarrLab/wc_kb_gen

View on GitHub

Showing 16 of 32 total issues

Function gen_tus has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
Open

    def gen_tus(self):
        """ Creates transcription units with 5'/3' UTRs, polycistronic mRNAs, and other types of RNA (tRNA, rRNA, sRNA) """

        options = self.options
        five_prime_len = options.get('five_prime_len') # 7 bp default (E. coli, wikipedia)
Severity: Minor
Found in wc_kb_gen/random/genome.py - About 1 day 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_genome has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    def gen_genome(self):
        '''Construct knowledge base components and generate the DNA sequence'''

        # get options
        options = self.options
Severity: Minor
Found in wc_kb_gen/random/genome.py - About 5 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 genome.py has 372 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
:Author: Ashwin Srinivasan <ashwins@mit.edu>
:Author: Bilal Shaikh <bilal.shaikh@columbia.edu>
:Author: Balazs Szigeti <balazs.szigeti@mssm.edu>
:Date: 2018-06-06
Severity: Minor
Found in wc_kb_gen/random/genome.py - About 4 hrs to fix

    Function gen_rnas_proteins has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def gen_rnas_proteins(self):
            """ Creates RNA and protein objects corresponding to genes on chromosome. """
    
            cell = self.knowledge_base.cell
            options = self.options
    Severity: Minor
    Found in wc_kb_gen/random/genome.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

    Function clean_and_validate_options has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def clean_and_validate_options(self):
            """ Apply default options and validate options """
    
            # Default options are loosely  based on Escherichia coli K-12
            # Nucleic Acids Research 41:D605-12 2013
    Severity: Major
    Found in wc_kb_gen/random/genome.py - About 2 hrs to fix

      Function gen_components has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def gen_components(self):
              """ Takes random samples of the generated rnas and proteins and assigns them functions based on the included list of proteins and rnas"""
      
              cell = self.knowledge_base.cell
              cytosol = cell.compartments.get_one(id='c')
      Severity: Minor
      Found in wc_kb_gen/random/observables.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_genome has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def gen_genome(self):
              '''Construct knowledge base components and generate the DNA sequence'''
      
              # get options
              options = self.options
      Severity: Minor
      Found in wc_kb_gen/random/genome.py - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                                for gene in tu.genes:
                                    # creates ProteinSpecipe object for corresponding protein sequence(s)
                                    prot = self.knowledge_base.cell.species_types.get_or_create(
                                        id='prot_{}'.format(gene.id),
                                        __type=wc_kb.prokaryote.ProteinSpeciesType)
        Severity: Major
        Found in wc_kb_gen/random/genome.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if five_prime_start < 0:
                                      five_prime_start = 0
                                  tu.genes.append(gene)
          Severity: Major
          Found in wc_kb_gen/random/genome.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    while seq_str[i:i+3] in START_CODONS or seq_str[i:i+3] in STOP_CODONS:
            
                                        if genetic_code == 'normal':
                                            codon_i = "".join(random.choice(BASES, p=PROB_BASES, size=(3,)))
                                        elif genetic_code == 'reduced':
            Severity: Major
            Found in wc_kb_gen/random/genome.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if three_prime_end >= len(seq):
                                          three_prime_end = len(seq) - 1
                                      tu.end = three_prime_end
              Severity: Major
              Found in wc_kb_gen/random/genome.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if three_prime_end >= len(seq):
                                            three_prime_end = len(seq) - 1
                
                
                Severity: Major
                Found in wc_kb_gen/random/genome.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if five_prime_start < 0:
                                              five_prime_start = 0
                                          if three_prime_end >= len(seq):
                  Severity: Major
                  Found in wc_kb_gen/random/genome.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            for k in range(operon_genes-1):
                                                i_gene += 1
                    
                                                if i_gene >= len(chromosome.loci):
                                                    break
                    Severity: Major
                    Found in wc_kb_gen/random/genome.py - About 45 mins to fix

                      Function reduce_model has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def reduce_model(self):
                              options = self.options
                              genetic_code = options.get('genetic_code')
                              seq_path = options.get('seq_path')
                      
                      
                      Severity: Minor
                      Found in wc_kb_gen/random/genome.py - About 35 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 clean_and_validate_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def clean_and_validate_options(self):
                              """ Apply default options and validate options """
                              options = self.options
                      
                              id = options.get('id', 'rand_wc_model')
                      Severity: Minor
                      Found in wc_kb_gen/random/core.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

                      Severity
                      Category
                      Status
                      Source
                      Language