File experiment.py
has 2390 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python
# =============================================================================
# MODULE DOCSTRING
# =============================================================================
ExperimentBuilder
has 41 functions (exceeds 20 allowed). Consider refactoring. Open
class ExperimentBuilder(object):
"""Parse YAML configuration file and build the experiment.
The relative paths indicated in the script are assumed to be relative to
the script directory. However, if ExperimentBuilder is initiated with a string
Function _configure_platform
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def _configure_platform(cls, platform_name, platform_precision):
"""
Configure the platform to be used for simulation for the given precision.
Parameters
- 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 _check_resume
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def _check_resume(self, check_setup=True, check_experiments=True):
"""Perform dry run to check if we are going to overwrite files.
If we find folders that ExperimentBuilder should create we raise an exception
unless resume_setup or resume_simulation are found, in which case we
- 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 run
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def run(self, n_iterations=None):
"""
Run the experiment.
Runs until either the maximum number of iterations have been reached or the sampler
- 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 _validate_protocols
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def _validate_protocols(protocols_description):
"""Validate protocols.
Parameters
----------
- 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 _validate_systems
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def _validate_systems(self, systems_description):
"""Validate systems.
Receptors, ligands, and solvents must be already loaded. If they are not
found an exception is raised.
- 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 status
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def status(self):
"""Iterate over the status of all experiments in dictionary form.
The status of each experiment is set to "completed" if both phases
in the experiments have been completed, "pending" if they are both
- 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 _generate_experiment_protocol
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def _generate_experiment_protocol(self, experiment):
"""Generate auto alchemical paths for the given experiment.
Creates a YAML script in the experiment folder with the found protocol.
- 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 _validate_molecules
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def _validate_molecules(cls, molecules_description):
"""Validate molecules syntax.
Parameters
----------
- 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 _expand_molecules
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def _expand_molecules(self, yaml_content):
"""Expand combinatorial molecules.
Generate new YAML content with no combinatorial molecules. The new content
is identical to the old one but combinatorial molecules are substituted by
- 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_experiments
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def _parse_experiments(self, yaml_content):
"""Validate experiments.
Perform dry run and validate system, protocol and options of every combination.
- 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 run_experiments
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def run_experiments(self, write_status=False):
"""
Set up and run all the Yank experiments.
Parameters
- 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, sampler, thermodynamic_state, sampler_states, topography,
Function _find_automatic_protocol_phases
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _find_automatic_protocol_phases(protocol):
"""Return the list of phase names in the protocol whose alchemical
path must be generated automatically."""
assert isinstance(protocol, collections.OrderedDict)
phases_to_generate = []
- 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 _validate_options
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _validate_options(cls, options, validate_general_options):
"""Validate molecules syntax.
Parameters
----------
- 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 initialize_alchemical_phase
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def initialize_alchemical_phase(self):
"""
Create and set all the initial options for the alchemical phase
This minimizes, randomizes_ligand, and equilibrates the alchemical_phase on top of creating it, if the various
- 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
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def parse(self, script):
"""Parse the given YAML configuration file.
Validate the syntax and load the script into memory. This does not build
the actual experiment.
- 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 _expand_experiments
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _expand_experiments(self):
"""Generates all possible combinations of experiment.
Each generated experiment is uniquely named. If job_id and n_jobs are
set, this returns only the experiments assigned to this particular job.
- 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 deeply nested control flow statements. Open
if not utils.is_openeye_installed(oetools=('oechem',)):
err_msg = 'Molecule {}: Cannot "select" from {} file without OpenEye toolkit'
raise RuntimeError(err_msg.format(comb_mol_name, extension))
n_models = len(utils.load_oe_molecules(comb_molecule['filepath']))
Avoid deeply nested control flow statements. Open
if is_processed and not resume_setup:
err_msg = 'molecule {} file'.format(molecule_id)
break
Function create_alchemical_phase
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create_alchemical_phase(self):
"""
Create the alchemical phase based on all the options
This only creates it, but does nothing else to prepare for simulations. The ``initialize_alchemical_phase``
- 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 _validate_samplers
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _validate_samplers(self, yaml_content):
"""Validate samplers section."""
sampler_descriptions = yaml_content.get('samplers', None)
if sampler_descriptions is None:
return {}
- 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 _generate_experiments_protocols
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _generate_experiments_protocols(self):
"""Go through all experiments and generate 'auto' alchemical paths."""
# Find all experiments that have at least one phase whose
# alchemical path needs to be generated automatically.
experiments_to_generate = []
- 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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, script=None, job_id=None, n_jobs=None):
"""
Constructor.
"""
- 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"