/** * * @return the interactor factory we want to use to create the complex for bipartite expansion */ public InteractorFactory getInteractorFactory() { if (this.interactorFactory == null){ this.interactorFactory = new DefaultInteractorFactory(); } return interactorFactory; }
/** * Creates an interactor from a given category (should be the canonical name of an Interactor interface) * @param category : the category of interactor * @param name : name * @param type : interactor type * @return the created interactor */ protected Interactor createInteractorFromRecognizedCategory(InteractorCategory category, String name, CvTerm type){ switch (category){ case protein: return createProtein(name, type); case gene: return createGene(name); case nucleic_acid: return createNucleicAcid(name, type); case bioactive_entity: return createBioactiveEntity(name, type); case polymer: return createPolymer(name, type); case complex: return createComplex(name, type); case interactor_set: return createInteractorSet(name, type); default: return createInteractor(name, type); } } }
/** * Return the proper instance of the interactor if the type is recognized and not null. It returns null otherwise. * @param type : the interactor type * @param name : shortName * @return the proper instance of the interactor if the type is recognized. It returns null otherwise. */ public Interactor createInteractorFromInteractorType(CvTerm type, String name){ if (type == null){ return null; } String typeName = type.getShortName().toLowerCase().trim(); String typeMI = type.getMIIdentifier(); if (typeMI != null && this.deterministicInteractorIdMap.containsKey(typeMI)){ InteractorCategory recognizedType = this.deterministicInteractorIdMap.get(typeMI); return createInteractorFromRecognizedCategory(recognizedType, name, type); } else if (typeMI == null && this.deterministicInteractorNameMap.containsKey(typeName)){ InteractorCategory recognizedType = this.deterministicInteractorNameMap.get(typeName); return createInteractorFromRecognizedCategory(recognizedType, name, type); } // we have a valid type that is not unknown or null else { return createInteractor(name, type); } }
/** * Return the proper instance of the interactor if the database is recognized (the interactor will be returned on the first database which is recognized). It returns null otherwise. * @param xrefs : identifiers * @param name : name * @return the proper instance of the interactor if the database is recognized (the interactor will be returned on the first database which is recognized). It returns null otherwise. */ public Interactor createInteractorFromIdentityXrefs(Collection<? extends Xref> xrefs, String name){ Interactor interactor = null; Iterator<? extends Xref> xrefsIterator = xrefs.iterator(); while (interactor == null && xrefsIterator.hasNext()){ interactor = createInteractorFromDatabase(xrefsIterator.next().getDatabase(), name); } return interactor; }
/** * Return the proper instance of the interactor if the database is recognized. It returns null otherwise. * @param database : the database * @param name : the name * @return the proper instance of the interactor if the database is recognized. It returns null otherwise. */ public Interactor createInteractorFromDatabase(CvTerm database, String name){ if (database == null){ return null; } String databaseName = database.getShortName().toLowerCase().trim(); String databaseMI = database.getMIIdentifier(); if (databaseMI != null && this.deterministicInteractorIdMap.containsKey(databaseMI)){ InteractorCategory recognizedType = this.deterministicInteractorIdMap.get(databaseMI); return createInteractorFromRecognizedCategory(recognizedType, name, null); } else if (databaseMI == null && this.deterministicInteractorNameMap.containsKey(databaseName)){ InteractorCategory recognizedType = this.deterministicInteractorNameMap.get(databaseName); return createInteractorFromRecognizedCategory(recognizedType, name, null); } return null; }