예제 #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();
        }
예제 #2
0
            protected Frame GetTargetFrame(XrefExpander expander, string id)
            {
                OBODoc targetDoc = expander.GetTargetDoc(OWLAPIPreconditions.VerifyNotNull(IdSpace, "idSpace not set yet"));
                Frame? f         = targetDoc.GetTermFrame(id);

                if (f == null)
                {
                    f = new Frame
                    {
                        Id = id
                    };
                    try
                    {
                        targetDoc.AddTermFrame(f);
                    }
                    catch (FrameMergeException e)
                    {
                        // this should be impossible
                        LOGGER.Error("Frame merge exceptions should not be possible", e);
                    }
                }
                return(f);
            }
예제 #3
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);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
 public XrefExpander(OBODoc src, OBODoc tgt)
 {
     sourceOBODoc = src;
     targetOBODoc = tgt;
     SetUp();
 }
예제 #5
0
 public XrefExpander(OBODoc src, string targetBase)
 {
     sourceOBODoc    = src;
     this.targetBase = targetBase;
     SetUp();
 }