Esempio n. 1
0
def test_gene_product_annotation_presence(model):
    """
    Expect all genes to have a non-empty annotation attribute.

    This test checks if any annotations at all are present in the SBML
    annotations field (extended by FBC package) for each gene product,
    irrespective of the type of annotation i.e. specific database,
    cross-references, ontology terms, additional information. For this test to
    pass the model is expected to have genes and each of them should have some
    form of annotation.

    Implementation:
    Check if the annotation attribute of each cobra.Gene object of the
    model is unset or empty.

    """
    ann = test_gene_product_annotation_presence.annotation
    ann["data"] = get_ids(annotation.find_components_without_annotation(
        model, "genes"))
    ann["metric"] = len(ann["data"]) / len(model.genes)
    ann["message"] = wrapper.fill(
        """A total of {} genes ({:.2%}) lack any form of
        annotation: {}""".format(
            len(ann["data"]), ann["metric"], truncate(ann["data"])))
    assert len(ann["data"]) == 0, ann["message"]
Esempio n. 2
0
def test_gene_product_annotation_presence(model):
    """
    Expect all genes to have a non-empty annotation attribute.

    This test checks if any annotations at all are present in the SBML
    annotations field (extended by FBC package) for each gene product,
    irrespective of the type of annotation i.e. specific database,
    cross-references, ontology terms, additional information. For this test to
    pass the model is expected to have genes and each of them should have some
    form of annotation.

    Implementation:
    Check if the annotation attribute of each cobra.Gene object of the
    model is unset or empty.

    """
    ann = test_gene_product_annotation_presence.annotation
    ann["data"] = get_ids(
        annotation.find_components_without_annotation(model, "genes"))
    ann["metric"] = len(ann["data"]) / len(model.genes)
    ann["message"] = wrapper.fill(
        """A total of {} genes ({:.2%}) lack any form of
        annotation: {}""".format(len(ann["data"]), ann["metric"],
                                 truncate(ann["data"])))
    assert len(ann["data"]) == 0, ann["message"]
Esempio n. 3
0
def test_reaction_annotation_presence(read_only_model, store):
    """Expect all reactions to have a non-empty annotation attribute."""
    store["reactions_without_annotation"] = [
        rxn.id for rxn in annotation.find_components_without_annotation(
            read_only_model, "reactions")
    ]
    assert len(store["reactions_without_annotation"]) == 0, \
        "The following reactions lack any form of annotation: " \
        "{}".format(", ".join(store["reactions_without_annotation"]))
Esempio n. 4
0
def test_metabolite_annotation_presence(read_only_model, store):
    """Expect all metabolites to have a non-empty annotation attribute."""
    store["metabolites_without_annotation"] = [
        met.id for met in annotation.find_components_without_annotation(
            read_only_model, "metabolites")
    ]
    assert len(store["metabolites_without_annotation"]) == 0, \
        "The following metabolites lack any form of annotation: " \
        "{}".format(", ".join(store["metabolites_without_annotation"]))
Esempio n. 5
0
def test_reaction_annotation_presence(read_only_model):
    """
    Expect all reactions to have a non-empty annotation attribute.

    This test checks if any annotations at all are present in the SBML
    annotations field for each reaction, irrespective of the type of
    annotation i.e. specific database  cross-references, ontology terms,
    additional information. For this test to pass the model is expected to
    have reactions and each of them should have some form of annotation.
    """
    ann = test_reaction_annotation_presence.annotation
    ann["data"] = get_ids(
        annotation.find_components_without_annotation(read_only_model,
                                                      "reactions"))
    ann["metric"] = len(ann["data"]) / len(read_only_model.reactions)
    ann["message"] = wrapper.fill(
        """A total of {} reactions ({:.2%}) lack any form of annotation:
        {}""".format(len(ann["data"]), ann["metric"], truncate(ann["data"])))
    assert len(ann["data"]) == 0, ann["message"]
Esempio n. 6
0
def test_find_components_without_annotation(model, num, components):
    """Expect `num` components to have no annotation."""
    without_annotation = annotation.find_components_without_annotation(
        model, components)
    assert len(without_annotation) == num