# Path: oe_utils/shape/color.py
# class ColorForceField(OEColorForceField):
#     """
#     Color force field wrapper with additional utility methods.
#     """
#     def get_interactions(self):
#         """
#         Extract color-color interactions from INTERACTION lines.
# 
#         Returns
#         -------
#         interactions : array_like
#             Array containing tuples of (a_type, b_type, decay, weight, radius).
# 
#         Notes
#         -----
#         * Negative weights indicate attractive interactions.
#         * Interaction list is sorted.
#         """
#         interactions = []
#         for line in self.get_string().split('\n'):
#             fields = line.split()
#             if not len(fields) or str.lower(fields[0]) != 'interaction':
#                 continue
#             assert len(fields) == 7
# 
#             # get color atom types
#             a_type = self.GetType(fields[1])
#             b_type = self.GetType(fields[2])
#             assert a_type and b_type
# 
#             # get decay
#             decay = fields[4]
# 
#             # get weight and direction (negative weights are attractive)
#             weight_name, weight = fields[5].split('=')
#             assert str.lower(weight_name) == 'weight'
#             weight = float(weight)
#             if str.lower(fields[3]) == 'attractive':
#                 weight *= -1
#             else:
#                 assert str.lower(fields[3]) == 'repulsive'
# 
#             # get radius
#             radius_name, radius = fields[6].split('=')
#             assert str.lower(radius_name) == 'radius'
#             radius = float(radius)
# 
#             # construct an interaction tuple matching the order required by
#             # OEColorForceField.AddInteraction
#             interactions.append((a_type, b_type, decay, weight, radius))
#         return sorted(interactions)  # sort interaction list
# 
#     def get_string(self):
#         """
#         Return the color force field as a string.
#         """
#         ostream = oeosstream()
#         self.Write(ostream)
#         return ostream.str()
# 
#     def isolate_interactions(self):
#         """
#         Yield color force fields that each have only a single interaction.
#         """
#         for interaction in self.get_interactions():
#             color_ff = ColorForceField(self)  # create a copy
#             color_ff.ClearInteractions()
#             color_ff.AddInteraction(*interaction)
#             yield color_ff


import numpy as np
import unittest
from openeye.oechem import *
from openeye.oeshape import *
from ..color import ColorForceField


class TestColorForceField(unittest.TestCase):
    """
    Tests for ColorForceField.
    """
    def setUp(self):
        """
        Set up tests.
        """
        self.color_ff = ColorForceField()
        self.color_ff.Init(OEColorFFType_ImplicitMillsDean)

    def test_get_interactions(self):
        """
        Test ColorForceField.get_interactions.
        """
        interactions = self.color_ff.get_interactions()
        assert len(interactions) == 6
        for (a_type, b_type, decay, weight, radius) in interactions:
            assert a_type == b_type
            assert decay == 'gaussian'
            assert weight < 0
            assert radius > 0

    def test_get_string(self):
        """
        Test ColorForceField.get_string.
        """
        ifs = oeisstream(self.color_ff.get_string())

# Path: oe_utils/shape/color.py
# class ColorForceField(OEColorForceField):
#     """
#     Color force field wrapper with additional utility methods.
#     """
#     def get_interactions(self):
#         """
#         Extract color-color interactions from INTERACTION lines.
# 
#         Returns
#         -------
#         interactions : array_like
#             Array containing tuples of (a_type, b_type, decay, weight, radius).
# 
#         Notes
#         -----
#         * Negative weights indicate attractive interactions.
#         * Interaction list is sorted.
#         """
#         interactions = []
#         for line in self.get_string().split('\n'):
#             fields = line.split()
#             if not len(fields) or str.lower(fields[0]) != 'interaction':
#                 continue
#             assert len(fields) == 7
# 
#             # get color atom types
#             a_type = self.GetType(fields[1])
#             b_type = self.GetType(fields[2])
#             assert a_type and b_type
# 
#             # get decay
#             decay = fields[4]
# 
#             # get weight and direction (negative weights are attractive)
#             weight_name, weight = fields[5].split('=')
#             assert str.lower(weight_name) == 'weight'
#             weight = float(weight)
#             if str.lower(fields[3]) == 'attractive':
#                 weight *= -1
#             else:
#                 assert str.lower(fields[3]) == 'repulsive'
# 
#             # get radius
#             radius_name, radius = fields[6].split('=')
#             assert str.lower(radius_name) == 'radius'
#             radius = float(radius)
# 
#             # construct an interaction tuple matching the order required by
#             # OEColorForceField.AddInteraction
#             interactions.append((a_type, b_type, decay, weight, radius))
#         return sorted(interactions)  # sort interaction list
# 
#     def get_string(self):
#         """
#         Return the color force field as a string.
#         """
#         ostream = oeosstream()
#         self.Write(ostream)
#         return ostream.str()
# 
#     def isolate_interactions(self):
#         """
#         Yield color force fields that each have only a single interaction.
#         """
#         for interaction in self.get_interactions():
#             color_ff = ColorForceField(self)  # create a copy
#             color_ff.ClearInteractions()
#             color_ff.AddInteraction(*interaction)
#             yield color_ff


# Path: oe_utils/shape/tests/test_color.py
import numpy as np
import unittest
from openeye.oechem import *
from openeye.oeshape import *
from ..color import ColorForceField



class TestColorForceField(unittest.TestCase):
    """
    Tests for ColorForceField.
    """
    def setUp(self):
        """
        Set up tests.
        """
        self.color_ff = ColorForceField()
        self.color_ff.Init(OEColorFFType_ImplicitMillsDean)

    def test_get_interactions(self):
        """
        Test ColorForceField.get_interactions.
        """
        interactions = self.color_ff.get_interactions()
        assert len(interactions) == 6
        for (a_type, b_type, decay, weight, radius) in interactions:
            assert a_type == b_type
            assert decay == 'gaussian'
            assert weight < 0
            assert radius > 0

    def test_get_string(self):
        """
        Test ColorForceField.get_string.
        """
        ifs = oeisstream(self.color_ff.get_string())

        color_ff = ColorForceField()