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 ); } } }
public Collection<IdentifiedObject> getObsoleteOBOObjects() { Collection<IdentifiedObject> ObsoloteOboObjects = new ArrayList<IdentifiedObject>(); Collection<IdentifiedObject> allOBOObjects = oboSession.getObjects(); for ( IdentifiedObject identifiedObject : allOBOObjects ) { if ( identifiedObject.getID().startsWith( "MI:" ) ) { if ( identifiedObject instanceof OBOObject ) { OBOObject obj = ( OBOObject ) identifiedObject; String defText = obj.getDefinition(); if ( obj.isObsolete() || defText.contains( "\nOBSOLETE" ) ) { ObsoloteOboObjects.add( identifiedObject ); } } } } return ObsoloteOboObjects; }
/** * @param oboObject The current OBOObject instance * @param categories OboCategory could be PSI-MI slim, Drugable, etc., * @return true if belongs to the subset */ protected boolean checkIfCategorySubset( OBOObject oboObject, OboCategory... categories ) { if ( categories == null || categories.length == 0 ) return true; for ( OboCategory category : categories ) { for ( TermSubset oboCat : oboObject.getSubsets() ) { if ( category.getName().equalsIgnoreCase( oboCat.getName() ) ) { return true; } } } return false; }
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 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; }
if ( log.isTraceEnabled() ) log.trace( "ID ->" + oboObj.getID() + " Name ->" + oboObj.getName() ); if ( this.isHavingMoreThanOneParent( oboObj.getID() ) ) { Set<String> linkedSet4child = map4misWithMoreParent.get( oboObj.getID() ); Set<String> linkedSet = map4misWithMoreParent.get( oboObj.getID() ); if ( linkedSet != null && linkedSet.size() > 0 ) { rootclass = ( String ) linkedSet.toArray()[0]; log.trace( "More than One Parent True " + oboObj.getID() ); cvClass = findCvClassforMI( oboObj.getID() ); if (cvClass != null){ String processedKey_ = createCvKey( cvClass, oboObj.getID() ); cvClass = findCvClassforMI( oboObj.getID() ); String processedKey = createCvKey( cvClass, oboObj.getID() ); cvObject.addXref( createIdentityXref( cvObject, oboObj.getID() ) ); cvObject.setIdentifier(oboObj.getID()); cvObject.setFullName( oboObj.getName() ); Set<Dbxref> defDbXrefSet = oboObj.getDefDbxrefs(); Object[] dbxrefArray = defDbXrefSet.toArray(); if ( oboObj.getDefinition() != null ) {
if (obj.getID().startsWith("obo:")) { logger.debug("bogus term: " + obj.getID()); return; trm.setTermPk(safeTrim(obj.getID()) + SHORT_NAME + "0"); if (trm.getTermPk().length() > 255) { throw new IllegalStateException("term PK longer than allowed database column length: " + trm.getTermPk()); trm.setDefinition(safeTrim(obj.getDefinition())); if (trm.getDefinition() != null && trm.getDefinition().length() > 4000) { logger.warn("term definition longer than allowed database column length - truncating" + trm.getIdentifier()); trm.setIdentifier(safeTrim(obj.getID())); if (trm.getIdentifier() != null && trm.getIdentifier().length() > 255) { logger.warn("term identifier longer than allowed database column length - truncating" + trm.getIdentifier()); if (rootTerms.contains(safeTrim(obj.getID()))) { trm.setRootTerm(true); logger.info(obj.getID() + " is a root term"); trm.setName(safeTrim(obj.getName())); Namespace nspace = obj.getNamespace(); if (nspace != null) { trm.setNamespace(safeTrim(nspace.getID())); trm.setObsolete(obj.isObsolete());
String comment = safeTrim(obj.getComment()); if (comment != null) { AnnotationBean annot = new AnnotationBean(); Set<ObsoletableObject> considers = obj.getConsiderReplacements(); for (ObsoletableObject obsolete : considers) { AnnotationBean annot = new AnnotationBean(); Set<ObsoletableObject> replacers = obj.getReplacedBy(); for (ObsoletableObject replacedby : replacers) { AnnotationBean annot = new AnnotationBean(); Set<TermSubset> subsets = obj.getSubsets(); for (TermSubset subset : subsets) { AnnotationBean annot = new AnnotationBean(); Set<PropertyValue> propVal = obj.getPropertyValues(); for (PropertyValue pv : propVal) { AnnotationBean annot = new AnnotationBean(); for (Object xrObj : obj.getDbxrefs()) {
public static Collection<OBOObject> findParents( OBOObject oboObject, boolean recursive ) { final Collection<OBOObject> parents = Lists.newArrayList(); final Set<String> processedIdSet = Sets.newHashSet(); findParents( parents, oboObject, recursive, processedIdSet ); if ( log.isDebugEnabled() ) { log.debug( "Found " + parents.size() + " parents for term " + oboObject.getID() ); } return parents; }
for (Object xrObj : obj.getDbxrefs()) { Dbxref xref = (Dbxref) xrObj; for (Object xrObj : obj.getDefDbxrefs()) { Dbxref xref = (Dbxref) xrObj; retval.add(createDbXref(xref, Dbxref.DEFINITION));
Set<Synonym> syns = obj.getSynonyms(); int synCount = 1; for (Synonym aSyn : syns) { Set altIDs = obj.getSecondaryIDs(); String altID; for (Iterator i = altIDs.iterator(); i.hasNext(); ) {
String shortLabel = null; for ( Synonym synonym : oboObj.getSynonyms() ) { if( synonym != null ) { SynonymType synCat = synonym.getSynonymType(); if ( oboObj.getName() != null && oboObj.getName().length() <= AnnotatedObject.MAX_SHORT_LABEL_LEN ) { return oboObj.getName(); } else if ( oboObj.getName() != null && oboObj.getName().length() > AnnotatedObject.MAX_SHORT_LABEL_LEN ) { if ( log.isDebugEnabled() ) log.debug( "No shortLabel for " + oboObj.getName() ); return oboObj.getName().substring( 0, AnnotatedObject.MAX_SHORT_LABEL_LEN );
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; }
Collection<Link> parentLinks = oboObj.getParents(); hashSet.add(cvClass.getSimpleName()); map4misWithMoreParent.put(oboObj.getID(), hashSet);
public Collection<IdentifiedObject> getAllMIOBOObjects() { int obsoleteCounter = 0; ArrayList<IdentifiedObject> allMIObjects = new ArrayList<IdentifiedObject>(); Collection<IdentifiedObject> allOBOObjects = oboSession.getObjects(); for ( IdentifiedObject identifiedObject : allOBOObjects ) { if ( identifiedObject.getID().equalsIgnoreCase( MI_ROOT_IDENTIFIER ) ) { continue; } if ( identifiedObject.getID().startsWith( "MI:" ) ) { if ( identifiedObject instanceof OBOObject ) { OBOObject obj = ( OBOObject ) identifiedObject; if ( obj.isObsolete() ) obsoleteCounter++; allMIObjects.add( identifiedObject ); } } } log.info( "obsoleteCounter " + obsoleteCounter ); return allMIObjects; }
if (obj.getID().startsWith("obo:")) { logger.debug("bogus term: " + obj.getID()); return; trm.setTermPk(safeTrim(obj.getID()) + SHORT_NAME + "0"); if (trm.getTermPk().length() > 255) { throw new IllegalStateException("term PK longer than allowed database column length: " + trm.getTermPk()); trm.setDefinition(safeTrim(obj.getDefinition())); if (trm.getDefinition() != null && trm.getDefinition().length() > 4000) { logger.warn("term definition longer than allowed database column length - truncating" + trm.getIdentifier()); trm.setIdentifier(safeTrim(obj.getID())); if (trm.getIdentifier() != null && trm.getIdentifier().length() > 255) { logger.warn("term identifier longer than allowed database column length - truncating" + trm.getIdentifier()); if (rootTerms.contains(safeTrim(obj.getID()))) { trm.setRootTerm(true); logger.info(obj.getID() + " is a root term"); trm.setName(safeTrim(obj.getName())); Namespace nspace = obj.getNamespace(); if (nspace != null) { trm.setNamespace(safeTrim(nspace.getID())); trm.setObsolete(obj.isObsolete());
String comment = safeTrim(obj.getComment()); if (comment != null) { AnnotationBean annot = new AnnotationBean(); Set<ObsoletableObject> considers = obj.getConsiderReplacements(); for (ObsoletableObject obsolete : considers) { AnnotationBean annot = new AnnotationBean(); Set<ObsoletableObject> replacers = obj.getReplacedBy(); for (ObsoletableObject replacedby : replacers) { AnnotationBean annot = new AnnotationBean(); Set<TermSubset> subsets = obj.getSubsets(); for (TermSubset subset : subsets) { AnnotationBean annot = new AnnotationBean(); Set<PropertyValue> propVal = obj.getPropertyValues(); for (PropertyValue pv : propVal) { AnnotationBean annot = new AnnotationBean(); for (Object xrObj : obj.getDbxrefs()) {
public static Collection<OBOObject> findChildren( OBOObject oboObject, boolean recursive ) { List<OBOObject> children = Lists.newArrayList(); final Set<String> processedIdSet = Sets.newHashSet(); findChildren( children, oboObject, recursive, processedIdSet ); if ( log.isDebugEnabled() ) { log.debug( "Found " + children.size() + " children for term " + oboObject.getID() ); } return children; }
for (Object xrObj : obj.getDbxrefs()) { Dbxref xref = (Dbxref) xrObj; for (Object xrObj : obj.getDefDbxrefs()) { Dbxref xref = (Dbxref) xrObj; retval.add(createDbXref(xref, Dbxref.DEFINITION));
Set<Synonym> syns = obj.getSynonyms(); int synCount = 1; for (Synonym aSyn : syns) { Set<String> altIDs = obj.getSecondaryIDs(); String altID; for ( Iterator<String> i = altIDs.iterator(); i.hasNext(); ) {