Пример #1
0
 def row_from_item(item):
     """ Return a row from an annotation item """
     return [
         LinkedItem(item.lastname, item),
         LinkedItem(item.firstname, item),
         LinkedItem(item.initials, item)
     ]
Пример #2
0
 def row_from_item(gene):
     """ Get the table row from the gene item """
     return [
         LinkedItem(gene.id, gene),
         LinkedItem(gene.name, gene),
         LinkedItem(gene.genome, gene)
     ]
Пример #3
0
    def row_from_item(setting):
        """ Get a row to be displayed in the table

        Parameters
        ----------
        setting : GEMEditor.data_classes.ReactionSetting

        Returns
        -------
        list
        """
        reaction_item = LinkedItem(setting.reaction.id, setting.reaction)
        reaction_item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)

        upper_bound_item = QStandardItem()
        upper_bound_item.setData(setting.upper_bound, 2)

        lower_bound_item = QStandardItem()
        lower_bound_item.setData(setting.lower_bound, 2)

        objective_item = QStandardItem()
        objective_item.setData(setting.objective_coefficient, 2)

        return [
            reaction_item, lower_bound_item, upper_bound_item, objective_item
        ]
Пример #4
0
    def row_from_item(setting):
        """ Get a row to be displayed in the table

        Parameters
        ----------
        setting : GEMEditor.data_classes.GeneSetting

        Returns
        -------
        list
        """
        gene_item = LinkedItem(setting.gene.id, setting.gene)
        gene_item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)

        if setting.activity is True:
            state = "active"
        elif setting.activity is False:
            state = "inactive"
        else:
            raise ValueError("Unknown state '{}' for gene activity.".format(
                str(setting.gene.functional)))

        activity_item = QStandardItem(state)

        return [gene_item, activity_item]
Пример #5
0
def iterate_tree(standard_item, data_item):
    for n, element in enumerate(
            sorted(data_item.children, key=lambda x: x.name)):
        gene_item = LinkedItem(element.name, element)
        gene_item.setEditable(False)
        standard_item.setChild(n, gene_item)
        iterate_tree(gene_item, element)
Пример #6
0
 def row_from_item(metabolite):
     """ Return a table row from the input metabolite """
     return [
         LinkedItem(metabolite.id, metabolite),
         LinkedItem(metabolite.name, metabolite),
         LinkedItem(metabolite.formula, metabolite),
         LinkedItem(str(metabolite.charge), metabolite),
         LinkedItem(metabolite.compartment, metabolite)
     ]
Пример #7
0
    def add_gene(self, gene):
        """ Buffer the addition of a gene to the genegroup and change the model"""
        table_item, model_item = self.get_selected_item()

        new_item = LinkedItem(text=gene.id, link=gene)
        new_item.setEditable(False)
        table_item.appendRow(new_item)
        self.cached_actions.append((model_item, "addition", gene))
        self.changed.emit()
Пример #8
0
 def row_from_item(input_tuple):
     """ Return the table row from an input item """
     metabolite, stoichiometry = input_tuple
     id_item = LinkedItem(metabolite.id, metabolite)
     id_item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
     id_item.setToolTip("Formula: {}\nCharge: {}".format(
         metabolite.formula, metabolite.charge))
     value_item = LinkedItem(link=metabolite)
     value_item.setData(stoichiometry, 2)
     return [id_item, value_item]
Пример #9
0
    def row_from_item(outcome):
        reaction_item = LinkedItem(outcome.reaction.id, outcome.reaction)
        reaction_item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)

        operator_item = QStandardItem(outcome.operator)

        flux_value_item = QStandardItem()
        flux_value_item.setData(outcome.value, 2)

        return [reaction_item, operator_item, flux_value_item]
Пример #10
0
    def row_from_item(self, reaction):
        status = LinkedItem(link=reaction)
        if reaction.balanced is True:
            status.setIcon(self.ok_icon)
        elif reaction.balanced is False:
            status.setIcon(self.error_icon)
        elif reaction.balanced == "Unknown":
            status.setIcon(self.unknown_icon)
        elif reaction.balanced is None:
            status.setIcon(self.undefined_icon)

        return ReactionBaseTable.row_from_item(reaction) + [status]
Пример #11
0
    def add_genegroup(self):
        """ Buffer the addition of a genegroup to the genegroup and change the model"""
        # Get current item
        table_item, model_item = self.get_selected_item()

        new_group = GeneGroup()
        new_item = LinkedItem(text=str(new_group.type).upper(), link=new_group)
        new_item.setEditable(False)
        table_item.appendRow(new_item)

        # Buffer the function call for when user accepts dialog
        self.cached_actions.append((model_item, "addition", new_group))
        self.changed.emit()
Пример #12
0
def iterate_tree(standard_item, data_item):
    for n, element in enumerate(data_item._children):
        if isinstance(element, Gene):
            gene_item = LinkedItem(element.id, element)
            gene_item.setEditable(False)
            standard_item.setChild(n, gene_item)
        elif isinstance(element, GeneGroup):
            new_item = LinkedItem(str(element.type).upper(), element)
            new_item.setEditable(False)
            iterate_tree(new_item, element)
            standard_item.setChild(n, new_item)
Пример #13
0
 def row_from_item(reference):
     return [
         LinkedItem(reference.reference_string(), reference),
         LinkedItem(reference.title, reference),
         LinkedItem(reference.journal, reference),
         LinkedItem(reference.year, reference),
         LinkedItem(reference.pmid, reference),
         LinkedItem(reference.pmc, reference),
         LinkedItem(reference.doi, reference),
         LinkedItem(reference.url, reference)
     ]
Пример #14
0
    def populate_tree(self):
        root_item = self.eco_tree.invisibleRootItem()

        # Get elements that dont have a parent
        top_level_elements = [x for x, y in all_ecos.items() if not y.parents]

        for i, name in enumerate(sorted(top_level_elements)):
            element = all_ecos[name]
            tree_item = LinkedItem(element.name, element)
            root_item.setChild(i, tree_item)
            iterate_tree(tree_item, element)
Пример #15
0
 def test_context_menu_gene(self):
     reaction = Reaction()
     model = Model()
     gene = Gene()
     self.widget.set_item(reaction, model)
     self.widget.geneTable.appendRow(LinkedItem("test", gene))
     assert self.widget.geneTable.rowCount() == 1
     index = self.widget.geneTable.item(0, 0).index()
     self.widget.geneView.setCurrentIndex(index)
     assert self.widget.get_selected_item()[1] is gene
     menu = self.widget.show_gene_contextmenu(QtCore.QPoint())
     assert self.widget.delete_action in menu.actions()
Пример #16
0
    def row_from_item(item):
        """ Get row from evidence item

        Parameters
        ----------
        item : GEMEditor.evidence_class.Evidence

        Returns
        -------
        list
        """

        target_id = item.target.id if item.target else "None"

        return [
            LinkedItem(item.entity.id, item),
            LinkedItem(item.assertion, item),
            LinkedItem(target_id),
            LinkedItem(item.eco, item),
            LinkedItem(item.comment, item),
            LinkedItem("; ".join(
                [x.reference_string() for x in item.references]))
        ]
Пример #17
0
 def row_from_item(compartment):
     id_item = LinkedItem(str(compartment.id), compartment)
     name_item = QStandardItem(str(compartment.name))
     return [id_item, name_item]
Пример #18
0
 def row_from_item(testcase):
     return [LinkedItem(testcase.description, testcase), LinkedItem()]
Пример #19
0
 def row_from_item(item):
     """ Return a row from an annotation item """
     display = LinkedItem(item.collection, item)
     identifier = LinkedItem(item.identifier, item)
     return [display, identifier]
Пример #20
0
 def row_from_item(reaction):
     """ Return a table row from the input reaction """
     id = LinkedItem(reaction.id, reaction)
     name = LinkedItem(reaction.name, reaction)
     reaction_str = LinkedItem(reaction.reaction, reaction)
     subsystem = LinkedItem(reaction.subsystem, reaction)
     lower_bound = LinkedItem(link=reaction)
     lower_bound.setData(reaction.lower_bound, 2)
     upper_bound = LinkedItem(link=reaction)
     upper_bound.setData(reaction.upper_bound, 2)
     obj_coeff = LinkedItem(link=reaction)
     obj_coeff.setData(reaction.objective_coefficient, 2)
     return [
         id, name, reaction_str, subsystem, lower_bound, upper_bound,
         obj_coeff
     ]