Package edu.pitt.ontology

Examples of edu.pitt.ontology.IOntology


   
    // assign code and name
    this.code = ""+cls.getURI();
    this.name = name;
   
    IOntology ontology = cls.getOntology();
    setDefinitions(getDefinitions(cls));
    setSources(new Source[] {new Source(ontology.getName(),ontology.getDescription(),""+ontology.getURI())});
    Set<String> labels = new LinkedHashSet<String>();
    labels.add(name);
    Collections.addAll(labels,cls.getLabels());
    setSynonyms(labels.toArray(new String [0]));
    if(ontology instanceof Terminology)
View Full Code Here


   * @return
   */
  public static boolean isOfParent(IClass cls,String parent){
    if(cls == null)
      return false;
    IOntology o = cls.getOntology();
    IClass p = o.getClass(parent);
    return cls.equals(p) || cls.hasSuperClass(p);
  }
View Full Code Here

        }
        for(int i=0;i<semTypeList.getModel().getSize();i++){
          semanticTypeFilter.add(SemanticType.getSemanticType(""+semTypeList.getModel().getElementAt(i)));
        }
        try {
          IOntology ont = POntology.createOntology(URI.create(defaultURI+ontologyFile.getName()),ontologyFile.getParentFile());
          export(term,rootFilter,semanticTypeFilter,ont);
          ont.save();
        } catch (Exception e) {
          console.append("Error: "+e.getMessage()+"\n");
          JOptionPane.showMessageDialog(main,"Problems encounted during export","Error",JOptionPane.ERROR_MESSAGE);
          e.printStackTrace();
        }
View Full Code Here

  private void exportConcept(Concept c, List<SemanticType> semanticTypeFilter,String prefix, IClass parent) throws Exception {
    // first make sure that it fits the filter
    if(isFilteredOut(c, semanticTypeFilter)){
      return;
    }
    IOntology ont = parent.getOntology();
    String clsName = getClassName(c.getName());
    IClass cls = ont.getClass(clsName);
    // if class exists, then we have a cycle, just add a parent and quit
    if(cls != null){
      if(!(cls.equals(parent) || cls.hasSuperClass(parent) || cls.hasSubClass(parent)))
        cls.addSuperClass(parent);
      return;
View Full Code Here

      pmap.put("hierarchySources",hsrc);
      terminology.loadRRF(f,pmap);
      name = (name == null)?f.getName():name;
    }else if(owl != null){
      log("Loading OWL terminology from "+owl+"...");
      IOntology ont = POntology.loadOntology(owl);
      if(ont != null){
        terminology.loadOntology(ont,name);
      }
      name = (name == null)?ont.getName():name;
    }else if(obo != null){
      log("Loading OBO terminology from "+obo+"...");
      if(name == null){
        name = (new File(obo)).getName();
        if(name.endsWith(".obo"))
          name = name.substring(0,name.length()-4);
      }
      terminology.load(name);
      ConceptImporter.getInstance().addPropertyChangeListener(this);
      ConceptImporter.getInstance().loadOBO(terminology,new File(obo));
      ConceptImporter.getInstance().removePropertyChangeListener(this);
      terminology.save();
    }else if(bioportal != null){
      log("Loading BioPortal terminology from "+bioportal+"...");
      BioPortalRepository r = new BioPortalRepository();
      IOntology ont = r.getOntology(URI.create(bioportal));
      if(ont != null){
        ont.addPropertyChangeListener(this);
        terminology.loadOntology(ont,name);
      }
      name = (name == null)?ont.getName():name;
    }else if(txt != null){
      log("Loading Text terminology from "+txt+"...");
      File f = new File(txt);
      terminology.loadText(f,name);
      name = (name == null)?f.getName():name;
View Full Code Here

   * create a template object from SlideTutor ontology
   * @param url
   * @return
   */
  private void addSlideTutorTemplates(String url) throws Exception {
    IOntology ont = POntology.loadOntology(url);
    ConceptRegistry.REGISTRY.put(url,SlideTutorConcept.class.getName());
   
    // create in-memory terminology from this ontology
    IndexFinderTerminology term = new IndexFinderTerminology();
    term.loadOntology(ont,null,true,true);
    term.setScoreConcepts(false);
    term.setSelectBestCandidate(false);
    term.setCachingEnabled(false);
   
    IndexFinderTerminology aterm = new IndexFinderTerminology();
    aterm.loadOntology(POntology.loadOntology(ANATOMY_ONTOLOGY_URI),null,true,true);
    aterm.setCachingEnabled(false);
   
    // add a terminology to it
    CompositTerminology terminology = new CompositTerminology();
    terminology.addTerminology(term);
    terminology.addTerminology(aterm);
   
   
    // go over templates
    for(IClass template: ont.getClass("TEMPLATES").getDirectSubClasses()){
      // get orders
      final Map<String,Integer> conceptOrder = new HashMap<String,Integer>();
      for(Object o: template.getPropertyValues(ont.getProperty("order"))){
        String [] p = o.toString().split(":");
        if(p.length == 2){
          conceptOrder.put(p[0].trim(),new Integer(p[1].trim()));
        }
      }
      // get triggers
      //TODO:
     
      // get template contents
      List<IClass> templateContent = new ArrayList<IClass>();
      for(IRestriction r: template.getRestrictions(ont.getProperty("hasPrognostic"))){
        IClass c = (IClass) r.getParameter().getOperand();
        templateContent.add(c);
      }
     
      // sort them in order
View Full Code Here

   * create a template item from a given class
   * @param c
   * @return
   */
  private static TemplateItem convertSlideTutorClass(IClass c, Template template) {
    IOntology ont = c.getOntology();
    TemplateItem item = new TemplateItem();
    item.setTemplate(template);
    item.setConcept(c.getConcept());
    item.getConcept().setCode(getCode(item.getConcept().getCode(),true));
    item.setValueDomain(TemplateItem.DOMAIN_BOOLEAN);
   
    // figure out type
    if(isFeature(c)){
      item.setType(TemplateItem.TYPE_FINDING);
    }else if(isAttributeCategory(c)){
      item.setType(TemplateItem.TYPE_ATTRIBUTE);
    }else if(isLocation(c)){
      item.setType(TemplateItem.TYPE_ATTRIBUTE_VALUE);
    }else if(isNumber(c)){
      item.setType(TemplateItem.TYPE_NUMERIC_VALUE);
    }else if(isModifier(c)){
      item.setType(TemplateItem.TYPE_MODIFIER);
    }else if(isDisease(c)){
      item.setType(TemplateItem.TYPE_DIAGNOSIS);
      item.setValueDomain(TemplateItem.DOMAIN_SELF);
    }
   
    // if feature process attributes
    if(isFeature(c)){
      IClass feature = getFeature(c)
     
      if(!feature.equals(c)){
        item.setFeature(convertSlideTutorClass(feature,template));
       
        // if feature is a child of value then, it is a fully specified feature attr/value, and
        // we just need a feature
        if(isOfParent(c,VALUES))
          item = item.getFeature();
       
        // if we have a more general feature specified, then
       
      }
     
      // process potential attributes
      for(IClass attribute: getPotentialTemplateAttributes(c)){
        // if used attribute, skip
        //if(!usedAttributes.contains(attribute))
        //  continue;
       
        TemplateItem a = convertSlideTutorClass(attribute,template);
        // handle numbers
        if(isNumber(attribute)){
          item.getValues().add(a);
          item.setValueDomain(TemplateItem.DOMAIN_VALUE);
        // handle units
        }else if(isOfParent(attribute,"UNITS")){
          item.getUnits().add(a);
        // handle locations
        }else if(isLocation(attribute)){
          TemplateItem l = convertSlideTutorClass(ont.getClass(LOCATIONS), template);
          item.addAttributeValue(l,a);
        // handle attributes with categories and modifiers
        }else if(isModifier(attribute)){
          if(!attribute.hasSubClass(c))
            item.setValueDomain(TemplateItem.DOMAIN_ATTRIBUTE);
          for(IClass  acat : attribute.getDirectSuperClasses()){
            if(isAttributeCategory(acat) && !acat.equals(ont.getClass(MODIFIERS))){
              TemplateItem l = convertSlideTutorClass(acat, template);
              item.addAttributeValue(l, a);
            }else{
              item.addModifier(a);
            }
          }
        }else{
          //System.err.println(attribute);
        }
      }
     
      // do something special for worksheet?
      if(isWorksheet(c)){
        item.setValueDomain(TemplateItem.DOMAIN_SELF);
      }else if(isHeader(c)){
        item.setValueDomain(TemplateItem.DOMAIN_SELF);
      }
     
      // anatomic location? 
      if(isAnatomicLocation(c)){
        item.setType(TemplateItem.TYPE_ORGAN);
        String code = getCode((String) c.getPropertyValue(ont.getProperty("code")),true);
        if(code != null){
          String cd = (code.indexOf("#") > -1)?code.substring(0,code.lastIndexOf("#")):code;
          String nm = (cd.indexOf("/") > -1)?cd.substring(cd.lastIndexOf("/")+1):cd;
          Source src = new Source(nm, "", cd);
          try {
View Full Code Here

   * @return
   */
  public static boolean isOfParent(IClass cls,String parent){
    if(cls == null)
      return false;
    IOntology o = cls.getOntology();
    IClass p = o.getClass(parent);
    return cls.equals(p) || cls.hasSuperClass(p);
  }
View Full Code Here

            String name = n.getTextContent().trim();
            //String uri =  ouri+"#"+name;
            //IClass cls = (IClass) repository.getResource(URI.create(uri));
           
            //if(cls == null){
            IOntology ont = repository.getOntology(URI.create(ouri));
            if(ont != null){
              IClass cls = new BClass((BOntology)ont,name);
              cls.getConcept().setTerminology(this);
              cls.getConcept().setSearchString(text);
              list.add(cls.getConcept());
View Full Code Here

public class FMAConcept extends Concept {
  public FMAConcept(IClass cls) {
    super(cls);
   
    // 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

TOP

Related Classes of edu.pitt.ontology.IOntology

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.