KarrLab/datanator

View on GitHub
datanator/data_source/gene_ortholog.py

Summary

Maintainability
D
2 days
Test Coverage
F
29%

Function parse_html has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_html(self, soup):
        """Parse out gene_orthologs from HTML 
        (https://www.kegg.jp/ssdb-bin/ssdb_best?org_gene=aly:ARALYDRAFT_486312).
        
        Args:
Severity: Minor
Found in datanator/data_source/gene_ortholog.py - About 4 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 load_data has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def load_data(self, skip=0, top_hits=10):
        """Loading data.
        
        Args:
            skip (:obj:`int`, optional): Beginning of the documents. Defaults to 0.
Severity: Minor
Found in datanator/data_source/gene_ortholog.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 __init__ has 10 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, server, src_db='datanator', des_db='datanator', collection_str='uniprot',
Severity: Major
Found in datanator/data_source/gene_ortholog.py - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

                            if doc is not None:
                                uniprot_id.append(doc)
                yield {'org_gene': org_gene_str,
    Severity: Major
    Found in datanator/data_source/gene_ortholog.py - About 45 mins to fix

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

                          for protein in proteins:
                              self.uniprot_nosql_manager.load_uniprot(query=True, msg=protein.split('.')[0], species=[ncbi_id])
                              doc = self.uniprot_manager.get_info_by_entrez_id(org_gene_str.split(':')[1])
                              if doc is not None:
                                  uniprot_id.append(doc)
      Severity: Major
      Found in datanator/data_source/gene_ortholog.py and 1 other location - About 4 hrs to fix
      datanator/data_source/gene_ortholog.py on lines 83..87

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

      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 isinstance(proteins, str):
                          self.uniprot_nosql_manager.load_uniprot(query=True, msg=proteins.split('.')[0], species=[ncbi_id])
                          doc = self.uniprot_manager.get_info_by_entrez_id(org_gene_str.split(':')[1])
                          if doc is not None:
                              uniprot_id.append(doc)                    
      Severity: Major
      Found in datanator/data_source/gene_ortholog.py and 1 other location - About 4 hrs to fix
      datanator/data_source/gene_ortholog.py on lines 89..93

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

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

                  if i % 50 == 0 and self.verbose:
                      print('Processing document {} out of {} ...'.format(i+skip, count))
      Severity: Major
      Found in datanator/data_source/gene_ortholog.py and 8 other locations - About 1 hr to fix
      datanator/data_source/metabolites_meta_collection.py on lines 173..174
      datanator/data_source/sabio_reaction.py on lines 170..171
      datanator/data_source/sabio_reaction.py on lines 198..199
      datanator/data_source/uniprot_nosql.py on lines 147..148
      datanator/data_source/uniprot_nosql.py on lines 162..163
      datanator/data_source/uniprot_nosql.py on lines 234..235
      datanator/data_source/uniprot_nosql.py on lines 269..270
      datanator/data_source/uniprot_nosql.py on lines 304..305

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

      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

              self.kegg_manager = query_kegg_orthology.QueryKO(username=username, password=password, server=server,
      Severity: Major
      Found in datanator/data_source/gene_ortholog.py and 2 other locations - About 50 mins to fix
      datanator/data_source/gene_ortholog.py on lines 30..30
      datanator/data_source/rna_halflife/back_fill_gene_name.py on lines 12..12

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

      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

              self.protein_manager = query_protein.QueryProtein(username=username, password=password, server=server,
      Severity: Major
      Found in datanator/data_source/gene_ortholog.py and 2 other locations - About 50 mins to fix
      datanator/data_source/gene_ortholog.py on lines 28..28
      datanator/data_source/rna_halflife/back_fill_gene_name.py on lines 12..12

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

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

              super().__init__(MongoDB=server, db=des_db, verbose=verbose, max_entries=max_entries,
      Severity: Major
      Found in datanator/data_source/gene_ortholog.py and 5 other locations - About 40 mins to fix
      datanator/data_source/brenda/reaction.py on lines 13..13
      datanator/data_source/ec.py on lines 14..14
      datanator/data_source/rna_halflife/back_fill_gene_name.py on lines 9..9
      datanator/elasticsearch_kl/batch_load.py on lines 26..26
      datanator/util/rna_halflife_util.py on lines 15..15

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

      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

              self.uniprot_nosql_manager = uniprot_nosql.UniprotNoSQL(MongoDB=server, db=des_db, max_entries=max_entries,
      Severity: Major
      Found in datanator/data_source/gene_ortholog.py and 3 other locations - About 35 mins to fix
      datanator/data_source/protein_aggregate.py on lines 29..29
      datanator/data_source/rna_halflife/back_fill_gene_name.py on lines 14..14
      datanator/util/rna_halflife_util.py on lines 25..25

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

      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