KarrLab/datanator

View on GitHub
datanator/data_source/metabolite_concentration/doi_10_1038_nchembio_2077.py

Summary

Maintainability
F
6 days
Test Coverage
F
22%

File doi_10_1038_nchembio_2077.py has 347 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import pandas as pd
import datetime
from datanator_query_python.query import query_metabolites_meta
from collections import deque
import datanator.config.core

    Function add_reference_eymdb has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_reference_eymdb(self, start=0):
            """(https://github.com/KarrLab/datanator_rest_api/issues/77)
            """
            query = {}
            projection = {"concentrations": 1, "inchikey": 1}

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

        def edit_nchembio2077(self, start=0):
            """Resolve https://github.com/KarrLab/datanator_rest_api/issues/73
            """
            con_0 = {"concentrations.reference.doi": "10.1038/nchembio.2077"}
            con_1 = {"metabolite": {"$ne": "UDP-D-glucose"}}

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

        def _flatten_conc_obj(self, obj, ncbi_id, species_name, _id, source='ECMDB'):
            """Flatten concentrations object in ec/ymdb.
    
            Args:
                obj(:obj:`Obj`): concentrations object.

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

        def fill_gerosa_collection(self, file_location, sheet_name='Sheet1', start_row=0,
                                    use_columns='A:E,G', column_names=['EC_Number', 'metabolite',
                                    'concentration', 'k_m', 'abbreviation', 'species_name'],
                                    reference={'doi': '10.1038/nchembio.2077'}, unit='M',
                                    nrows=None):

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

        def grab_eymdb(self, start=0):
            """Fill collection with concentration values from ec/ymdb.
            Documents in current collection all have inchikey
            """
            query = {'concentrations': {'$ne': None}}

    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 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, MongoDB=None, db=None, collection_str=None, username=None,

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

          def fill_collection(self, file_location, sheet_name='Sheet1', start_row=0,
                              use_columns='A:E,G', column_names=['EC_Number', 'metabolite',
                              'concentration', 'k_m', 'abbreviation', 'species_name'],
                              reference={'doi': '10.1038/nchembio.2077'}, unit='M'):
              """

      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_gerosa_collection has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def fill_gerosa_collection(self, file_location, sheet_name='Sheet1', start_row=0,

        Function fill_collection has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def fill_collection(self, file_location, sheet_name='Sheet1', start_row=0,

          Function _flatten_conc_obj has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def _flatten_conc_obj(self, obj, ncbi_id, species_name, _id, source='ECMDB'):

            Function fill_meta has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def fill_meta(self):
                    """Fill exisiting metabolites with meta information.
                    """
                    query = {'inchikey': {'$exists': False}}
                    count = self.collection.count_documents(query)

            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 i, y_doc in enumerate(y_docs[start:]):
                        if self.verbose and i % 50 == 0:
                            print('Processing ymdb doc {} out of {}'.format(i+start, count_y))
                        if y_doc['synonyms']:
                            synonyms = y_doc['synonyms']['synonym']
            datanator/data_source/metabolite_concentration/doi_10_1038_nchembio_2077.py on lines 153..165

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

            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 i, e_doc in enumerate(e_docs[start:]):
                        if self.verbose and i % 50 == 0:
                            print('Processing ecmdb doc {} out of {}'.format(i+start, count_e))
                        if e_doc['synonyms']:
                            synonyms = e_doc['synonyms']['synonym']
            datanator/data_source/metabolite_concentration/doi_10_1038_nchembio_2077.py on lines 167..179

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

            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

                        try:
                            row['ncbi_taxonomy_id'] = self.taxon_collection.find_one({'tax_name': row['species_name']},
                                                                                    projection={'tax_id': 1}, collation=self.collation).get('tax_id')
            datanator/data_source/rna_modification/rna_modification.py on lines 73..75

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

            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

                                    conc_obj[idx]["affinities"].append({
                                                                        "ec_number": conc['ec_number'],
                                                                        "k_m": conc.get('k_m'),
                                                                        "k_i": conc.get('k_i'),
                                                                        "unit": conc.get('unit')
            datanator/data_source/metabolite_concentration/doi_10_1038_nchembio_2077.py on lines 67..71

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

            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

                                                    "affinities": [{
                                                                    "ec_number": conc['ec_number'],
                                                                    "k_m": conc.get('k_m'),
                                                                    "k_i": conc.get('k_i'),
                                                                    "unit": conc.get('unit')
            datanator/data_source/metabolite_concentration/doi_10_1038_nchembio_2077.py on lines 85..89

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

            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 % 20 == 0:
                            print('Processing doc {} out of {}'.format(i, count))
            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/metabolites_meta_collection.py on lines 247..248
            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 6 locations. Consider refactoring.
            Open

                        if self.verbose and i % 20 == 0:
                            print("Processing doc {} out of {} ...".format(i, count))
            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 343..344
            datanator/data_source/metabolites_meta_collection.py on lines 247..248
            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 14 locations. Consider refactoring.
            Open

                        if i % 10 == 0 and self.verbose:
                            print("Processing locus {} out {}".format(i, row_count))
            datanator/data_source/metabolite_concentration/doi_10_1038_nchembio_2077.py on lines 246..247
            datanator/data_source/metabolites_meta_collection.py on lines 149..150
            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 14 locations. Consider refactoring.
            Open

                        if i % 10 == 0 and self.verbose:
                            print("Processing locus {} out {}".format(i, row_count))
            datanator/data_source/metabolite_concentration/doi_10_1038_nchembio_2077.py on lines 307..308
            datanator/data_source/metabolites_meta_collection.py on lines 149..150
            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 % 20 == 0:
                            print("Processing doc {} out of {} ...".format(i, count))
            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/metabolites_meta_collection.py on lines 247..248
            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

            There are no issues that match your filters.

            Category
            Status