Ejemplo n.º 1
0
  private void populateParentChildMap(Map<String, SOTerm> soTerms, String parentSOTermName) {
    String parentClsName = TypeUtil.javaiseClassName(parentSOTermName);
    ClassDescriptor cd = model.getClassDescriptorByName(parentClsName);
    if (cd == null) {
      LOG.error("couldn't find class in model:" + parentClsName);
      return;
    }
    Class<?> parentClass = cd.getType();

    // all collections for gene
    Map<String, Class<?>> childCollections = model.getCollectionsForClass(parentClass);

    Set<CollectionHolder> children = new HashSet<CollectionHolder>();

    // for each collection, see if this is a child class
    for (Map.Entry<String, Class<?>> entry : childCollections.entrySet()) {

      String childCollectionName = entry.getKey();
      String childClassName = entry.getValue().getSimpleName();

      // TODO use same method as in the oboparser
      // is this a child collection? e.g. transcript
      SOTerm soterm = soTerms.get(childClassName.toLowerCase());

      if (soterm == null) {
        // for testing
        continue;
      }

      // is gene in transcript parents collection
      for (OntologyTerm parent : soterm.getParents()) {
        if (parent.getName().equals(parentSOTermName)) {
          CollectionHolder h = new CollectionHolder(childClassName, childCollectionName);
          children.add(h);
        }
      }
    }
    if (children.size() > 0) {
      parentToChildren.put(parentSOTermName, children);
    }
  }