/** * Uses the map containing the parsed OMIM map to create a list of {@link Entity} */ private void addEntityToGeneEntityList(Map<String, List<List<String>>> omimEntriesByGeneSymbol, String geneSymbol) { Entity entity = new DynamicEntity(getEntityType()); entity.set(OMIM_GENE_SYMBOLS_COL_NAME, geneSymbol); entity.set(OMIM_PHENOTYPE_COL_NAME, join(omimEntriesByGeneSymbol.get(geneSymbol).get(0), ",")); entity.set(OMIM_MIM_NUMBER_COL_NAME, join(omimEntriesByGeneSymbol.get(geneSymbol).get(1), ",")); entity.set(OMIM_CYTO_LOCATION_COL_NAME, join(omimEntriesByGeneSymbol.get(geneSymbol).get(2), ",")); entity.set(OMIM_TYPE_COL_NAME, join(omimEntriesByGeneSymbol.get(geneSymbol).get(3), ",")); entity.set(OMIM_ENTRY_COL_NAME, join(omimEntriesByGeneSymbol.get(geneSymbol).get(4), ",")); List<Entity> entities = entitiesByGeneSymbol.computeIfAbsent(geneSymbol, k -> new ArrayList<>()); entities.add(entity); }
@Override public Entity next() { Entity entity = iterator.next(); if (isEmpty(entity.getString(ALLOWED_IDENTIFIER))) { DynamicEntity dynamicEntity = new DynamicEntity(getEntityType()); dynamicEntity.set(entity); entity = dynamicEntity; entity.set(ALLOWED_IDENTIFIER, String.valueOf(count.incrementAndGet())); } return entity; } };
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; DynamicEntity other = (DynamicEntity) obj; return getIdValue().equals(other.getIdValue()); }
/** Execute a JavaScript using the Magma API */ Object executeScript(String jsScript, Map<String, Object> parameters) { EntityType entityType = entityTypeFactory.create("entity"); Set<String> attributeNames = parameters.keySet(); attributeNames.forEach(key -> entityType.addAttribute(attributeFactory.create().setName(key))); if (attributeNames.iterator().hasNext()) { entityType.getAttribute(attributeNames.iterator().next()).setIdAttribute(true); } Entity entity = new DynamicEntity(entityType); parameters.forEach(entity::set); return jsMagmaScriptEvaluator.eval(jsScript, entity); } }
private static Stream<Entity> createEffectsEntitiesForSingleVariant(EntityType effectsEntityType, List<Attribute> effectFieldAttributeList, String descriptionFieldsString, Entity variantEntity) { List<Entity> listOfEffectsEntities = new ArrayList<>(); if (descriptionFieldsString == null) return listOfEffectsEntities.stream(); String[] descriptionFieldValues = descriptionFieldsString.split(","); for (String descriptionFieldValue : descriptionFieldValues) { String[] descriptionFieldPartValues = descriptionFieldValue.split("\\|", -1); DynamicEntity singleEffectsEntity = new DynamicEntity(effectsEntityType); int i = 0; for (Attribute attribute : effectFieldAttributeList) { if (i > descriptionFieldPartValues.length) { throw new RuntimeException( "Description of the attribute contains more values (pipe separated values) than the actual value"); } singleEffectsEntity.set(attribute.getName(), descriptionFieldPartValues[i]); i++; } singleEffectsEntity.set(VARIANT, variantEntity); listOfEffectsEntities.add(singleEffectsEntity); } return listOfEffectsEntities.stream(); } }
next = new DynamicEntity(entityType);
private static Stream<Entity> createEffectsEntitiesForSingleVariant(EntityType effectsEntityType, List<Attribute> effectFieldAttributeList, String descriptionFieldsString, Entity variantEntity) { List<Entity> listOfEffectsEntities = new ArrayList<>(); if (descriptionFieldsString == null) return listOfEffectsEntities.stream(); String[] descriptionFieldValues = descriptionFieldsString.split(","); for (String descriptionFieldValue : descriptionFieldValues) { String[] descriptionFieldPartValues = descriptionFieldValue.split("\\|", -1); DynamicEntity singleEffectsEntity = new DynamicEntity(effectsEntityType); int i = 0; for (Attribute attribute : effectFieldAttributeList) { if (i > descriptionFieldPartValues.length) { throw new RuntimeException( "Description of the attribute contains more values (pipe separated values) than the actual value"); } singleEffectsEntity.set(attribute.getName(), descriptionFieldPartValues[i]); i++; } singleEffectsEntity.set(VARIANT, variantEntity); listOfEffectsEntities.add(singleEffectsEntity); } return listOfEffectsEntities.stream(); } }
private Entity getEmptyEffectsEntity(Entity sourceEntity, EntityType effectsEMD) { Entity effect = new DynamicEntity(effectsEMD); effect.set(ID, idGenerator.generateId()); effect.set(VARIANT, sourceEntity); return effect; }
Entity aggregated = new DynamicEntity(emd); aggregated.set(HPO_IDS, ids.toString()); aggregated.set(HPO_TERMS, terms.toString());
private Entity createVcfEntityStructureForSingleEntity(Entity variant, List<Entity> effectsForVariant) { createResultEntityType(effectsForVariant.get(0), variant.getEntityType()); Entity newVariant = new DynamicEntity(vcfVariantEntityType); newVariant.set(variant); if (effectsForVariant.size() > 1) { newVariant.set(EFFECT, effectsForVariant); } else { // is this an empty effect entity? Entity effectForVariant = effectsForVariant.get(0); if (!isEmptyEffectEntity(effectForVariant)) newVariant.set(EFFECT, effectsForVariant); } return newVariant; }
Entity entity = new DynamicEntity(getEntityType()); entity.set(HPO_DISEASE_ID_COL_NAME, values[0]); entity.set(HPO_GENE_SYMBOL_COL_NAME, geneSymbol);
private void tryUpdate(JobExecution jobExecution) { Entity jobExecutionCopy = new DynamicEntity(jobExecution.getEntityType()); jobExecutionCopy.set(jobExecution); try { dataService.update(jobExecutionCopy.getEntityType().getId(), jobExecutionCopy); } catch (Exception ex) { LOG.warn("Error updating job execution", ex); } } }
private Entity createVcfEntityStructureForSingleEntity(Entity variant, List<Entity> effectsForVariant) { createResultEntityType(effectsForVariant.get(0), variant.getEntityType()); Entity newVariant = new DynamicEntity(vcfVariantEntityType); newVariant.set(variant); if (effectsForVariant.size() > 1) { newVariant.set(EFFECT, effectsForVariant); } else { // is this an empty effect entity? Entity effectForVariant = effectsForVariant.get(0); if (!isEmptyEffectEntity(effectForVariant)) newVariant.set(EFFECT, effectsForVariant); } return newVariant; }
private Stream<Entity> createVariantEffectStructureForSingleEntity(Attribute attributeToParse, ArrayList<Attribute> effectFieldAttributeList, EntityType effectsEntityType, Entity vcfInputEntity, EntityType variantEntityType) { List<Entity> results = new ArrayList<>(); Entity variantEntity = new DynamicEntity(variantEntityType); for (String attr : variantEntity.getAttributeNames()) { if (vcfInputEntity.getEntityType().getAttribute(attr) != null) { variantEntity.set(attr, vcfInputEntity.get(attr)); } } List<Entity> result = createEffectsEntitiesForSingleVariant(effectsEntityType, effectFieldAttributeList, vcfInputEntity.getString(attributeToParse.getName()), variantEntity).collect(Collectors.toList()); results.addAll(result); return results.stream(); }
private Stream<Entity> createVariantEffectStructureForSingleEntity(Attribute attributeToParse, ArrayList<Attribute> effectFieldAttributeList, EntityType effectsEntityType, Entity vcfInputEntity, EntityType variantEntityType) { List<Entity> results = new ArrayList<>(); Entity variantEntity = new DynamicEntity(variantEntityType); for (String attr : variantEntity.getAttributeNames()) { if (vcfInputEntity.getEntityType().getAttribute(attr) != null) { variantEntity.set(attr, vcfInputEntity.get(attr)); } } List<Entity> result = createEffectsEntitiesForSingleVariant(effectsEntityType, effectFieldAttributeList, vcfInputEntity.getString(attributeToParse.getName()), variantEntity).collect(Collectors.toList()); results.addAll(result); return results.stream(); }
private Entity applyMappingToEntity(EntityMapping sourceMapping, Entity sourceEntity, EntityType targetMetaData) { Entity target = new DynamicEntity(targetMetaData); if (targetMetaData.getAttribute(SOURCE) != null) { target.set(SOURCE, sourceMapping.getName()); } sourceMapping.getAttributeMappings().forEach( attributeMapping -> applyMappingToAttribute(attributeMapping, sourceEntity, target, sourceMapping.getSourceEntityType())); return target; }
private Entity addEntry(String term, PubMedTFEntity pubMedTFEntity, DataService dataService) { if (pubMedTFEntity == null) return null; // FIXME remove reference to getApplicationContext TermFrequencyMetaData termFrequencyEntityType = getApplicationContext().getBean(TermFrequencyMetaData.class); Entity entity = new DynamicEntity(termFrequencyEntityType); entity.set(TERM, term); entity.set(FREQUENCY, pubMedTFEntity.getFrequency()); entity.set(OCCURRENCE, pubMedTFEntity.getOccurrence()); dataService.add(TERM_FREQUENCY, entity); return entity; }
private Entity toAttributeMappingEntity(AttributeMapping attributeMapping) { Entity attributeMappingEntity = new DynamicEntity(attributeMappingMetaData); attributeMappingEntity.set(IDENTIFIER, attributeMapping.getIdentifier()); attributeMappingEntity.set(TARGET_ATTRIBUTE, attributeMapping.getTargetAttributeName()); attributeMappingEntity.set(ALGORITHM, attributeMapping.getAlgorithm()); attributeMappingEntity.set( SOURCE_ATTRIBUTES, attributeMapping .getSourceAttributes() .stream() .map(Attribute::getName) .collect(Collectors.joining(","))); attributeMappingEntity.set(ALGORITHM_STATE, attributeMapping.getAlgorithmState().toString()); return attributeMappingEntity; } }
Entity mapEntity = new DynamicEntity(termFrequencyEntityType); mapEntity.set(TERM, ontologyTermSynonym); mapEntity.set(FREQUENCY, pubMedTFEntity.getFrequency());
private Entity toAttributeMappingEntity(AttributeMapping attributeMapping) { Entity attributeMappingEntity = new DynamicEntity(attributeMappingMetaData); attributeMappingEntity.set(IDENTIFIER, attributeMapping.getIdentifier()); attributeMappingEntity.set(TARGET_ATTRIBUTE, attributeMapping.getTargetAttribute() != null ? attributeMapping.getTargetAttribute() .getName() : null); attributeMappingEntity.set(ALGORITHM, attributeMapping.getAlgorithm()); attributeMappingEntity.set(SOURCE_ATTRIBUTES, attributeMapping.getSourceAttributes().stream().map(Attribute::getName) .collect(Collectors.joining(","))); attributeMappingEntity.set(ALGORITHM_STATE, attributeMapping.getAlgorithmState().toString()); return attributeMappingEntity; }