Package edu.pitt.ontology

Examples of edu.pitt.ontology.IProperty


    for(Definition d: c.getDefinitions()){
      cls.addComment(d.getDefinition());
    }
   
    // get concept code
    IProperty code = getProperty(ont,"code");
    cls.setPropertyValue(code,c.getCode());
   
    // get semantic types
    IProperty stype = getProperty(ont,"SemanticType");
    for(SemanticType st: c.getSemanticTypes())
      cls.addPropertyValue(stype,st.getName());
   
    // output
    console.append(prefix+c.getName()+"\n");
View Full Code Here


   * @param ont
   * @param name
   * @return
   */
  private IProperty getProperty(IOntology ont, String name){
    IProperty code = ont.getProperty(name);
    if(code == null){
      code = ont.createProperty(name,IProperty.ANNOTATION_DATATYPE);
      code.setRange(new String [0]);
    }
    return code;
  }
View Full Code Here

   
    // not lets do NCI Thesaurus specifics
    IOntology ont = cls.getOntology();
   
    // do codes
    IProperty code_p = ont.getProperty("FMAID");
    if(code_p != null){
      Object [] val = cls.getPropertyValues(code_p);
      if(val.length > 0)
        addCode(val[0].toString(),new Source("FMA"));
    }
    IProperty umls_p = ont.getProperty("UMLS_ID");
    if(umls_p != null){
      Object [] val = cls.getPropertyValues(umls_p);
      if(val.length > 0)
        addCode(val[0].toString(),new Source("UMLS"));
    }
   
    // do definitions
    List<Definition> deflist = new ArrayList<Definition>();
    IProperty def_p = ont.getProperty("definition");
    if(def_p != null){
      for(Object val : cls.getPropertyValues(def_p)){
        Definition d = new Definition(val.toString());
        deflist.add(d);
      }
View Full Code Here

   
    // not lets do NCI Thesaurus specifics
    IOntology ont = cls.getOntology();
   
    // do preferred name
    IProperty pn_p = ont.getProperty("Preferred_Name");
    if(pn_p != null){
      Object [] val = cls.getPropertyValues(pn_p);
      if(val.length > 0)
        setName(val[0].toString());
    }
   
    // do synonyms
    IProperty syn_p = ont.getProperty("FULL_SYN");
    if(syn_p != null){
      List<Term> terms = new ArrayList<Term>();
      Set<String> syns = new LinkedHashSet<String>();
      Collections.addAll(syns,getSynonyms());
      for(Object val : cls.getPropertyValues(syn_p)){
        Pattern pt = Pattern.compile(".*<.*:term-name>(.*)</.*:term-name><.*:term-group>(.*)</.*:term-group><.*:term-source>(.*)</.*:term-source>.*");
        Matcher mt = pt.matcher(val.toString());
        if(mt.matches()){
          String text  = mt.group(1);
          String group = mt.group(2);
          String src   = mt.group(3);
         
          Term term = new Term(text);
          term.setForm(group);
          term.setSource(new Source(src));
         
          terms.add(term);
          syns.add(text);
        }
      }
      setTerms(terms.toArray(new Term [0]));
      setSynonyms(syns.toArray(new String [0]));
    }
       
    // do definitions
    List<Definition> deflist = new ArrayList<Definition>();
    IProperty def_p = ont.getProperty("DEFINITION");
    if(def_p != null){
      for(Object val : cls.getPropertyValues(def_p)){
        Pattern pt = Pattern.compile(".*<.*:def-definition>(.*)</.*:def-definition><.*:def-source>(.*)</.*:def-source>.*");
        Matcher mt = pt.matcher(val.toString());
        if(mt.matches()){
          String text  = mt.group(1);
          String src   = mt.group(2);
         
          Definition d = new Definition(text);
          d.setSource(new Source(src));
          deflist.add(d);
        }
      }
    }
   
    IProperty adef_p = ont.getProperty("ALT_DEFINITION");
    if(adef_p != null){
      for(Object val : cls.getPropertyValues(adef_p)){
        Pattern pt = Pattern.compile(".*<.*:def-definition>(.*)</.*:def-definition><.*:def-source>(.*)</.*:def-source>.*");
        Matcher mt = pt.matcher(val.toString());
        if(mt.matches()){
          String text  = mt.group(1);
          String src   = mt.group(2);
         
          Definition d = new Definition(text);
          d.setSource(new Source(src));
          deflist.add(d);
        }
      }
    }
   
    setDefinitions(deflist.toArray(new Definition [0]));
   
    // do semantic type
    IProperty sem_p = ont.getProperty("Semantic_Type");
    if(sem_p != null){
      Object [] val = cls.getPropertyValues(sem_p);
      SemanticType [] types = new SemanticType [val.length];
      for(int i=0;i<val.length;i++){
        types[i] = new SemanticType(val[i].toString());
      }
      setSemanticTypes(types);
    }
   
    // do codes
    IProperty code_p = ont.getProperty("code");
    if(code_p != null){
      Object [] val = cls.getPropertyValues(code_p);
      if(val.length > 0){
        addCode(val[0].toString(),new Source("NCI"));
      }
    }
   
    IProperty umls_p = ont.getProperty("UMLS_CUI");
    if(umls_p != null){
      Object [] val = cls.getPropertyValues(umls_p);
      if(val.length > 0){
        addCode(val[0].toString(),new Source("UMLS"));
      }
    }
   
    IProperty nci_p = ont.getProperty("NCI_META_CUI");
    if(nci_p != null){
      Object [] val = cls.getPropertyValues(nci_p);
      if(val.length > 0){
        addCode(val[0].toString(),new Source("NCI_META"));
      }
View Full Code Here

   
    // not lets do NCI Thesaurus specifics
    IOntology ont = cls.getOntology();
   
    // do code
    IProperty code_p = ont.getProperty(BioPortalHelper.CODE);
    if(code_p != null){
      for(Object val : cls.getPropertyValues(code_p)){
        addCode(val.toString(),new Source(val.toString()));
      }
    }
   
    // do sem type
    IProperty sem_p = ont.getProperty(BioPortalHelper.SEMANTIC_TYPE);
    if(sem_p != null){
      Object [] val = cls.getPropertyValues(sem_p);
      SemanticType [] types = new SemanticType [val.length];
      for(int i=0;i<val.length;i++){
        types[i] = new SemanticType(val[i].toString());
View Full Code Here

    for(IProperty sp : src.getProperties()){
      String name = sp.getName();
      // skip properties that are incorrectly named
      if(!name.matches("\\w+"))
        continue;
      IProperty tp = target.getProperty(name);
      if(tp == null && !target.hasResource(name)){
        tp = target.createProperty(name,sp.getPropertyType());
       
        // notify of progress
        String msg = "Copying property "+name+" ...";
        pcs.firePropertyChange(PROPERTY_PROGRESS_MSG, progressMessage, msg);
        progressMessage = msg;
       
       
       
        // copy stuff
        copyResourceInfo(sp,tp);
       
        // copy booleans
        tp.setFunctional(sp.isFunctional());
        tp.setTransitive(sp.isTransitive());
        tp.setSymmetric(sp.isSymmetric());
       
        // copy domain and ranges
        tp.setDomain((IResource []) convertResources(target,sp.getDomain(),IResource.class));
        tp.setRange(convertResources(target,sp.getRange()));
      }
    }
   
    // set rest of properties properties
    for(IProperty sp : src.getProperties()){
      String name = sp.getName();
      // skip properties that are incorrectly named
      if(!name.matches("\\w+"))
        continue;
     
      IProperty tp = target.getProperty(name);
      if(tp != null){
        tp.setInverseProperty((IProperty)convertResource(target,sp.getInverseProperty()));
        IProperty [] sub = sp.getSubProperties();
        if(sub != null && sub.length > 0){
          for(IProperty p: (IProperty []) convertResources(target,sub,IProperty.class)){
            tp.addSubProperty(p);
          }
        }
        IProperty [] sup = sp.getSuperProperties();
        if(sup != null && sup.length > 0){
          for(IProperty p: (IProperty []) convertResources(target,sup,IProperty.class)){
            tp.addSuperProperty(p);
          }
        }
       
      }
    }
View Full Code Here

    IClass cls = ont.getClass(name);
    // if exists, then do the magic
    if(cls != null){
      // copy property values
      for(IProperty sp: source.getProperties()){
        IProperty tp = (IProperty) convertResource(ont,sp);
        if(tp != null){
          // set property values
          if(tp.isFunctional())
            cls.setPropertyValue(tp,convertResource(ont,source.getPropertyValue(sp)));
          else
            cls.setPropertyValues(tp,convertResources(ont,source.getPropertyValues(sp)));
         
       
      }
     
      // copy disjoints
      for(IClass c: source.getDisjointClasses()){
        cls.addDisjointClass((IClass)convertResource(ont,c));
      }
     
      // copy necessary restrictions
      ILogicExpression exp = source.getNecessaryRestrictions();
      if(exp.getExpressionType() == ILogicExpression.OR){
        cls.addSuperClass(ont.createClass((ILogicExpression) convertResource(ont,exp)));
      }else{
        for(Object c: exp){
          if(c instanceof IRestriction)
            cls.addNecessaryRestriction((IRestriction)convertResource(ont,c));
          else if(c instanceof IClass)
            cls.addSuperClass((IClass) convertResource(ont,c));
          else if(c instanceof ILogicExpression)
            cls.addSuperClass(ont.createClass((ILogicExpression) convertResource(ont,exp)));   
        }
      }
     
      // copy equivalent restrictions
      exp = source.getEquivalentRestrictions();
      if(exp.getExpressionType() == ILogicExpression.OR){
        cls.addEquivalentClass(ont.createClass((ILogicExpression) convertResource(ont,exp)));
      }else{
        for(Object c: exp){
          if(c instanceof IRestriction)
            cls.addEquivalentRestriction((IRestriction)convertResource(ont,c));
          else if(c instanceof IClass)
            cls.addEquivalentClass((IClass) convertResource(ont,c));
          else if(c instanceof ILogicExpression)
            cls.addEquivalentClass(ont.createClass((ILogicExpression) convertResource(ont,exp)));
         
        }
      }
           
      // copy instances
      for(IInstance inst: source.getDirectInstances()){
        IInstance i = ont.getInstance(inst.getName());
        if(i == null){
          i = cls.createInstance(inst.getName());
          // copy property values
          for(IProperty sp : inst.getProperties()){
            IProperty tp = (IProperty) convertResource(ont,sp);
            if(tp != null){
              if(tp.isFunctional())
                i.setPropertyValue(tp,convertResource(ont,inst.getPropertyValue(sp)));
              else
                i.setPropertyValues(tp,convertResources(ont,inst.getPropertyValues(sp)));
            }
          }
View Full Code Here

      if(e instanceof IClass){
        IClass cls = (IClass) e;
        buffer.append("<b>Equivalent: </b> "+Arrays.asList(cls.getEquivalentClasses())+"<br>");
        buffer.append("<b>Disjoint: </b> "+Arrays.asList(cls.getDisjointClasses())+"<br>");
      }else if(e instanceof IProperty){
        IProperty cls = (IProperty) e;
        buffer.append("<b>Domain: </b> "+Arrays.asList(cls.getDomain())+"<br>");
        buffer.append("<b>Range: </b> "+Arrays.asList(cls.getRange())+"<br>");
      }else if(e instanceof IInstance){
        IInstance cls = (IInstance) e;
        buffer.append("<b>Types: </b> "+Arrays.asList(cls.getTypes())+"<br>");
      }
      buffer.append("<b>Properties:</b>");
      IProperty[] p = e.getProperties();
      if(p.length > 0){
        buffer.append("<ul>");
View Full Code Here

        }
        buffer.append("</td></tr>");
      }
     
    }else if(e instanceof IProperty){
      IProperty cls = (IProperty) e;
      buffer.append("<tr valign=top><td><b>Domain: </b></td><td>"+
          toHTML(cls.getDomain())+"</td></tr>");
      buffer.append("<tr valign=top><td><b>Range: </b></td><td>"+
          toHTML(cls.getRange())+"</td></tr>");
    }else if(e instanceof IInstance){
      IInstance cls = (IInstance) e;
      buffer.append("<tr valign=top><td><b>Types: </b></td><td>"+
          toHTML(cls.getDirectTypes())+"</td></tr>");
    }
   
    IProperty[] p = e.getProperties();
    if(p.length > 0){
      buffer.append("<tr valign=top><td><b>Properties:</b>");
View Full Code Here

    pcs.firePropertyChange(ONTOLOGY_LOAD_STAGE,null,ONTOLOGY_LOAD_STAGE_BUILDHIERARCHY);
    pcs.firePropertyChange(ONTOLOGY_LOADING_EVENT,null,"Creating Hierarchy ...");
   
   
    // create some important properties
    IProperty partOf = target.getProperty(PART_OF);
    if(partOf == null){
      partOf = target.createProperty(PART_OF,IProperty.OBJECT);
      partOf.setDomain(new IClass [] {target.getRoot()});
      partOf.setRange(new IClass [] {target.getRoot()});
    }
   
    IProperty hasPart = target.getProperty(HAS_PART);
    if(hasPart == null){
      hasPart = target.createProperty(HAS_PART,IProperty.OBJECT);
      hasPart.setDomain(new IClass [] {target.getRoot()});
      hasPart.setRange(new IClass [] {target.getRoot()});
    }
    // make them inverses of eachother
    hasPart.setInverseProperty(partOf);
    partOf.setInverseProperty(hasPart);
   
    // now that we have all classes, build a tree, since classes only have the superclasses set
    IResourceIterator it = target.getAllClasses();
    while(it.hasNext()){
      IClass cls = (IClass) it.next();
     
      long time = System.currentTimeMillis();
     
      // now copy equivalent classes classes
      IProperty p = target.getProperty(EQUIVALENT_CLASS);
      if(p != null){
        for(IClass sibling: getClassList(target,cls.getPropertyValues(p))){
          cls.addEquivalentClass(sibling);
        }
        // remove temporary property
View Full Code Here

TOP

Related Classes of edu.pitt.ontology.IProperty

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.