KarrLab/rand_wc_model_gen

View on GitHub

Showing 46 of 46 total issues

File core.py has 819 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" Classes to generate random wc models

:Author: Mike Zheng <xzheng20@colby.edu>
:Author: Jonathan Karr <karr@mssm.edu>
:Date: 2019-08-13
Severity: Major
Found in rand_wc_model_gen/model_gen/core.py - About 1 day to fix

    Function run has 268 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def run(self):
            """ Generate a :obj:`wc_lang` model
    
            Returns:
                :obj:`wc_lang.Model`: model
    Severity: Major
    Found in rand_wc_model_gen/model_gen/core.py - About 1 day to fix

      Function gen_tus has a Cognitive Complexity of 57 (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)
      
              """
      
      
      Severity: Minor
      Found in rand_wc_model_gen/kb_gen/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

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

              for rna in sampled_trnas:
                  rna_name = next(assigned_trnas)
                  rna.id = rna_name
                  rna.name = rna_name
                  observable = cell.observables.get_or_create(id=rna_name+'_obs')
      Severity: Major
      Found in rand_wc_model_gen/kb_gen/observables.py and 1 other location - About 6 hrs to fix
      rand_wc_model_gen/kb_gen/observables.py on lines 103..111

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

      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 in sampled_proteins:
                  protein_name = next(assigned_proteins)
                  protein.id = protein_name
                  protein.name = protein_name
                  observable = cell.observables.get_or_create(id=protein_name+'_obs')
      Severity: Major
      Found in rand_wc_model_gen/kb_gen/observables.py and 1 other location - About 6 hrs to fix
      rand_wc_model_gen/kb_gen/observables.py on lines 88..97

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

      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

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

                  gene_starts = numpy.int64(numpy.cumsum(numpy.concatenate(([0], gene_lens[0:-1])) +
                                                         numpy.concatenate((numpy.round(intergene_lens[0:1] / 2), intergene_lens[1:]))))
      Severity: Major
      Found in rand_wc_model_gen/kb_gen/genome.py and 1 other location - About 4 hrs to fix
      rand_wc_model_gen/kb_gen/chrs_genes_tus.py on lines 91..92

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

      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

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

                  gene_starts = numpy.int64(numpy.cumsum(numpy.concatenate(([0], gene_lens[0:-1])) +
                                                         numpy.concatenate((numpy.round(intergene_lens[0:1] / 2), intergene_lens[1:]))))
      Severity: Major
      Found in rand_wc_model_gen/kb_gen/chrs_genes_tus.py and 1 other location - About 4 hrs to fix
      rand_wc_model_gen/kb_gen/genome.py on lines 210..211

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

      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

              if not os.path.isdir(os.path.dirname(config['kb']['path']['seq'])):
                  os.makedirs(os.path.dirname(config['kb']['path']['seq']))
      Severity: Major
      Found in rand_wc_model_gen/__main__.py and 1 other location - About 4 hrs to fix
      rand_wc_model_gen/__main__.py on lines 63..64

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

      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

              if not os.path.isdir(os.path.dirname(config['kb']['path']['core'])):
                  os.makedirs(os.path.dirname(config['kb']['path']['core']))
      Severity: Major
      Found in rand_wc_model_gen/__main__.py and 1 other location - About 4 hrs to fix
      rand_wc_model_gen/__main__.py on lines 65..66

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

      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 genome.py has 303 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """
      :Author: Ashwin Srinivasan <ashwins@mit.edu>
      :Author: Bilal Shaikh <bilal.shaikh@columbia.edu>
      :Date: 2018-06-06
      :Copyright: 2018, Karr Lab
      Severity: Minor
      Found in rand_wc_model_gen/kb_gen/genome.py - About 3 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
        Severity: Minor
        Found in rand_wc_model_gen/kb_gen/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 gen_reactions has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            def gen_reactions(self, model, options):
                """ Generate reactions and rate laws of the random model
        
                Args:
                    model (:obj:`wc_lang.Model`): model
        Severity: Minor
        Found in rand_wc_model_gen/model_gen/core.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_genome has a Cognitive Complexity of 18 (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 rand_wc_model_gen/kb_gen/genome.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 clean_and_validate_options has 53 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 rand_wc_model_gen/kb_gen/genome.py - About 2 hrs to fix

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

              class Meta:
                  label = 'analyze'
                  stacked_on = 'base'
                  stacked_type = 'nested'
                  description = "Analyze a random whole-cell model and simulations"
          Severity: Major
          Found in rand_wc_model_gen/__main__.py and 1 other location - About 2 hrs to fix
          rand_wc_model_gen/__main__.py on lines 44..51

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

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

              def gen_species(self, model, options, misc_options):
                  """ Generate species type, species, and init concentrations of the random model
          
                  Args:
                      model (:obj:`wc_lang.Model`): model
          Severity: Minor
          Found in rand_wc_model_gen/model_gen/core.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

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

              class Meta:
                  label = 'generate'
                  stacked_on = 'base'
                  stacked_type = 'nested'
                  description = "Generate a random whole-cell knowledge base and a random whole-cell model"
          Severity: Major
          Found in rand_wc_model_gen/__main__.py and 1 other location - About 2 hrs to fix
          rand_wc_model_gen/__main__.py on lines 116..123

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

          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

                                  tu = self.knowledge_base.cell.loci.get_or_create(
                                      id='tu_{}_{}'.format(i_chr + 1, i_gene + 1), __type=wc_kb.prokaryote.TranscriptionUnitLocus)
          Severity: Major
          Found in rand_wc_model_gen/kb_gen/genome.py and 3 other locations - About 1 hr to fix
          rand_wc_model_gen/kb_gen/genome.py on lines 215..216
          rand_wc_model_gen/kb_gen/genome.py on lines 395..396
          rand_wc_model_gen/kb_gen/genome.py on lines 406..407

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

          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

                                  tu = self.knowledge_base.cell.loci.get_or_create(
                                      id='tu_{}_{}'.format(i_chr + 1, i_gene + 1), __type=wc_kb.prokaryote.TranscriptionUnitLocus)
          Severity: Major
          Found in rand_wc_model_gen/kb_gen/genome.py and 3 other locations - About 1 hr to fix
          rand_wc_model_gen/kb_gen/genome.py on lines 215..216
          rand_wc_model_gen/kb_gen/genome.py on lines 355..356
          rand_wc_model_gen/kb_gen/genome.py on lines 406..407

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

          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

                          gene = self.knowledge_base.cell.loci.get_or_create(
                              id='gene_{}_{}'.format(i_chr + 1, i_gene + 1), __type=wc_kb.prokaryote.GeneLocus)
          Severity: Major
          Found in rand_wc_model_gen/kb_gen/genome.py and 3 other locations - About 1 hr to fix
          rand_wc_model_gen/kb_gen/genome.py on lines 355..356
          rand_wc_model_gen/kb_gen/genome.py on lines 395..396
          rand_wc_model_gen/kb_gen/genome.py on lines 406..407

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

          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