if (relationshipType.contains(trm.getType().getID())) { paths.put(trm.getChild().getID(), distance); computeChildPaths(distance + 1, relationshipType, trm.getChild(), paths); } catch (StackOverflowError e) { logger.error("Stack overflow when computing child paths for: " + term.getID() + " for relationships: " + relationshipType);
public Collection<IdentifiedObject> getRootOBOObjects( OboCategory... categories ) { ArrayList<IdentifiedObject> rootOboObjects = new ArrayList<IdentifiedObject>(); OBOObject rootObj = ( OBOObject ) oboSession.getObject( MI_ROOT_IDENTIFIER ); Collection<Link> childLinks = rootObj.getChildren(); for ( Link childLink : childLinks ) { if (MI_ROOT_IDENTIFIER.equals(childLink.getParent().getID())) { OBOObject immediateChildOfRoot = (OBOObject) childLink.getChild(); if ( checkIfCategorySubset( immediateChildOfRoot, categories ) ) { rootOboObjects.add( immediateChildOfRoot ); } } } log.debug( "oboObjects " + rootOboObjects.size() ); return rootOboObjects; }
/** * Sometimes Cvterms with more than one parent will * have children but as it would be difficult to assign * to the right root parent class, we also create * children for each of the parent root class * * @param oboObj * @return String[] with MIs of all childresn */ private String[] getChildren4MisWithMoreParent( OBOObject oboObj ) { Collection<Link> childLinks = oboObj.getChildren(); String[] mis = new String[childLinks.size()]; int i = -1; for ( Link childLink1 : childLinks ) { Pattern p = Pattern.compile( "(MI:\\d+)-OBO_REL:is_a->(MI:\\d+)" ); Matcher m = p.matcher( childLink1.getID() ); if ( m.matches() ) { if ( m.group( 2 ).equalsIgnoreCase( oboObj.getID() ) ) { OBOObject childObj = ( OBOObject ) oboSession.getObject( m.group( 1 ) ); mis[++i] = childObj.getID(); } } } return mis; }
Term parentTrm = ontologyTerms.get(safeTrim(lnk.getParent().getID())); parentTrm = localTermCache.get(safeTrim(lnk.getParent().getID())); if (parentTrm == null) { parentTrm = tqh.getTermById(safeTrim(lnk.getParent().getID()), null); throw new IllegalStateException(lnk.getParent().getID() + " is not lot local to " + SHORT_NAME + " and is not already loaded in the OLS dabatase. Cannot proceed."); } else { logger.warn(lnk.getParent().getID() + " is not lot local to " + SHORT_NAME + " and is not already loaded in the OLS dabatase. RELATIONSHIP IGNORED."); logger.info("retrieved " + lnk.getParent().getID() + " from OLS database"); localTermCache.put(safeTrim(lnk.getParent().getID()), parentTrm); logger.debug("cached " + lnk.getParent().getID() + " for local reuse if required"); logger.debug("used cached resolved term: " + lnk.getParent().getID()); if (IS_A_SET.contains(lnk.getType().getID())) { trb.setPredicateTerm(IS_A); } else if (PART_OF_SET.contains(lnk.getType().getID())) { trb.setPredicateTerm(PART_OF); } else if (DEV_FROM_SET.contains(lnk.getType().getID())) { trb.setPredicateTerm(DEVELOPS_FROM); } else { TermBean otherRelation = getUnknownRelationTermBean(lnk.getType().getID()); if (otherRelation != null) { trb.setPredicateTerm(otherRelation);
private Collection<IdentifiedObject> getChildren( OBOSession source, String miTerm ) { OBOObject parentTerm = ( OBOObject ) source.getObject( miTerm ); Collection<Link> childLinks = parentTerm.getChildren(); Collection<IdentifiedObject> children = new ArrayList<IdentifiedObject>(); for ( Link childLink : childLinks ) { OBOObject childTerm = ( OBOObject ) childLink.getChild(); children.add( childTerm ); children.addAll( getChildren( source, childTerm.getID() ) ); } return children; }
private static void findParents( Collection<OBOObject> parents, OBOObject oboObject, boolean recursive, Set<String> processedIdSet ) { final String id = oboObject.getID(); if( processedIdSet.contains( id ) ) { return; // cuts infinite loop as the ontology can have cycles. } else { processedIdSet.add( id ); } for ( Link parentLink : oboObject.getParents() ) { OBOObject parent = (OBOObject) parentLink.getParent(); parents.add( parent ); if( recursive && !parent.getParents().isEmpty() ) { if ( log.isTraceEnabled() ) { log.trace( "Calling recursively findParent( "+ parent.getID() +" - "+ parent.getName() +" ) ..." ); } findParents( parents, parent, recursive, processedIdSet ); } } }
private void addChild(OBOClass parent, OBOClass child) { Link linkToIsA = new OBORestrictionImpl(child); linkToIsA.setType( OBOProperty.IS_A ); parent.addChild( linkToIsA ); }
private static void findChildren( Collection<OBOObject> children, OBOObject oboObject, boolean recursive, Set<String> processedIdSet ) { final String id = oboObject.getID(); if( processedIdSet.contains( id ) ) { return; // cuts infinite loop as the ontology can have cycles. } else { processedIdSet.add( id ); } for ( Link childLink : oboObject.getChildren() ) { OBOObject child = (OBOObject) childLink.getChild(); children.add( child ); if( recursive && !child.getChildren().isEmpty() ) { if ( log.isTraceEnabled() ) { log.trace( "Calling recursively findChildren( "+ child.getID() +" - "+ child.getName() +" ) ..." ); } findChildren( children, child, recursive, processedIdSet ); } } }
final String parentId = parentLink.getParent().getID(); cvClass = findCvClassforMI(parentId);
private void addLinkToRootFor(OBOClass oboObj) { OBOClass rootObject = getRootObject(); Link linkToRoot = new OBORestrictionImpl( oboObj ); OBOProperty oboProp = new OBOPropertyImpl( "part_of" ); linkToRoot.setType( oboProp ); rootObject.addChild( linkToRoot ); }
if (relationshipType.contains(trm.getType().getID())) { paths.put(trm.getChild().getID(), distance); computeChildPaths(distance + 1, relationshipType, trm.getChild(), paths); } catch (StackOverflowError e) { logger.error("Stack overflow when computing child paths for: " + term.getID() + " for relationships: " + relationshipType);
OBOObject childObj = (OBOObject) childLink1.getChild();
protected <T extends CvObject> Class<T> findCvClassforMI( String id ) { Class<T> cvClass; cvClass = mi2Class.get( id ); if ( cvClass != null ) { //then it is one of rootCv return cvClass; } else { OBOObject oboObj = ( OBOObject ) oboSession.getObject( id ); Collection<Link> parentLinks = oboObj.getParents(); for ( Link parentLink : parentLinks ) { String parentId = parentLink.getParent().getID(); return findCvClassforMI( parentId ); } } return cvClass; }
if (relationshipType.contains(trm.getType().getID())) { paths.put(trm.getChild().getID(), distance); computeChildPaths(distance + 1, relationshipType, trm.getChild(), paths); } catch (StackOverflowError e) { logger.error("Stack overflow when computing child paths for: " + term.getID() + " for relationships: " + relationshipType);
Term childTrm = ontologyTerms.get(safeTrim(lnk.getChild().getID())); if (childTrm != null) { TermRelationshipBean trb = new TermRelationshipBean(); if (IS_A_SET.contains(lnk.getType().getID())) { trb.setPredicateTerm(IS_A); } else if (PART_OF_SET.contains(lnk.getType().getID())) { trb.setPredicateTerm(PART_OF); } else if (DEV_FROM_SET.contains(lnk.getType().getID())) { trb.setPredicateTerm(DEVELOPS_FROM); } else { TermBean otherRelation = getUnknownRelationTermBean(lnk.getType().getID()); if (otherRelation != null) { trb.setPredicateTerm(otherRelation); } else { logger.warn("Unable to create unknown relation type: >" + lnk.getType().getID() + "<"); continue;
Term childTrm = ontologyTerms.get(safeTrim(lnk.getChild().getID())); if (childTrm != null) { TermRelationshipBean trb = new TermRelationshipBean(); if (IS_A_SET.contains(lnk.getType().getID())) { trb.setPredicateTerm(IS_A); } else if (PART_OF_SET.contains(lnk.getType().getID())) { trb.setPredicateTerm(PART_OF); } else if (DEV_FROM_SET.contains(lnk.getType().getID())) { trb.setPredicateTerm(DEVELOPS_FROM); } else { TermBean otherRelation = getUnknownRelationTermBean(lnk.getType().getID()); if (otherRelation != null) { trb.setPredicateTerm(otherRelation); } else { logger.warn("Unable to create unknown relation type: >" + lnk.getType().getID() + "<"); continue;
Term childTrm = ontologyTerms.get(safeTrim(lnk.getChild().getID())); if (childTrm != null) { TermRelationshipBean trb = new TermRelationshipBean(); if (IS_A_SET.contains(lnk.getType().getID())) { trb.setPredicateTerm(IS_A); } else if (PART_OF_SET.contains(lnk.getType().getID())) { trb.setPredicateTerm(PART_OF); } else if (DEV_FROM_SET.contains(lnk.getType().getID())) { trb.setPredicateTerm(DEVELOPS_FROM); } else { TermBean otherRelation = getUnknownRelationTermBean(lnk.getType().getID()); if (otherRelation != null) { trb.setPredicateTerm(otherRelation); } else { logger.warn("Unable to create unknown relation type: >" + lnk.getType().getID() + "<"); continue;