Search in sources :

Example 11 with MultiAllelicResultFilter

use of org.molgenis.data.annotation.core.filter.MultiAllelicResultFilter in project molgenis by molgenis.

the class ExacAnnotator method init.

@Override
public void init() {
    List<Attribute> attributes = createExacOutputAttributes();
    List<Attribute> resourceMetaData = new ArrayList<>(asList(attributeFactory.create().setName(EXAC_AF_ResourceAttributeName).setDataType(STRING), attributeFactory.create().setName(EXAC_AC_HOM_ResourceAttributeName).setDataType(STRING), attributeFactory.create().setName(EXAC_AC_HET_ResourceAttributeName).setDataType(STRING)));
    AnnotatorInfo exacInfo = AnnotatorInfo.create(READY, POPULATION_REFERENCE, "exac", " The Exome Aggregation Consortium (ExAC) is a coalition of investigators seeking to aggregate" + " and harmonize exome sequencing data from a wide variety of large-scale sequencing projects" + ", and to make summary data available for the wider scientific community.The data set provided" + " on this website spans 60,706 unrelated individuals sequenced as part of various " + "disease-specific and population genetic studies. ", attributes);
    // TODO: properly test multiAllelicFresultFilter
    LocusQueryCreator locusQueryCreator = new LocusQueryCreator(vcfAttributes);
    MultiAllelicResultFilter multiAllelicResultFilter = new MultiAllelicResultFilter(resourceMetaData, vcfAttributes);
    EntityAnnotator entityAnnotator = new AbstractAnnotator(EXAC_TABIX_RESOURCE, exacInfo, locusQueryCreator, multiAllelicResultFilter, dataService, resources, new SingleFileLocationCmdLineAnnotatorSettingsConfigurer(EXAC_LOCATION, exacAnnotatorSettings)) {

        @Override
        public List<Attribute> createAnnotatorAttributes(AttributeFactory attributeFactory) {
            return createExacOutputAttributes();
        }

        @Override
        protected Object getResourceAttributeValue(Attribute attr, Entity sourceEntity) {
            String attrName = EXAC_AF.equals(attr.getName()) ? EXAC_AF_ResourceAttributeName : EXAC_AC_HOM.equals(attr.getName()) ? EXAC_AC_HOM_ResourceAttributeName : EXAC_AC_HET.equals(attr.getName()) ? EXAC_AC_HET_ResourceAttributeName : attr.getName();
            return sourceEntity.get(attrName);
        }
    };
    annotator.init(entityAnnotator);
}
Also used : LocusQueryCreator(org.molgenis.data.annotation.core.query.LocusQueryCreator) Entity(org.molgenis.data.Entity) Attribute(org.molgenis.data.meta.model.Attribute) MultiAllelicResultFilter(org.molgenis.data.annotation.core.filter.MultiAllelicResultFilter) EntityAnnotator(org.molgenis.data.annotation.core.entity.EntityAnnotator) ArrayList(java.util.ArrayList) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) AbstractAnnotator(org.molgenis.data.annotation.core.entity.impl.framework.AbstractAnnotator) AnnotatorInfo(org.molgenis.data.annotation.core.entity.AnnotatorInfo) AttributeFactory(org.molgenis.data.meta.model.AttributeFactory) SingleFileLocationCmdLineAnnotatorSettingsConfigurer(org.molgenis.data.annotation.web.settings.SingleFileLocationCmdLineAnnotatorSettingsConfigurer)

Example 12 with MultiAllelicResultFilter

use of org.molgenis.data.annotation.core.filter.MultiAllelicResultFilter in project molgenis by molgenis.

the class MultiAllelicResultFilterTest method testMultiLineMerge.

/*
	 * entity list:
	 * 3	300	G	A	0.2|23.1
	 * 3	300	G	T	-2.4|0.123
	 * 3	300	G	X	-0.002|2.3
	 * 3	300	G	C	0.5|14.5
	 * 3	300	GC	A	0.2|23.1
	 * 3	300	GC	T	-2.4|0.123
	 * 3	300	C	GX	-0.002|2.3
	 * 3	300	C	GC	0.5|14.5
	 *
	 * should become:
	 * 3	300	G	A,T,X,C	0.2|23.1,-2.4|0.123,-0.002|2.3,0.5|14.5
	 * 3	300	GC	A,T	0.2|23.1,-2.4|0.123
	 * 3	300	C	GX,GC	-0.002|2.3,0.5|14.5
	 */
@Test
public void testMultiLineMerge() {
    String customAttrb = "MyAnnotation";
    EntityType multiLineTestEMD = entityTypeFactory.create("entity");
    multiLineTestEMD.addAttribute(vcfAttributes.getChromAttribute());
    multiLineTestEMD.addAttribute(vcfAttributes.getPosAttribute());
    multiLineTestEMD.addAttribute(vcfAttributes.getIdAttribute());
    multiLineTestEMD.addAttribute(vcfAttributes.getRefAttribute());
    multiLineTestEMD.addAttribute(vcfAttributes.getAltAttribute());
    multiLineTestEMD.addAttribute(attributeFactory.create().setName(customAttrb).setDataType(STRING));
    Entity multiLineEntity1 = new DynamicEntity(multiLineTestEMD);
    multiLineEntity1.set(VcfAttributes.CHROM, "3");
    multiLineEntity1.set(VcfAttributes.POS, 300);
    multiLineEntity1.set(VcfAttributes.REF, "G");
    multiLineEntity1.set(VcfAttributes.ALT, "A");
    multiLineEntity1.set(customAttrb, "0.2|23.1");
    Entity multiLineEntity2 = new DynamicEntity(multiLineTestEMD);
    multiLineEntity2.set(VcfAttributes.CHROM, "3");
    multiLineEntity2.set(VcfAttributes.POS, 300);
    multiLineEntity2.set(VcfAttributes.REF, "G");
    multiLineEntity2.set(VcfAttributes.ALT, "T");
    multiLineEntity2.set(customAttrb, "-2.4|0.123");
    Entity multiLineEntity3 = new DynamicEntity(multiLineTestEMD);
    multiLineEntity3.set(VcfAttributes.CHROM, "3");
    multiLineEntity3.set(VcfAttributes.POS, 300);
    multiLineEntity3.set(VcfAttributes.REF, "G");
    multiLineEntity3.set(VcfAttributes.ALT, "X");
    multiLineEntity3.set(customAttrb, "-0.002|2.3");
    Entity multiLineEntity4 = new DynamicEntity(multiLineTestEMD);
    multiLineEntity4.set(VcfAttributes.CHROM, "3");
    multiLineEntity4.set(VcfAttributes.POS, 300);
    multiLineEntity4.set(VcfAttributes.REF, "G");
    multiLineEntity4.set(VcfAttributes.ALT, "C");
    multiLineEntity4.set(customAttrb, "0.5|14.5");
    Entity multiLineEntity5 = new DynamicEntity(multiLineTestEMD);
    multiLineEntity5.set(VcfAttributes.CHROM, "3");
    multiLineEntity5.set(VcfAttributes.POS, 300);
    multiLineEntity5.set(VcfAttributes.REF, "GC");
    multiLineEntity5.set(VcfAttributes.ALT, "A");
    multiLineEntity5.set("MyAnnotation", "0.2|23.1");
    Entity multiLineEntity6 = new DynamicEntity(multiLineTestEMD);
    multiLineEntity6.set(VcfAttributes.CHROM, "3");
    multiLineEntity6.set(VcfAttributes.POS, 300);
    multiLineEntity6.set(VcfAttributes.REF, "GC");
    multiLineEntity6.set(VcfAttributes.ALT, "T");
    multiLineEntity6.set(customAttrb, "-2.4|0.123");
    Entity multiLineEntity7 = new DynamicEntity(multiLineTestEMD);
    multiLineEntity7.set(VcfAttributes.CHROM, "3");
    multiLineEntity7.set(VcfAttributes.POS, 300);
    multiLineEntity7.set(VcfAttributes.REF, "C");
    multiLineEntity7.set(VcfAttributes.ALT, "GX");
    multiLineEntity7.set(customAttrb, "-0.002|2.3");
    Entity multiLineEntity8 = new DynamicEntity(multiLineTestEMD);
    multiLineEntity8.set(VcfAttributes.CHROM, "3");
    multiLineEntity8.set(VcfAttributes.POS, 300);
    multiLineEntity8.set(VcfAttributes.REF, "C");
    multiLineEntity8.set(VcfAttributes.ALT, "GC");
    multiLineEntity8.set(customAttrb, "0.5|14.5");
    Entity expectedResultEntity1 = new DynamicEntity(multiLineTestEMD);
    expectedResultEntity1.set(VcfAttributes.CHROM, "3");
    expectedResultEntity1.set(VcfAttributes.POS, 300);
    expectedResultEntity1.set(VcfAttributes.REF, "G");
    expectedResultEntity1.set(VcfAttributes.ALT, "A,T,X,C");
    expectedResultEntity1.set(customAttrb, "0.2|23.1,-2.4|0.123,-0.002|2.3,0.5|14.5");
    Entity expectedResultEntity2 = new DynamicEntity(multiLineTestEMD);
    expectedResultEntity2.set(VcfAttributes.CHROM, "3");
    expectedResultEntity2.set(VcfAttributes.POS, 300);
    expectedResultEntity2.set(VcfAttributes.REF, "GC");
    expectedResultEntity2.set(VcfAttributes.ALT, "A,T");
    expectedResultEntity2.set(customAttrb, "0.2|23.1,-2.4|0.123");
    Entity expectedResultEntity3 = new DynamicEntity(multiLineTestEMD);
    expectedResultEntity3.set(VcfAttributes.CHROM, "3");
    expectedResultEntity3.set(VcfAttributes.POS, 300);
    expectedResultEntity3.set(VcfAttributes.REF, "C");
    expectedResultEntity3.set(VcfAttributes.ALT, "GX,GC");
    expectedResultEntity3.set(customAttrb, "-0.002|2.3,0.5|14.5");
    Iterable<Entity> multiLineInput = Arrays.asList(multiLineEntity1, multiLineEntity2, multiLineEntity3, multiLineEntity4, multiLineEntity5, multiLineEntity6, multiLineEntity7, multiLineEntity8);
    MultiAllelicResultFilter multiAllelicResultFilter = new MultiAllelicResultFilter(Lists.newArrayList((multiLineTestEMD.getAttribute(customAttrb))), vcfAttributes);
    Iterable<Entity> expectedResult = Arrays.asList(expectedResultEntity1, expectedResultEntity2, expectedResultEntity3);
    Iterable<Entity> actualResult = multiAllelicResultFilter.merge(multiLineInput);
    assertTrue(EntityUtils.equals(actualResult.iterator().next(), expectedResult.iterator().next()));
}
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) MultiAllelicResultFilter(org.molgenis.data.annotation.core.filter.MultiAllelicResultFilter) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 13 with MultiAllelicResultFilter

use of org.molgenis.data.annotation.core.filter.MultiAllelicResultFilter in project molgenis by molgenis.

the class MultiAllelicResultFilterTest method filterResultsSourceHasNoRef.

@Test
public void filterResultsSourceHasNoRef() {
    MultiAllelicResultFilter filter = new MultiAllelicResultFilter(Collections.singletonList(attributeFactory.create().setName("annotation").setDataType(STRING)), vcfAttributes);
    Optional<Entity> result = filter.filterResults(Collections.singletonList(resultEntity10), entityNoRef, false);
    assertEquals(result, Optional.absent());
}
Also used : DynamicEntity(org.molgenis.data.support.DynamicEntity) Entity(org.molgenis.data.Entity) MultiAllelicResultFilter(org.molgenis.data.annotation.core.filter.MultiAllelicResultFilter) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 14 with MultiAllelicResultFilter

use of org.molgenis.data.annotation.core.filter.MultiAllelicResultFilter in project molgenis by molgenis.

the class MultiAllelicResultFilterTest method filterResultsTest12.

@Test
public void filterResultsTest12() {
    MultiAllelicResultFilter filter = new MultiAllelicResultFilter(Collections.singletonList(attributeFactory.create().setName("annotation").setDataType(STRING)), vcfAttributes);
    Optional<Entity> result = filter.filterResults(Collections.singletonList(resultEntity10), entity10, false);
    assertEquals(Lists.newArrayList(result.asSet()).get(0).getString("annotation"), "19");
}
Also used : DynamicEntity(org.molgenis.data.support.DynamicEntity) Entity(org.molgenis.data.Entity) MultiAllelicResultFilter(org.molgenis.data.annotation.core.filter.MultiAllelicResultFilter) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 15 with MultiAllelicResultFilter

use of org.molgenis.data.annotation.core.filter.MultiAllelicResultFilter in project molgenis by molgenis.

the class MultiAllelicResultFilterTest method filterResultsTest8.

@Test
public void filterResultsTest8() {
    MultiAllelicResultFilter filter = new MultiAllelicResultFilter(Collections.singletonList(attributeFactory.create().setName("annotation").setDataType(STRING)), vcfAttributes);
    Optional<Entity> result8 = filter.filterResults(Collections.singletonList(resultEntity5), entity1, false);
    assertEquals(Lists.newArrayList(result8.asSet()).get(0).getString("annotation"), "8");
}
Also used : DynamicEntity(org.molgenis.data.support.DynamicEntity) Entity(org.molgenis.data.Entity) MultiAllelicResultFilter(org.molgenis.data.annotation.core.filter.MultiAllelicResultFilter) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Aggregations

MultiAllelicResultFilter (org.molgenis.data.annotation.core.filter.MultiAllelicResultFilter)21 AbstractMolgenisSpringTest (org.molgenis.data.AbstractMolgenisSpringTest)16 Entity (org.molgenis.data.Entity)16 Test (org.testng.annotations.Test)16 DynamicEntity (org.molgenis.data.support.DynamicEntity)14 AnnotatorInfo (org.molgenis.data.annotation.core.entity.AnnotatorInfo)5 EntityAnnotator (org.molgenis.data.annotation.core.entity.EntityAnnotator)5 AbstractAnnotator (org.molgenis.data.annotation.core.entity.impl.framework.AbstractAnnotator)5 LocusQueryCreator (org.molgenis.data.annotation.core.query.LocusQueryCreator)5 Attribute (org.molgenis.data.meta.model.Attribute)5 AttributeFactory (org.molgenis.data.meta.model.AttributeFactory)5 SingleFileLocationCmdLineAnnotatorSettingsConfigurer (org.molgenis.data.annotation.web.settings.SingleFileLocationCmdLineAnnotatorSettingsConfigurer)4 MolgenisDataException (org.molgenis.data.MolgenisDataException)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 ArrayList (java.util.ArrayList)1 EntityType (org.molgenis.data.meta.model.EntityType)1