Exemple #1
0
    def _init_builder(self, reaction_data, objective, variable):
        self.header_id = str(uuid4()).replace("-", "_")
        display(
            HTML("""
        <p>
            %s&nbsp;<span id="objective-%s">%f</span></br>
            %s&nbsp;<span id="variable-%s">%f</span>
        </p>
        """ % (objective[0], self.header_id, objective[1], variable[0],
               self.header_id, variable[1])))

        self.builder = NotebookBuilder(map_name=self.map_name,
                                       reaction_data=reaction_data,
                                       reaction_scale=[
                                           dict(type='min',
                                                color="red",
                                                size=20),
                                           dict(type='median',
                                                color="grey",
                                                size=7),
                                           dict(type='max',
                                                color='green',
                                                size=20)
                                       ],
                                       **self.kwargs_for_escher)
        display(self.builder.display_in_notebook())
Exemple #2
0
 def _init_builder(self, reaction_data, reaction_scale):
     if os.path.isfile(self.map_name):
         self.builder = NotebookBuilder(map_json=self.map_name,
                                        reaction_data=reaction_data,
                                        reaction_scale=reaction_scale,
                                        reaction_no_data_color="lightgray",
                                        reaction_no_data_size=5)
     else:
         self.builder = NotebookBuilder(map_name=self.map_name,
                                        reaction_data=reaction_data,
                                        reaction_scale=reaction_scale,
                                        reaction_no_data_color="lightgray",
                                        reaction_no_data_size=5)
     display(self.builder.display_in_notebook())
Exemple #3
0
 def _init_builder(self, reaction_data, reaction_scale):
     if os.path.isfile(self.map_name):
         self.builder = NotebookBuilder(map_json=self.map_name,
                                        reaction_data=reaction_data,
                                        reaction_scale=reaction_scale,
                                        reaction_no_data_color="lightgray",
                                        reaction_no_data_size=5)
     else:
         self.builder = NotebookBuilder(map_name=self.map_name,
                                        reaction_data=reaction_data,
                                        reaction_scale=reaction_scale,
                                        reaction_no_data_color="lightgray",
                                        reaction_no_data_size=5)
     display(self.builder.display_in_notebook())
Exemple #4
0
class EscherViewer(object):
    def __init__(self, data_frame, map_name, color_scales, normalization_functions):
        assert isinstance(data_frame, DataFrame)
        self.data_frame = data_frame
        self.map_name = map_name
        self.builder = None
        self.color_scales = color_scales
        self.normalization_functions = normalization_functions

    def __call__(self, column):
        reaction_data = dict(self.data_frame.dropna()[column].apply(self.normalization_functions[column]))
        reaction_data = {r: v for r, v in six.iteritems(reaction_data) if v is not None}
        reaction_data = {r: v for r, v in six.iteritems(reaction_data) if v is not np.nan}
        reaction_scale = self.color_scales[column]
        if self.builder is None:
            self._init_builder(reaction_data, reaction_scale)
        else:
            self.builder.update(reaction_data=reaction_data, reaction_scale=reaction_scale)

    def _init_builder(self, reaction_data, reaction_scale):
        if os.path.isfile(self.map_name):
            self.builder = NotebookBuilder(map_json=self.map_name,
                                           reaction_data=reaction_data,
                                           reaction_scale=reaction_scale,
                                           reaction_no_data_color="lightgray",
                                           reaction_no_data_size=5)
        else:
            self.builder = NotebookBuilder(map_name=self.map_name,
                                           reaction_data=reaction_data,
                                           reaction_scale=reaction_scale,
                                           reaction_no_data_color="lightgray",
                                           reaction_no_data_size=5)
        display(self.builder.display_in_notebook())
Exemple #5
0
class _MapView(object):
    def __init__(self, solutions, map_name, **kwargs):
        self.solutions = solutions
        self.map_name = map_name
        self.builder = None
        self.kwargs_for_escher = kwargs

    def __call__(self, index):
        reaction_data = dict(self.solutions.iloc[index - 1].gaps)
        axis = self.solutions.axes[0]
        if self.builder is None:
            self._init_builder(reaction_data, axis[index - 1][0],
                               axis[index - 1][1])
        else:
            self.builder.update(reaction_data)
            self.update_header(axis[index - 1][0], axis[index - 1][1])

    def update_header(self, objective, variable):
        display(
            Javascript("""
            jQuery("#objective-%s").text("%f");\n
            jQuery("#variable-%s").text("%f");
        """ % (self.header_id, objective[1], self.header_id, variable[1])))

    def _init_builder(self, reaction_data, objective, variable):
        self.header_id = str(uuid4()).replace("-", "_")
        display(
            HTML("""
        <p>
            %s&nbsp;<span id="objective-%s">%f</span></br>
            %s&nbsp;<span id="variable-%s">%f</span>
        </p>
        """ % (objective[0], self.header_id, objective[1], variable[0],
               self.header_id, variable[1])))

        self.builder = NotebookBuilder(map_name=self.map_name,
                                       reaction_data=reaction_data,
                                       reaction_scale=[
                                           dict(type='min',
                                                color="red",
                                                size=20),
                                           dict(type='median',
                                                color="grey",
                                                size=7),
                                           dict(type='max',
                                                color='green',
                                                size=20)
                                       ],
                                       **self.kwargs_for_escher)
        display(self.builder.display_in_notebook())
    def _init_builder(self, reaction_data, objective, variable):
        self.header_id = str(uuid4()).replace("-", "_")
        display(HTML("""
        <p>
            %s&nbsp;<span id="objective-%s">%f</span></br>
            %s&nbsp;<span id="variable-%s">%f</span>
        </p>
        """ % (objective[0], self.header_id, objective[1],
               variable[0], self.header_id, variable[1])))

        self.builder = NotebookBuilder(map_name=self.map_name,
                                       reaction_data=reaction_data,
                                       reaction_scale=[
                                           dict(type='min', color="red", size=20),
                                           dict(type='median', color="grey", size=7),
                                           dict(type='max', color='green', size=20)], **self.kwargs_for_escher)
        display(self.builder.display_in_notebook())
class _MapView(object):
    def __init__(self, solutions, map_name, **kwargs):
        self.solutions = solutions
        self.map_name = map_name
        self.builder = None
        self.kwargs_for_escher = kwargs

    def __call__(self, index):
        reaction_data = dict(self.solutions.iloc[index - 1].gaps)
        axis = self.solutions.axes[0]
        if self.builder is None:
            self._init_builder(reaction_data, axis[index - 1][0], axis[index - 1][1])
        else:
            self.builder.update(reaction_data)
            self.update_header(axis[index - 1][0], axis[index - 1][1])

    def update_header(self, objective, variable):
        display(Javascript("""
            jQuery("#objective-%s").text("%f");\n
            jQuery("#variable-%s").text("%f");
        """ % (self.header_id, objective[1], self.header_id, variable[1])))

    def _init_builder(self, reaction_data, objective, variable):
        self.header_id = str(uuid4()).replace("-", "_")
        display(HTML("""
        <p>
            %s&nbsp;<span id="objective-%s">%f</span></br>
            %s&nbsp;<span id="variable-%s">%f</span>
        </p>
        """ % (objective[0], self.header_id, objective[1],
               variable[0], self.header_id, variable[1])))

        self.builder = NotebookBuilder(map_name=self.map_name,
                                       reaction_data=reaction_data,
                                       reaction_scale=[
                                           dict(type='min', color="red", size=20),
                                           dict(type='median', color="grey", size=7),
                                           dict(type='max', color='green', size=20)], **self.kwargs_for_escher)
        display(self.builder.display_in_notebook())