Exemple #1
0
        public XrefExpander(OBODoc src)
        {
            sourceOBODoc = src;
            Frame  shf      = OWLAPIPreconditions.CheckNotNull(src.HeaderFrame);
            string?ontId    = shf.GetTagValue <string>(OboFormatTag.TAG_ONTOLOGY);
            string tgtOntId = ontId + "/xref_expansions";

            targetOBODoc = new OBODoc();
            Frame thf = new Frame(FrameType.HEADER);

            thf.AddClause(new Clause(OboFormatTag.TAG_ONTOLOGY, tgtOntId));
            targetOBODoc.HeaderFrame = thf;
            sourceOBODoc.AddImportedOBODoc(targetOBODoc);
            SetUp();
        }
Exemple #2
0
        public void SetUp()
        {
            // required for translation of IDs
            IDictionary <string, string> relationsUseByIdSpace = new Dictionary <string, string>();
            Frame?headerFrame = sourceOBODoc.HeaderFrame;

            if (headerFrame != null)
            {
                foreach (Clause c in headerFrame.GetClauses())
                {
                    string[] parts;
                    string   v = c.Value().ToString();
                    parts = v.Split("\\s");
                    string?relation = null;
                    string idSpace  = parts[0];
                    string?tag      = c.Tag;
                    if (tag == null)
                    {
                        continue;
                    }
                    if (tag.Equals(OboFormatTag.TAG_TREAT_XREFS_AS_EQUIVALENT.Tag))
                    {
                        AddRule(parts[0], new EquivalenceExpansion());
                    }
                    else if (tag.Equals(OboFormatTag.TAG_TREAT_XREFS_AS_GENUS_DIFFERENTIA.Tag))
                    {
                        AddRule(idSpace, new GenusDifferentiaExpansion(parts[1], parts[2]));
                        relationsUseByIdSpace[idSpace] = parts[1];
                        relation = parts[1];
                    }
                    else if (tag.Equals(OboFormatTag.TAG_TREAT_XREFS_AS_REVERSE_GENUS_DIFFERENTIA.Tag))
                    {
                        AddRule(idSpace, new ReverseGenusDifferentiaExpansion(parts[1], parts[2]));
                        relationsUseByIdSpace[idSpace] = parts[1];
                        relation = parts[1];
                    }
                    else if (tag.Equals(OboFormatTag.TAG_TREAT_XREFS_AS_HAS_SUBCLASS.Tag))
                    {
                        AddRule(idSpace, new HasSubClassExpansion());
                    }
                    else if (tag.Equals(OboFormatTag.TAG_TREAT_XREFS_AS_IS_A.Tag))
                    {
                        AddRule(idSpace, new IsaExpansion());
                    }
                    else if (tag.Equals(OboFormatTag.TAG_TREAT_XREFS_AS_RELATIONSHIP.Tag))
                    {
                        AddRule(idSpace, new RelationshipExpansion(parts[1]));
                        relationsUseByIdSpace[idSpace] = parts[1];
                        relation = parts[1];
                    }
                    else
                    {
                        continue;
                    }
                    if (targetBase != null)
                    {
                        // create a new bridge ontology for every expansion macro
                        OBODoc tgt = new OBODoc();
                        Frame  thf = new Frame(FrameType.HEADER);
                        thf.AddClause(new Clause(OboFormatTag.TAG_ONTOLOGY,
                                                 targetBase + "-" + idSpace.ToLower()));
                        tgt.HeaderFrame       = thf;
                        targetDocMap[idSpace] = tgt;
                        sourceOBODoc.AddImportedOBODoc(tgt);
                        if (relation != null)
                        {
                            // See 4.4.2
                            // "In addition, any Typedef frames for relations used
                            // in a header macro are also copied into the
                            // corresponding bridge ontology
                            Frame?tdf = sourceOBODoc.GetTypedefFrame(relation);
                            if (tdf != null)
                            {
                                try
                                {
                                    tgt.AddTypedefFrame(tdf);
                                }
                                catch (FrameMergeException e)
                                {
                                    LOGGER.Debug("frame merge failed", e);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #3
0
            public override void Expand(XrefExpander expander, Frame sf, string id, string xRef)
            {
                Clause c = new Clause(OboFormatTag.TAG_EQUIVALENT_TO, xRef);

                sf.AddClause(c);
            }