File sabio_rk_nosql.py
has 1090 lines of code (exceeds 250 allowed). Consider refactoring. Open
import datanator.config.core
from datanator.util import mongo_util
from datanator.util import file_util, chem_util
from datanator.util import molecule_util
import requests
Function normalize_parameter_value
has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring. Open
def normalize_parameter_value(self, name, type, value, error, units, enzyme_molecular_weight):
"""
Args:
name (:obj:`str`): parameter name
type (:obj:`int`) parameter type (SBO term id)
- Read upRead up
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_missing_kinetic_law_information_from_tsv_helper
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
def load_missing_kinetic_law_information_from_tsv_helper(self, tsv, start=0):
""" Update the properties of kinetic laws in the mongodb based on content downloaded
from SABIO in TSV format.
Note: this method is necessary because neither of SABIO's SBML and Excel export methods provide
- Read upRead up
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_compounds
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def load_compounds(self, compounds=None):
""" Download information from SABIO-RK about all of the compounds stored sabio_compounds
collection
Args:
compounds (:obj:`list` of :obj:`obj`): list of compounds to download
- Read upRead up
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 parse_complex_subunit_structure
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def parse_complex_subunit_structure(self, text):
""" Parse the subunit structure of complex into a dictionary of subunit coefficients
Args:
text (:obj:`str`): subunit structure described with nested parentheses
- Read upRead up
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 create_kinetic_law_from_sbml
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def create_kinetic_law_from_sbml(self, id, sbml, root_species, specie_properties, functions, units):
""" Make a kinetic law doc for mongoDB
Args:
id (:obj:`int`): identifier
- Read upRead up
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 create_cross_references_from_sbml
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def create_cross_references_from_sbml(self, sbml):
""" Look up cross references from an SBML object to dictionary
Args:
sbml (:obj:`libsbml.SBase`): object in an SBML documentation
- Read upRead up
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
SabioRk
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
class SabioRk:
def __init__(self, cache_dirname=None, MongoDB=None, replicaSet=None, db=None,
verbose=False, max_entries=float('inf'), username=None,
password=None, authSource='admin', webservice_batch_size=50,
Function infer_compound_structures_from_names
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def infer_compound_structures_from_names(self, compounds):
""" Try to use PubChem to infer the structure of compounds from their names
Notes: we don't try look up structures from their cross references because SABIO has already gathered
all structures from their cross references to ChEBI, KEGG, and PubChem
- Read upRead up
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 create_kinetic_laws_from_sbml
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def create_kinetic_laws_from_sbml(self, ids, sbml):
""" Add kinetic laws defined in an SBML file to the local mongodb database
Args:
ids (:obj:`list` of :obj:`int`): list kinetic law IDs
- Read upRead up
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 add_inchi_hash
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def add_inchi_hash(self, ids):
'''
Add sha224 hashed values of _value_inchi in sabio_rk collection
'''
query = {}
- Read upRead up
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 calc_enzyme_molecular_weights
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def calc_enzyme_molecular_weights(self, enzymes, length):
""" Calculate the molecular weight of each enzyme
Args:
enzymes (:obj:`list` of :obj:`dict`): list of enzymes
- Read upRead up
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_missing_enzyme_information_from_html
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def load_missing_enzyme_information_from_html(self, ids, start=0):
""" Loading enzyme subunit information from html
Args:
ids (:obj:`list` of :obj:`int`): list of IDs of kinetic laws to download
- Read upRead up
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 get_specie_from_sbml
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def get_specie_from_sbml(self, sbml):
""" get species information from sbml
Args:
sbml (:obj:`libsbml.Species`): SBML-representation of a compound or enzyme
- Read upRead up
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 get_parameter_by_properties
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def get_parameter_by_properties(self, kinetic_law, parameter_properties):
""" Get the parameter of :obj:`kinetic_law` whose attribute values are
equal to that of :obj:`parameter_properties`
Args:
kinetic_law (:obj:`KineticLaw`): kinetic law to find parameter of
- Read upRead up
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 11 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, cache_dirname=None, MongoDB=None, replicaSet=None, db=None,
Function load_content
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def load_content(self):
""" Download the content of SABIO-RK and store it to a remote mongoDB. """
def ids_to_process(total_ids, query):
exisitng_ids = self.collection.distinct('kinlaw_id', filter=query)
- Read upRead up
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 normalize_kinetic_laws
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def normalize_kinetic_laws(self, new_ids):
""" Normalize parameter values.
Args:
new_ids (:obj:`list` of :obj:`int`): list of IDs of kinetic laws to normalize
- Read upRead up
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 create_kinetic_law_from_sbml
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_kinetic_law_from_sbml(self, id, sbml, root_species, specie_properties, functions, units):
Function normalize_parameter_value
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def normalize_parameter_value(self, name, type, value, error, units, enzyme_molecular_weight):
Function load_kinetic_laws
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def load_kinetic_laws(self, ids):
""" Download kinetic laws from SABIO-RK
Args:
ids (:obj:`list` of :obj:`int`): list of IDs of kinetic laws to download
- Read upRead up
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
Avoid too many return
statements within this function. Open
return ('k_cat', 25, value, error, 's^(-1)')
Avoid too many return
statements within this function. Open
return (None, None, None, None, None)
Avoid too many return
statements within this function. Open
return (None, None, None, None, None)
Avoid too many return
statements within this function. Open
return (None, None, None, None, None)
Avoid too many return
statements within this function. Open
return (None, None, None, None, None)
Avoid too many return
statements within this function. Open
return parameters[0]
Avoid too many return
statements within this function. Open
return (None, None, None, None, None)
Avoid too many return
statements within this function. Open
return (None, None, None, None, None)
Avoid too many return
statements within this function. Open
return (None, None, None, None, None)
Avoid too many return
statements within this function. Open
return (None, None, None, None, None)
Avoid too many return
statements within this function. Open
return (None, None, None, None, None)
Avoid too many return
statements within this function. Open
return (None, None, None, None, None)
Avoid too many return
statements within this function. Open
return ('v_max', 186, value, error, 'mol*s^(-1)*g^(-1)')
Avoid too many return
statements within this function. Open
return ('k_m', 27, value, error, 'M')
Avoid too many return
statements within this function. Open
return ('k_cat', 25, value * float(f) if value else None, error * float(f) if error else None, 's^(-1)')
Avoid too many return
statements within this function. Open
return ('k_i', 261, value, error, 'M')
Avoid too many return
statements within this function. Open
return (None, None, None, None, None)
Avoid too many return
statements within this function. Open
return (None, None, None, None, None)
Avoid too many return
statements within this function. Open
return (None, None, None, None, None)
Function calc_inchi_formula_connectivity
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def calc_inchi_formula_connectivity(self, structure):
""" Calculate a searchable structures
* InChI format
* Core InChI format
- Read upRead up
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 parse_enzyme_name
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def parse_enzyme_name(self, sbml):
""" Parse the name of an enzyme in SBML for the enzyme name, wild type status, and variant
description that it contains.
Args:
- Read upRead up
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"