Example #1
0
    def build_result_collection(self, exp):
        if settings.CELERY_DEBUG:
            import sys
            sys.path.append('/Migration/skola/phd/projects/miXGENE/mixgene_project/wrappers/pycharm-debug.egg')
            import pydevd
            pydevd.settrace('localhost', port=6901, stdoutToServer=True, stderrToServer=True)

        rc = ResultsContainer(
            base_dir=exp.get_data_folder(),
            base_filename="%s" % self.uuid
        )
        res_seq = self.res_seq

        axis_meta_block = self.base_name
        axis_meta_block_labels = self.get_fold_labels()
        def create_new_dim_rc(local_rc):
            local_rc.axis_list = [axis_meta_block]
            local_rc.labels_dict[axis_meta_block] = axis_meta_block_labels
            local_rc.init_ar()
            local_rc.update_label_index()

        # WARNING: We only support homogeneous results, so we only check first element
        res_seq_field_name, data_type = res_seq.fields.iteritems().next()
        if data_type == "ClassifierResult":
            single_rc_list = []
            for field_name in res_seq.fields:
                rc_single = ResultsContainer("", "")
                create_new_dim_rc(rc_single)
                for idx, res_seq_cell in enumerate(res_seq.sequence):
                    rc_single.ar[idx] = res_seq_cell[field_name]
                single_rc_list.append(rc_single)

            rc.add_dim_layer(single_rc_list, self.collector_spec.label, res_seq.fields.keys())

        elif data_type == "ResultsContainer":
            if len(res_seq.fields) > 1:
                raise Exception("Meta block only support single output of type ResultsContainer")

            else:
                rc_list = []
                for cell in res_seq.sequence:
                    sub_rc = cell[res_seq_field_name]
                    sub_rc.load()
                    rc_list.append(sub_rc)

                rc.add_dim_layer(rc_list, self.base_name, self.get_fold_labels())

        elif data_type == "SequenceContainer":
            # TODO remove this check
            pass
        else:
            raise Exception("Meta blocks only support ClassifierResult "
                            "or ResultsContainer in the output collection. "
                            " Instead got: %s" % data_type)

        rc.store()
        rc.ar = None
        self.set_out_var("results_container", rc)
Example #2
0
    def build_result_collection(self, exp):
        rc = ResultsContainer(base_dir=exp.get_data_folder(),
                              base_filename="%s" % self.uuid)
        res_seq = self.res_seq

        axis_meta_block = self.base_name
        axis_meta_block_labels = self.get_fold_labels()

        def create_new_dim_rc(local_rc):
            local_rc.axis_list = [axis_meta_block]
            local_rc.labels_dict[axis_meta_block] = axis_meta_block_labels

            local_rc.init_ar()
            local_rc.update_label_index()

        # WARNING: We only support homogeneous results, so we only check first element
        res_seq_field_name, data_type = res_seq.fields.iteritems().next()
        if data_type == "ClassifierResult":
            single_rc_list = []
            for field_name in res_seq.fields:
                rc_single = ResultsContainer("", "")
                create_new_dim_rc(rc_single)

                for idx, res_seq_cell in enumerate(res_seq.sequence):
                    rc_single.ar[idx] = res_seq_cell[field_name]
                single_rc_list.append(rc_single)

            rc.add_dim_layer(single_rc_list, self.collector_spec.label,
                             res_seq.fields.keys())

        elif data_type == "ResultsContainer":
            if len(res_seq.fields) > 1:
                raise Exception(
                    "Meta block only support single output of type ResultsContainer"
                )

            else:
                rc_list = []
                for cell in res_seq.sequence:
                    sub_rc = cell[res_seq_field_name]
                    sub_rc.load()
                    rc_list.append(sub_rc)

                rc.add_dim_layer(rc_list, self.base_name,
                                 self.get_fold_labels())

        elif data_type == "SequenceContainer":
            # TODO remove this check
            pass
        else:
            raise Exception("Meta blocks only support ClassifierResult "
                            "or ResultsContainer in the output collection. "
                            " Instead got: %s" % data_type)

        rc.store()
        rc.ar = None
        self.set_out_var("results_container", rc)
Example #3
0
    def build_result_collection(self, exp):
        rc = ResultsContainer(
            base_dir=exp.get_data_folder(),
            base_filename="%s" % self.uuid
        )
        res_seq = self.res_seq

        axis_meta_block = self.base_name
        axis_meta_block_labels = self.get_fold_labels()


        def create_new_dim_rc(local_rc):
            local_rc.axis_list = [axis_meta_block]
            local_rc.labels_dict[axis_meta_block] = axis_meta_block_labels

            local_rc.init_ar()
            local_rc.update_label_index()

        # WARNING: We only support homogeneous results, so we only check first element
        res_seq_field_name, data_type = res_seq.fields.iteritems().next()
        if data_type == "ClassifierResult":
            single_rc_list = []
            for field_name in res_seq.fields:
                rc_single = ResultsContainer("", "")
                create_new_dim_rc(rc_single)

                for idx, res_seq_cell in enumerate(res_seq.sequence):
                    rc_single.ar[idx] = res_seq_cell[field_name]
                single_rc_list.append(rc_single)

            rc.add_dim_layer(single_rc_list, self.collector_spec.label, res_seq.fields.keys())

        elif data_type == "ResultsContainer":
            if len(res_seq.fields) > 1:
                raise Exception("Meta block only support single output of type ResultsContainer")

            else:
                rc_list = []
                for cell in res_seq.sequence:
                    sub_rc = cell[res_seq_field_name]
                    sub_rc.load()
                    rc_list.append(sub_rc)

                rc.add_dim_layer(rc_list, self.base_name, self.get_fold_labels())

        elif data_type == "SequenceContainer":
            # TODO remove this check
            pass
        else:
            raise Exception("Meta blocks only support ClassifierResult "
                            "or ResultsContainer in the output collection. "
                            " Instead got: %s" % data_type)

        rc.store()
        rc.ar = None
        self.set_out_var("results_container", rc)