Beispiel #1
0
def test_gaf_gpi_bridge():
    gaf = ["MGI", "MGI:1923503", "0610006L08Rik", "enables", "GO:0003674", "MGI:MGI:2156816|GO_REF:0000015", "ND", "",
           "F", "RIKEN cDNA 0610006L08 gene", "", "gene", "taxon:10090", "20120430", "MGI", "", ""]
    association = gafparser.to_association(gaf, qualifier_parser=assocparser.Qualifier2_2()).associations[0]
    bridge = gafgpibridge.GafGpiBridge()
    entity = bridge.convert_association(association)
    assert entity.get("type") == ["gene"]
Beispiel #2
0
def make_annotation(db="blah",
                    db_id="blah12345",
                    db_obj_symb="blah",
                    qualifier="",
                    negated=False,
                    goid="GO:1234567",
                    references="BLAH:54321",
                    evidence="IDA",
                    withfrom="BLAH:12345",
                    aspect="C",
                    db_obj_name="",
                    db_obj_syn="",
                    db_obj_type="blah",
                    taxon="taxon:12345",
                    date="20200330",
                    assigned_by="blah",
                    extension="",
                    gene_form_id="",
                    properties="",
                    version=None,
                    from_gaf=True):

    if from_gaf:
        qual_parse = assocparser.Qualifier2_1()
        if version == "2.2":
            qual_parse = assocparser.Qualifier2_2()

        annotation = [
            db, db_id, db_obj_symb, qualifier, goid, references, evidence,
            withfrom, aspect, db_obj_name, db_obj_syn, db_obj_type, taxon,
            date, assigned_by, extension, gene_form_id
        ]

        return gafparser.to_association(annotation,
                                        qualifier_parser=qual_parse)
    else:
        if version != "2.0":
            # Default to 1.2 if we're anything but 2.0
            annotation = [
                db, db_id, qualifier, goid, references, evidence, withfrom,
                taxon, date, assigned_by, extension, properties
            ]
            return gpadparser.to_association(annotation, version="1.2")
        else:
            annotation = [
                "{}:{}".format(db, db_id), "NOT" if negated else "", qualifier,
                goid, references, evidence, withfrom, taxon, date, assigned_by,
                extension, properties
            ]
            return gpadparser.to_association(annotation, version="2.0")
Beispiel #3
0
    def qualifier_parser(self) -> assocparser.ColumnValidator:
        if self.gaf_version() == "2.2":
            return assocparser.Qualifier2_2()

        return assocparser.Qualifier2_1()
Beispiel #4
0
from ontobio.ontol import Ontology

import dateutil.parser
import functools

import click

logger = logging.getLogger(__name__)




gaf_line_validators = {
    "default": assocparser.ColumnValidator(),
    "qualifier2_1": assocparser.Qualifier2_1(),
    "qualifier2_2": assocparser.Qualifier2_2(),
    "curie": assocparser.CurieValidator(),
    "taxon": assocparser.TaxonValidator()
}


def protein_complex_sublcass_closure(ontology: Ontology) -> Set[str]:
    protein_containing_complex = association.Curie(namespace="GO", identity="0032991")
    children_of_complexes = set(ontology.descendants(str(protein_containing_complex), relations=["subClassOf"], reflexive=True))
    return children_of_complexes


class GafParser(assocparser.AssocParser):
    """
    Parser for GO GAF format
    """