/** * 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); } }
/** * 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); } } }