# Path: simdna/synthetic/core.py
# class DefaultNameMixin(object):
#     """Basic functionality for classes that have a self.name attribute.
#     
#     The self.name attribute is typically used to leave a trace in
#     an instance of :class:`.AdditionalInfo`
#     
#     Arguments:
#         name: string
#     """
# 
#     def __init__(self, name):
#         if (name == None):
#             name = self.getDefaultName()
#         self.name = name
# 
#     def get_default_name(self):
#         self.getDefaultName()
# 
#     def getDefaultName(self):
#         return type(self).__name__
# 
# Path: simdna/synthetic/substringgen.py
# class AbstractSubstringGenerator(DefaultNameMixin):
#     """
#         Generates a substring, usually for embedding in a background sequence.
#     """
# 
#     def generate_substring(self):
#         self.generateSubstring()
# 
#     def generateSubstring(self):
#         """
#         Return:
#             A tuple of ``(string, stringDescription)``; the result can be
#         wrapped in an instance of :class:`.StringEmbeddable`.
#         ``stringDescription`` is a short descriptor that does not contain
#         spaces and may be prefixed in front of string when generating
#         the __str__ representation for :class:`.StringEmbeddable`. 
#         """
#         raise NotImplementedError()
# 
#     def get_jsonable_object(self):
#         self.getJsonableObject()
# 
#     def getJsonableObject(self):
#         """Get JSON object representation.
# 
#         Returns:
#             A json-friendly object (built of dictionaries, lists and
#         python primitives), which can be converted to json to
#         record the exact details of what was simualted.
#         """
#         raise NotImplementedError()


from simdna.synthetic.core import DefaultNameMixin
from simdna.synthetic.substringgen import AbstractSubstringGenerator
from collections import OrderedDict
import random

        name: see :class:`.DefaultNameMixin`.
    """

    def __init__(self, substringGenerator, transformations,
                       transformationsDescription="transformations",
                       name=None):
        self.substringGenerator = substringGenerator
        self.transformations = transformations
        self.transformationsDescription = transformationsDescription
        super(TransformedSubstringGenerator, self).__init__(self.name)

    def generateSubstring(self):
        """See superclass.
        """
        substring, substringDescription = self.substringGenerator.generateSubstring()
        baseSubstringArr = [x for x in substring]
        for transformation in self.transformations:
            baseSubstringArr = transformation.transform(baseSubstringArr)
        return "".join(baseSubstringArr), self.transformationsDescription + "-" + substringDescription

    def getJsonableObject(self):
        """See superclass.
        """
        return OrderedDict([("class", "TransformedSubstringGenerator"),
    ("substringGenerator", self.substringGenerator.getJsonableObject()),
    ("transformations", [x.getJsonableObject() for x in self.transformations])
    ])



# Path: simdna/synthetic/core.py
# class DefaultNameMixin(object):
#     """Basic functionality for classes that have a self.name attribute.
#     
#     The self.name attribute is typically used to leave a trace in
#     an instance of :class:`.AdditionalInfo`
#     
#     Arguments:
#         name: string
#     """
# 
#     def __init__(self, name):
#         if (name == None):
#             name = self.getDefaultName()
#         self.name = name
# 
#     def get_default_name(self):
#         self.getDefaultName()
# 
#     def getDefaultName(self):
#         return type(self).__name__
# 
# Path: simdna/synthetic/substringgen.py
# class AbstractSubstringGenerator(DefaultNameMixin):
#     """
#         Generates a substring, usually for embedding in a background sequence.
#     """
# 
#     def generate_substring(self):
#         self.generateSubstring()
# 
#     def generateSubstring(self):
#         """
#         Return:
#             A tuple of ``(string, stringDescription)``; the result can be
#         wrapped in an instance of :class:`.StringEmbeddable`.
#         ``stringDescription`` is a short descriptor that does not contain
#         spaces and may be prefixed in front of string when generating
#         the __str__ representation for :class:`.StringEmbeddable`. 
#         """
#         raise NotImplementedError()
# 
#     def get_jsonable_object(self):
#         self.getJsonableObject()
# 
#     def getJsonableObject(self):
#         """Get JSON object representation.
# 
#         Returns:
#             A json-friendly object (built of dictionaries, lists and
#         python primitives), which can be converted to json to
#         record the exact details of what was simualted.
#         """
#         raise NotImplementedError()


# Path: simdna/synthetic/mutation.py
from simdna.synthetic.core import DefaultNameMixin
from simdna.synthetic.substringgen import AbstractSubstringGenerator
from collections import OrderedDict
import random


        name: see :class:`.DefaultNameMixin`.
    """

    def __init__(self, substringGenerator, transformations,
                       transformationsDescription="transformations",
                       name=None):
        self.substringGenerator = substringGenerator
        self.transformations = transformations
        self.transformationsDescription = transformationsDescription
        super(TransformedSubstringGenerator, self).__init__(self.name)

    def generateSubstring(self):
        """See superclass.
        """
        substring, substringDescription = self.substringGenerator.generateSubstring()
        baseSubstringArr = [x for x in substring]
        for transformation in self.transformations:
            baseSubstringArr = transformation.transform(baseSubstringArr)
        return "".join(baseSubstringArr), self.transformationsDescription + "-" + substringDescription

    def getJsonableObject(self):
        """See superclass.
        """
        return OrderedDict([("class", "TransformedSubstringGenerator"),
    ("substringGenerator", self.substringGenerator.getJsonableObject()),
    ("transformations", [x.getJsonableObject() for x in self.transformations])
    ])



class AbstractTransformation(DefaultNameMixin):