KarrLab/datanator

View on GitHub
datanator/data_source/metabolites_meta_collection.py

Summary

Maintainability
F
5 days
Test Coverage
F
37%

Function fill_standard_id has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def fill_standard_id(self, skip=0):
        """Fill meta collection with chebi_id, pubmed_id,
        and kegg_id.

        Args:
Severity: Minor
Found in datanator/data_source/metabolites_meta_collection.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 reset_cellular_locations has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def reset_cellular_locations(self, start=0):
        """Github (https://github.com/KarrLab/datanator_rest_api/issues/69)
        """
        query = {'cellular_locations': {'$ne': None}}
        count = self.collection.count_documents(query) - start
Severity: Minor
Found in datanator/data_source/metabolites_meta_collection.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, cache_dirname=None, MongoDB=None, replicaSet=None, db=None,
Severity: Major
Found in datanator/data_source/metabolites_meta_collection.py - About 1 hr to fix

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

        def fill_metabolite_fields(self, fields=None, collection_src=None, collection_des = None):
            '''Fill in values of fields of interest from 
                metabolite collection: ecmdb or ymdb
                    Args:
                            fileds: list of fields of interest
    Severity: Minor
    Found in datanator/data_source/metabolites_meta_collection.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 fill_names has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def fill_names(self):
            """Fill names of metabolites in 'name' field
            """
            docs = self.collection.find({})
            count = self.collection.count_documents({})
    Severity: Minor
    Found in datanator/data_source/metabolites_meta_collection.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 replace_key_in_similar_compounds has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def replace_key_in_similar_compounds(self):
            query = {}
            projection = {'similar_compounds': 1}
            _, _, col = self.con_db('metabolites_meta')
            docs = col.find(filter=query, projection=projection)
    Severity: Minor
    Found in datanator/data_source/metabolites_meta_collection.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

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

                elif m2m_id is not None:
                    doc_y = self.ecmdb_query.get_standard_ids_by_id(m2m_id)
                    if doc_y['synonyms']:
                        synonyms = doc_y['synonyms']['synonym']
                    else:
    Severity: Major
    Found in datanator/data_source/metabolites_meta_collection.py and 1 other location - About 1 day to fix
    datanator/data_source/metabolites_meta_collection.py on lines 179..201

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

    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 ymdb_id is not None: # ymdb has richer data than ecmdb
                    doc_e = self.ymdb_query.get_standard_ids_by_id(ymdb_id)
                    if doc_e['synonyms']:
                        synonyms = doc_e['synonyms']['synonym']
                    else:
    Severity: Major
    Found in datanator/data_source/metabolites_meta_collection.py and 1 other location - About 1 day to fix
    datanator/data_source/metabolites_meta_collection.py on lines 202..224

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

    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 doc.get('ymdb_id'):
                    for loc in cell_locations:
                        location = loc['cellular_location']['cellular_location']
                        obj.append({
                                    'reference': ['YMDB'],
    Severity: Major
    Found in datanator/data_source/metabolites_meta_collection.py and 1 other location - About 1 hr to fix
    datanator/data_source/metabolites_meta_collection.py on lines 251..264

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

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

            super(MetabolitesMeta, self).__init__(cache_dirname=cache_dirname, MongoDB=MongoDB, replicaSet=replicaSet,
    Severity: Major
    Found in datanator/data_source/metabolites_meta_collection.py and 6 other locations - About 1 hr to fix
    datanator/data_source/corum_nosql.py on lines 26..26
    datanator/data_source/intact_nosql.py on lines 23..23
    datanator/data_source/kegg_orthology.py on lines 26..26
    datanator/data_source/pax_nosql.py on lines 25..25
    datanator/data_source/taxon_tree.py on lines 27..27
    datanator/util/index_collection.py on lines 19..19

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

    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 % 100 == 0 and self.verbose:
                    print('Processing doc {} out of {}'.format(i+skip, count))
    Severity: Major
    Found in datanator/data_source/metabolites_meta_collection.py and 8 other locations - About 1 hr to fix
    datanator/data_source/gene_ortholog.py on lines 162..163
    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.collection.update_one({'_id': doc['_id']},
                                            {'$set': {'name': name}}, upsert=False)
    Severity: Major
    Found in datanator/data_source/metabolites_meta_collection.py and 2 other locations - About 40 mins to fix
    datanator/data_source/metabolites_meta_collection.py on lines 267..268
    datanator/data_source/uniprot_nosql.py on lines 308..309

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

                self.collection.update_one({'_id': doc['_id']},
                                           {'$set': {'cellular_locations': obj}},
    Severity: Major
    Found in datanator/data_source/metabolites_meta_collection.py and 2 other locations - About 40 mins to fix
    datanator/data_source/metabolites_meta_collection.py on lines 155..156
    datanator/data_source/uniprot_nosql.py on lines 308..309

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

                if i % 100 == 0 and self.verbose:
                    print('Adding name to document {} out of {}.'.format(i, count))
    Severity: Major
    Found in datanator/data_source/metabolites_meta_collection.py and 13 other locations - About 35 mins to fix
    datanator/data_source/metabolite_concentration/doi_10_1038_nchembio_2077.py on lines 246..247
    datanator/data_source/metabolite_concentration/doi_10_1038_nchembio_2077.py on lines 307..308
    datanator/data_source/rna_halflife/doi_10_1016_j_cell_2013_12_026.py on lines 48..49
    datanator/data_source/rna_halflife/doi_10_1038_srep01318.py on lines 49..50
    datanator/data_source/rna_halflife/doi_10_1091_mbc_e11_01_0028.py on lines 54..55
    datanator/data_source/rna_halflife/doi_10_1093_nar_gks1019.py on lines 58..59
    datanator/data_source/rna_halflife/doi_10_1093_nar_gks1019.py on lines 75..76
    datanator/data_source/rna_halflife/doi_10_1093_nar_gkt1150.py on lines 49..50
    datanator/data_source/rna_halflife/doi_10_1101_gr_131037_111.py on lines 72..73
    datanator/data_source/rna_halflife/doi_10_1186_gb_2012_13_4_r30.py on lines 61..62
    datanator/data_source/rna_halflife/doi_10_1371_journal_pone_0059059.py on lines 57..58
    datanator/data_source/rna_modification/rna_modification.py on lines 40..41
    datanator/data_source/rna_modification/rna_modification.py on lines 69..70

    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

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

                if self.verbose and i % 100 == 0:
                    print('Processing doc {} out of {} ...'.format(i, count))
    Severity: Major
    Found in datanator/data_source/metabolites_meta_collection.py and 5 other locations - About 35 mins to fix
    datanator/data_source/metabolite_concentration/doi_10_1038_nchembio_2077.py on lines 51..52
    datanator/data_source/metabolite_concentration/doi_10_1038_nchembio_2077.py on lines 117..118
    datanator/data_source/metabolite_concentration/doi_10_1038_nchembio_2077.py on lines 343..344
    datanator/data_source/protein_aggregate.py on lines 126..127
    datanator/data_source/sabio_compound.py on lines 39..40

    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

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

            self.ymdb_query = query_xmdb.QueryXmdb(username=username, password=password, server=MongoDB, authSource=authSource,
    Severity: Minor
    Found in datanator/data_source/metabolites_meta_collection.py and 1 other location - About 35 mins to fix
    datanator/data_source/metabolites_meta_collection.py on lines 35..35

    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

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

            self.ecmdb_query = query_xmdb.QueryXmdb(username=username, password=password, server=MongoDB, authSource=authSource,
    Severity: Minor
    Found in datanator/data_source/metabolites_meta_collection.py and 1 other location - About 35 mins to fix
    datanator/data_source/metabolites_meta_collection.py on lines 33..33

    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