Completed
Push — master ( 4cde57...24f8d3 )
by Rich
01:30
created

UFF   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
dl 0
loc 18
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 2 1
A optimize() 0 13 4
1
#! /usr/bin/env python
2
#
3
# Copyright (C) 2015 Rich Lewis <[email protected]>
4
# License: 3-clause BSD
5
6
"""
7
## skchem.forcefields.uff
8
9
Module specifying the universal force field.
10
"""
11
import warnings
12
13
from .base import ForceField
14
from rdkit.Chem.rdForceFieldHelpers import UFFOptimizeMolecule
0 ignored issues
show
Configuration introduced by
The import rdkit.Chem.rdForceFieldHelpers could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
15
16
17
class UFF(ForceField):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
18
19
    def __init__(self):
0 ignored issues
show
Bug introduced by
The __init__ method of the super-class ForceField is not called.

It is generally advisable to initialize the super-class by calling its __init__ method:

class SomeParent:
    def __init__(self):
        self.x = 1

class SomeChild(SomeParent):
    def __init__(self):
        # Initialize the super class
        SomeParent.__init__(self)
Loading history...
20
        pass
21
22
    def optimize(self, mol):
23
        res = UFFOptimizeMolecule(mol)
24
25
        if res == -1:
26
            msg = 'Failed to optimize molecule \'{}\' using MMFF'.format(mol.name)
27
            if self.error_on_fail:
28
                raise RuntimeError(msg)
29
            elif self.warn_on_fail:
30
                warnings.warn(msg)
31
            else:
32
                pass
33
34
        return mol
0 ignored issues
show
Coding Style introduced by
Final newline missing
Loading history...