Search in sources :

Example 36 with DynamicEntity

use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.

the class ExacAnnotatorTest method testAnnotate.

@Test
public void testAnnotate() {
    EntityType emdIn = entityTypeFactory.create("exac");
    emdIn.addAttribute(vcfAttributes.getChromAttribute(), ROLE_ID);
    emdIn.addAttribute(vcfAttributes.getPosAttribute());
    emdIn.addAttribute(vcfAttributes.getRefAttribute());
    emdIn.addAttribute(vcfAttributes.getAltAttribute());
    emdIn.addAttribute(exacAnnotator.getExacAFAttr(attributeFactory));
    emdIn.addAttribute(exacAnnotator.getExacAcHomAttr(attributeFactory));
    emdIn.addAttribute(exacAnnotator.getExacAcHetAttr(attributeFactory));
    Entity inputEntity = new DynamicEntity(emdIn);
    inputEntity.set(VcfAttributes.CHROM, "1");
    inputEntity.set(VcfAttributes.POS, 13372);
    inputEntity.set(VcfAttributes.REF, "G");
    inputEntity.set(VcfAttributes.ALT, "C");
    Iterator<Entity> results = annotator.annotate(Collections.singletonList(inputEntity));
    assertTrue(results.hasNext());
    Entity resultEntity = results.next();
    assertFalse(results.hasNext());
    assertEquals(resultEntity.get(VcfAttributes.CHROM), "1");
    assertEquals(resultEntity.get(VcfAttributes.POS), 13372);
    assertEquals(resultEntity.get(VcfAttributes.REF), "G");
    assertEquals(resultEntity.get(VcfAttributes.ALT), "C");
    assertEquals(resultEntity.get(ExacAnnotator.EXAC_AF), "6.998E-5");
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) DynamicEntity(org.molgenis.data.support.DynamicEntity) Entity(org.molgenis.data.Entity) DynamicEntity(org.molgenis.data.support.DynamicEntity) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 37 with DynamicEntity

use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.

the class GavinAnnotatorTest method getVariantEntity.

private Entity getVariantEntity(String alt, String caddScaled, String exacAF) {
    Entity variantEntity = new DynamicEntity(entityType);
    variantEntity.set(VcfAttributes.ALT, alt);
    variantEntity.set(CaddAnnotator.CADD_SCALED, caddScaled);
    variantEntity.set(ExacAnnotator.EXAC_AF, exacAF);
    return variantEntity;
}
Also used : DynamicEntity(org.molgenis.data.support.DynamicEntity) Entity(org.molgenis.data.Entity) DynamicEntity(org.molgenis.data.support.DynamicEntity)

Example 38 with DynamicEntity

use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.

the class HPOResultFilterTest method filterResults.

@Test
public void filterResults() {
    HpoResultFilter filter = new HpoResultFilter(entityTypeFactory, hpoAnnotator);
    EntityType resultEntityType = entityTypeFactory.create("result");
    resultEntityType.addAttribute(hpoAnnotator.getIdsAttr());
    resultEntityType.addAttribute(hpoAnnotator.getTermsAttr());
    EntityType entityType = entityTypeFactory.create("HPO");
    entityType.addAttribute(attributeFactory.create().setName(HPO_DISEASE_ID_COL_NAME));
    entityType.addAttribute(attributeFactory.create().setName(HPO_GENE_SYMBOL_COL_NAME));
    entityType.addAttribute(attributeFactory.create().setName(HPO_ID_COL_NAME), ROLE_ID);
    entityType.addAttribute(attributeFactory.create().setName(HPO_TERM_COL_NAME));
    Entity e1 = new DynamicEntity(entityType);
    e1.set(HPO_ID_COL_NAME, "id1");
    e1.set(HPO_TERM_COL_NAME, "term1");
    Entity e2 = new DynamicEntity(entityType);
    e2.set(HPO_ID_COL_NAME, "id2");
    e2.set(HPO_TERM_COL_NAME, "term2");
    Optional<Entity> result = filter.filterResults(Arrays.asList(e1, e2), new DynamicEntity(resultEntityType), false);
    assertTrue(result.isPresent());
    assertEquals(result.get().getString(HPOAnnotator.HPO_IDS), "id1/id2");
    assertEquals(result.get().getString(HPOAnnotator.HPO_TERMS), "term1/term2");
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) DynamicEntity(org.molgenis.data.support.DynamicEntity) Entity(org.molgenis.data.Entity) DynamicEntity(org.molgenis.data.support.DynamicEntity) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 39 with DynamicEntity

use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.

the class GoNLAnnotatorTest method testAnnotate11.

@Test
public void testAnnotate11() {
    Entity entity11 = new DynamicEntity(emd);
    entity11.set(VcfAttributes.CHROM, "3");
    entity11.set(VcfAttributes.POS, 53219680);
    entity11.set(VcfAttributes.REF, "G");
    entity11.set(VcfAttributes.ALT, "C");
    Iterator<Entity> results = annotator.annotate(Collections.singletonList(entity11));
    assertTrue(results.hasNext());
    Entity resultEntity = results.next();
    assertFalse(results.hasNext());
    assertNull(resultEntity.get(GONL_GENOME_AF));
    assertNull(resultEntity.get(GONL_GENOME_GTC));
}
Also used : DynamicEntity(org.molgenis.data.support.DynamicEntity) Entity(org.molgenis.data.Entity) DynamicEntity(org.molgenis.data.support.DynamicEntity) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 40 with DynamicEntity

use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.

the class GoNLAnnotatorTest method testAnnotate8.

@Test
public void testAnnotate8() {
    Entity entity8 = new DynamicEntity(emd);
    entity8.set(VcfAttributes.CHROM, "21");
    entity8.set(VcfAttributes.POS, 46924425);
    entity8.set(VcfAttributes.REF, "CGGCCCCCCA");
    entity8.set(VcfAttributes.ALT, "C");
    Iterator<Entity> results = annotator.annotate(Collections.singletonList(entity8));
    assertTrue(results.hasNext());
    Entity resultEntity = results.next();
    assertFalse(results.hasNext());
    assertNull(resultEntity.get(GONL_GENOME_AF));
    assertNull(resultEntity.get(GONL_GENOME_GTC));
}
Also used : DynamicEntity(org.molgenis.data.support.DynamicEntity) Entity(org.molgenis.data.Entity) DynamicEntity(org.molgenis.data.support.DynamicEntity) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Aggregations

DynamicEntity (org.molgenis.data.support.DynamicEntity)161 Entity (org.molgenis.data.Entity)123 Test (org.testng.annotations.Test)104 AbstractMolgenisSpringTest (org.molgenis.data.AbstractMolgenisSpringTest)50 EntityType (org.molgenis.data.meta.model.EntityType)48 Attribute (org.molgenis.data.meta.model.Attribute)38 AttributeMapping (org.molgenis.semanticmapper.mapping.model.AttributeMapping)14 BeforeMethod (org.testng.annotations.BeforeMethod)14 ExplainedAttribute (org.molgenis.semanticsearch.explain.bean.ExplainedAttribute)7 EntityMapping (org.molgenis.semanticmapper.mapping.model.EntityMapping)5 BeforeClass (org.testng.annotations.BeforeClass)5 ArrayList (java.util.ArrayList)4 MolgenisDataException (org.molgenis.data.MolgenisDataException)4 EntityWithComputedAttributes (org.molgenis.data.support.EntityWithComputedAttributes)4 ExplainedQueryString (org.molgenis.semanticsearch.explain.bean.ExplainedQueryString)4 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)4 StringWriter (java.io.StringWriter)3 List (java.util.List)3 BoolQueryBuilder (org.elasticsearch.index.query.BoolQueryBuilder)3 QueryBuilder (org.elasticsearch.index.query.QueryBuilder)3