use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class VcfUtilsTest method beforeMethod.
@BeforeMethod
public void beforeMethod() throws IOException {
/*
* 1 10050000 test21 G A . PASS AC=21;AN=22;GTC=0,1,10 1 10050001 test22 G A . PASS AC=22;AN=23;GTC=1,2,11 1
* 10050002 test23 G A . PASS AC=23;AN=24;GTC=2,3,12
*/
metaDataCanAnnotate.addAttribute(attributeChrom, ROLE_ID);
metaDataCanAnnotate.addAttribute(attributePos);
metaDataCanAnnotate.addAttribute(attributeRef);
metaDataCanAnnotate.addAttribute(attributeAlt);
metaDataCantAnnotate.addAttribute(attributeCantAnnotateChrom);
metaDataCantAnnotate.addAttribute(attributePos);
metaDataCantAnnotate.addAttribute(attributeRef);
metaDataCantAnnotate.addAttribute(attributeAlt);
entity = new DynamicEntity(metaDataCanAnnotate);
entity1 = new DynamicEntity(metaDataCanAnnotate);
entity2 = new DynamicEntity(metaDataCanAnnotate);
entity3 = new DynamicEntity(metaDataCanAnnotate);
entity4 = new DynamicEntity(metaDataCanAnnotate);
metaDataCanAnnotate.addAttribute(attributeFactory.create().setName(ID).setDataType(STRING));
metaDataCanAnnotate.addAttribute(attributeFactory.create().setName(QUAL).setDataType(STRING));
metaDataCanAnnotate.addAttribute(attributeFactory.create().setName(FILTER).setDataType(STRING));
metaDataCanAnnotate.addAttribute(attributeFactory.create().setName(EFFECT).setDataType(STRING).setDescription("EFFECT annotations: 'Alt_Allele | Gene_Name | Annotation | Putative_impact | Gene_ID | Feature_type | Feature_ID | Transcript_biotype | Rank_total | HGVS_c | HGVS_p | cDNA_position | CDS_position | Protein_position | Distance_to_feature | Errors'"));
Attribute INFO = attributeFactory.create().setName("INFO").setDataType(COMPOUND);
Attribute AC = attributeFactory.create().setName("AC").setDataType(STRING).setParent(INFO);
Attribute AN = attributeFactory.create().setName("AN").setDataType(STRING).setParent(INFO);
Attribute GTC = attributeFactory.create().setName("GTC").setDataType(STRING).setParent(INFO);
metaDataCanAnnotate.addAttribute(INFO);
metaDataCanAnnotate.addAttribute(AC);
metaDataCanAnnotate.addAttribute(AN);
metaDataCanAnnotate.addAttribute(GTC);
annotatedEntityType.addAttribute(attributeChrom, ROLE_ID);
annotatedEntityType.addAttribute(attributePos);
annotatedEntityType.addAttribute(attributeRef);
annotatedEntityType.addAttribute(attributeAlt);
annotatedEntityType.addAttribute(attributeFactory.create().setName(ID).setDataType(STRING));
annotatedEntityType.addAttribute(attributeFactory.create().setName(QUAL).setDataType(STRING));
annotatedEntityType.addAttribute((attributeFactory.create().setName(FILTER).setDataType(STRING)).setDescription("Test that description is not: '" + VcfRepository.DEFAULT_ATTRIBUTE_DESCRIPTION + "'"));
Attribute annoAttr = attributeFactory.create().setName("ANNO").setDataType(STRING).setParent(INFO);
annotatedEntityType.addAttribute(INFO);
annotatedEntityType.addAttribute(AC);
annotatedEntityType.addAttribute(AN);
annotatedEntityType.addAttribute(GTC);
annotatedEntityType.addAttribute(annoAttr);
metaDataCanAnnotate.addAttribute(annoAttr);
entity1.set(VcfAttributes.CHROM, "1");
entity1.set(VcfAttributes.POS, 10050000);
entity1.set(VcfAttributes.ID, "test21");
entity1.set(VcfAttributes.REF, "G");
entity1.set(VcfAttributes.ALT, "A");
entity1.set(VcfAttributes.QUAL, ".");
entity1.set(VcfAttributes.FILTER, "PASS");
entity1.set("AC", "21");
entity1.set("AN", "22");
entity1.set("GTC", "0,1,10");
entity1.set(EFFECT, "A|TUBB8|missense_variant|MODERATE|TUBB8|transcript|NM_177987.2|Coding|4/4|c.1286C>T|p.Thr429Met|1286/1504|1286/1335|429/444||");
entity2.set(VcfAttributes.CHROM, "1");
entity2.set(VcfAttributes.POS, 10050001);
entity2.set(VcfAttributes.ID, "test22");
entity2.set(VcfAttributes.REF, "G");
entity2.set(VcfAttributes.ALT, "A");
entity2.set(VcfAttributes.QUAL, ".");
entity2.set(VcfAttributes.FILTER, "PASS");
entity2.set(EFFECT, "A|TUBB8|missense_variant|MODERATE|TUBB8|transcript|NM_177987.2|Coding|4/4|c.1286C>T|p.Thr429Met|1286/1504|1286/1335|429/444||,A|GEN2|missense_variant|MODERATE|GEN2|transcript|NM_177987.2|Coding|4/4|c.1286C>T|p.Thr429Met|1286/1504|1286/1335|429/444||");
entity3.set(VcfAttributes.CHROM, "1");
entity3.set(VcfAttributes.POS, 10050002);
entity3.set(VcfAttributes.ID, "test23");
entity3.set(VcfAttributes.REF, "G");
entity3.set(VcfAttributes.ALT, "A");
entity3.set(VcfAttributes.QUAL, ".");
entity3.set(VcfAttributes.FILTER, "PASS");
entities = new ArrayList<>();
entities.add(entity1);
entities.add(entity2);
entities.add(entity3);
expectedEffectsEntityType = entityTypeFactory.create("EFFECTannotations");
expectedEffectsEntityType.addAttribute(attributeFactory.create().setName("identifier").setDataType(STRING), ROLE_ID);
expectedEffectsEntityType.addAttribute(attributeFactory.create().setName("Alt_Allele").setDataType(STRING));
expectedEffectsEntityType.addAttribute(attributeFactory.create().setName("Gene_Name").setDataType(STRING));
expectedEffectsEntityType.addAttribute(attributeFactory.create().setName("Annotation").setDataType(STRING));
expectedEffectsEntityType.addAttribute(attributeFactory.create().setName("Putative_impact").setDataType(STRING));
expectedEffectsEntityType.addAttribute(attributeFactory.create().setName("Gene_ID").setDataType(STRING));
expectedEffectsEntityType.addAttribute(attributeFactory.create().setName("Feature_type").setDataType(STRING));
expectedEffectsEntityType.addAttribute(attributeFactory.create().setName("Feature_ID").setDataType(STRING));
expectedEffectsEntityType.addAttribute(attributeFactory.create().setName("Transcript_biotype").setDataType(STRING));
expectedEffectsEntityType.addAttribute(attributeFactory.create().setName("Rank_total").setDataType(STRING));
expectedEffectsEntityType.addAttribute(attributeFactory.create().setName("HGVS_c").setDataType(STRING));
expectedEffectsEntityType.addAttribute(attributeFactory.create().setName("HGVS_p").setDataType(STRING));
expectedEffectsEntityType.addAttribute(attributeFactory.create().setName("cDNA_position").setDataType(STRING));
expectedEffectsEntityType.addAttribute(attributeFactory.create().setName("CDS_position").setDataType(STRING));
expectedEffectsEntityType.addAttribute(attributeFactory.create().setName("Protein_position").setDataType(STRING));
expectedEffectsEntityType.addAttribute(attributeFactory.create().setName("Distance_to_feature").setDataType(STRING));
expectedEffectsEntityType.addAttribute(attributeFactory.create().setName("Errors").setDataType(STRING));
expectedEffectsEntityType.addAttribute(attributeFactory.create().setName("VARIANT").setDataType(XREF).setRefEntity(metaDataCanAnnotate));
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class EntityManagerImpl method create.
private Entity create(EntityType entityType, Fetch fetch, CreationMode creationMode) {
Entity entity = new DynamicEntity(entityType);
if (fetch != null) {
// create partial entity that loads attribute values not contained in the fetch on demand.
entity = new PartialEntity(entity, fetch, this);
}
if (entityType.hasAttributeWithExpression()) {
// create entity that computed values based on expressions defined in meta data
entity = new EntityWithComputedAttributes(entity);
}
if (creationMode == POPULATE) {
entityPopulator.populate(entity);
}
EntityFactory<? extends Entity, ?> entityFactory = entityFactoryRegistry.getEntityFactory(entityType);
if (entityFactory != null) {
// create static entity (e.g. Tag, Language, Package) that wraps the constructed dynamic or partial entity.
return entityFactory.create(entity);
}
return entity;
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class OmimResultFilter method filterResults.
@Override
public Optional<Entity> filterResults(Iterable<Entity> results, Entity annotatedEntity, boolean updateMode) {
if (updateMode == true) {
throw new MolgenisDataException("This annotator/filter does not support updating of values");
}
Optional<Entity> firstResult = FluentIterable.from(results).first();
// FIXME 4714 refactor to work with auto id, setPackage() and setName()
EntityType emd = entityTypeFactory.create().setId(OmimAnnotator.NAME);
emd.addAttributes(Arrays.asList(omimAnnotator.getPhenotypeAttr(), omimAnnotator.getMimNumberAttr(), omimAnnotator.getOmimLocationAttr(), omimAnnotator.getEntryAttr(), omimAnnotator.getTypeAttr()));
return firstResult.transform(e -> {
Entity result = new DynamicEntity(emd);
result.set(OMIM_DISORDER, e.get(OmimRepository.OMIM_PHENOTYPE_COL_NAME));
result.set(OMIM_CAUSAL_IDENTIFIER, e.get(OmimRepository.OMIM_MIM_NUMBER_COL_NAME));
result.set(OMIM_CYTO_LOCATIONS, e.get(OmimRepository.OMIM_CYTO_LOCATION_COL_NAME));
result.set(OMIM_TYPE, e.get(OmimRepository.OMIM_TYPE_COL_NAME).toString());
result.set(OMIM_ENTRY, e.get(OmimRepository.OMIM_ENTRY_COL_NAME).toString());
return result;
});
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class EntityTestHarness method createEntity.
public Entity createEntity(EntityType entityType, int id, Entity refEntity) {
Entity entity = new DynamicEntity(entityType);
entity.set(ATTR_ID, "" + id);
entity.set(ATTR_STRING, "string1");
entity.set(ATTR_BOOL, id % 2 == 0);
entity.set(ATTR_CATEGORICAL, refEntity);
entity.set(ATTR_CATEGORICAL_MREF, refEntity == null ? emptyList() : singletonList(refEntity));
entity.set(ATTR_DATE, date);
entity.set(ATTR_DATETIME, dateTime);
entity.set(ATTR_EMAIL, "this.is@mail.address");
entity.set(ATTR_DECIMAL, id + 0.123);
entity.set(ATTR_HTML, id % 2 == 1 ? "<html>where is my head and where is my body</html>" : null);
entity.set(ATTR_HYPERLINK, "http://www.molgenis.org");
entity.set(ATTR_LONG, id * 1000000L);
entity.set(ATTR_INT, 10 + id);
entity.set(ATTR_SCRIPT, "/bin/blaat/script.sh");
entity.set(ATTR_XREF, refEntity);
entity.set(ATTR_MREF, refEntity == null ? emptyList() : singletonList(refEntity));
entity.set(ATTR_COMPOUND_CHILD_INT, 10 + id);
entity.set(ATTR_ENUM, id % 2 == 0 ? "option1" : "option2");
return new EntityWithComputedAttributes(entity);
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class JsMagmaScriptEvaluatorTest method testNull.
@Test
public void testNull() {
Entity person0 = new DynamicEntity(personBirthDateMeta);
person0.set("birthdate", LocalDate.now());
String script = "$('birthdate').age().value() < 18 || $('birthdate').value() != null";
Object result = jsMagmaScriptEvaluator.eval(script, person0, 3);
assertEquals(result, true);
Entity person1 = new DynamicEntity(personBirthDateMeta);
person1.set("birthdate", null);
result = jsMagmaScriptEvaluator.eval(script, person1, 3);
assertEquals(result, false);
}
Aggregations