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; }
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; }
private Collection<IdentifiedObject> getTermAndChildren( Collection<IdentifiedObject> allChildObjects, OBOSession source ) { if ( omc.isIncludeSourceOntologyTerm() ) { allChildObjects.add( source.getObject( omc.getSourceOntologyTerm() ) ); } if ( omc.isRecursive() ) { allChildObjects.addAll( getChildren( source, omc.getSourceOntologyTerm() ) ); } return allChildObjects; }//end method
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; }
final boolean recursive = true; for ( String termId : terms ) { OBOObject oboObject = ( OBOObject ) session.getObject( termId ); allOboObjects.add( oboObject );
OBOObject targetTerm = ( OBOObject ) target.getObject( omc.getTargetOntologyTerm() ); OBOObject sourceTerm = ( OBOObject ) source.getObject( omc.getSourceOntologyTerm() ); OBOObject targetTermAfter = ( OBOObject ) target.getObject( omc.getTargetOntologyTerm() ); if ( log.isDebugEnabled() ) { log.debug( " targetTermAfter " + targetTermAfter.getID() + " " + targetTermAfter.getName() + " " + targetTermAfter.getChildren().size() );