choderalab/yank

View on GitHub
Yank/experiment.py

Summary

Maintainability
F
1 wk
Test Coverage

File experiment.py has 2390 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python

# =============================================================================
# MODULE DOCSTRING
# =============================================================================
Severity: Major
Found in Yank/experiment.py - About 6 days to fix

    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
    Severity: Minor
    Found in Yank/experiment.py - About 5 hrs to fix

      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
      Severity: Minor
      Found in Yank/experiment.py - About 4 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function _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
      Severity: Minor
      Found in Yank/experiment.py - About 4 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function 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
      Severity: Minor
      Found in Yank/experiment.py - About 4 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function _validate_protocols has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          def _validate_protocols(protocols_description):
              """Validate protocols.
      
              Parameters
              ----------
      Severity: Minor
      Found in Yank/experiment.py - About 3 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 _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.
      Severity: Minor
      Found in Yank/experiment.py - About 3 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 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
      Severity: Minor
      Found in Yank/experiment.py - About 3 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 _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.
      
      
      Severity: Minor
      Found in Yank/experiment.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 _validate_molecules has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def _validate_molecules(cls, molecules_description):
              """Validate molecules syntax.
      
              Parameters
              ----------
      Severity: Minor
      Found in Yank/experiment.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 _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
      Severity: Minor
      Found in Yank/experiment.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 _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.
      
      
      Severity: Minor
      Found in Yank/experiment.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 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
      Severity: Minor
      Found in Yank/experiment.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 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, sampler, thermodynamic_state, sampler_states, topography,
      Severity: Major
      Found in Yank/experiment.py - About 1 hr to fix

        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 = []
        Severity: Minor
        Found in Yank/experiment.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 _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
                ----------
        Severity: Minor
        Found in Yank/experiment.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 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
        Severity: Minor
        Found in Yank/experiment.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 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.
        Severity: Minor
        Found in Yank/experiment.py - About 45 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 _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.
        Severity: Minor
        Found in Yank/experiment.py - About 45 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

        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']))
        Severity: Major
        Found in Yank/experiment.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if is_processed and not resume_setup:
                                      err_msg = 'molecule {} file'.format(molecule_id)
                                      break
          
          
          Severity: Major
          Found in Yank/experiment.py - About 45 mins to fix

            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``
            Severity: Minor
            Found in Yank/experiment.py - About 35 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 _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 {}
            Severity: Minor
            Found in Yank/experiment.py - About 35 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 _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 = []
            Severity: Minor
            Found in Yank/experiment.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

            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.
            
                    """
            Severity: Minor
            Found in Yank/experiment.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

            There are no issues that match your filters.

            Category
            Status