use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class EntityAttributesValidatorTest method checkRangeMinOnlyInvalid.
@Test
public void checkRangeMinOnlyInvalid() {
Entity entity = new DynamicEntity(intRangeMinMeta);
entity.set("id", "123");
entity.set("intrangemin", -1);
Set<ConstraintViolation> constraints = entityAttributesValidator.validate(entity, intRangeMinMeta);
assertEquals(constraints.size(), 1);
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class VcfToEntityTest method testToEntityAlternativeAlleles.
@Test
public void testToEntityAlternativeAlleles() throws IOException {
VcfRecord record = new VcfRecord(vcfMetaSmall, new String[] { "10", "12345", "id3", "A", "A,C,G,T,N,*", "7.9123", "pass", "DF;DF2;CHAR=-" });
Entity entity = vcfToEntitySmall.toEntity(record);
Entity expected = new DynamicEntity(vcfToEntitySmall.getEntityType());
expected.set("#CHROM", "10");
expected.set("ALT", "A,C,G,T,N,*");
expected.set("POS", 12345);
expected.set("REF", "A");
expected.set("FILTER", "pass");
expected.set("QUAL", "7.9123");
expected.set("ID", "id3");
expected.set("INTERNAL_ID", entity.get("INTERNAL_ID"));
expected.set("DF", true);
expected.set("DF2", true);
expected.set("CHAR", "-");
assertTrue(EntityUtils.equals(entity, expected));
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class VcfWriterUtilsIT method getEffectEntities.
private List<Entity> getEffectEntities(List<String> altAlleles) {
List<Entity> effectEntities = newArrayList();
for (int i = 0; i < altAlleles.size(); i++) {
String gene = "BRCA" + (i + 1);
Entity effectEntity = new DynamicEntity(effectMeta);
String altAllele = altAlleles.get(i);
effectEntity.set("id", "eff" + (i + 1));
effectEntity.set(ALT, altAllele);
effectEntity.set("ALT_GENE", altAllele + "_" + gene);
effectEntity.set("GENE", gene);
effectEntity.set(PUTATIVE_IMPACT, "HIGH");
effectEntity.set(TYPE, "STOP_GAIN");
effectEntities.add(effectEntity);
}
return effectEntities;
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class VcfWriterUtilsIT method convertToVcfInfoGtFirst.
// regression test for https://github.com/molgenis/molgenis/issues/3643
@Test
public void convertToVcfInfoGtFirst() throws MolgenisDataException, IOException {
String formatDpAttrName = "DP";
String formatEcAttrName = "EC";
String formatGtAttrName = FORMAT_GT;
String idAttrName = "idAttr";
String sampleIdAttrName = VcfRepository.NAME;
EntityType sampleEntityType = entityTypeFactory.create("vcfSampleEntity");
Attribute sampleId = attributeFactory.create().setName(sampleIdAttrName).setIdAttribute(true);
sampleEntityType.addAttribute(sampleId);
sampleEntityType.addAttribute(attributeFactory.create().setName(formatDpAttrName));
sampleEntityType.addAttribute(attributeFactory.create().setName(formatEcAttrName));
sampleEntityType.addAttribute(attributeFactory.create().setName(formatGtAttrName));
EntityType entityType = entityTypeFactory.create("vcfEntity");
Attribute id = attributeFactory.create().setName(idAttrName).setIdAttribute(true);
entityType.addAttribute(id);
entityType.addAttribute(vcfAttributes.getChromAttribute());
entityType.addAttribute(vcfAttributes.getPosAttribute());
entityType.addAttribute(vcfAttributes.getIdAttribute());
entityType.addAttribute(vcfAttributes.getRefAttribute());
entityType.addAttribute(vcfAttributes.getAltAttribute());
entityType.addAttribute(vcfAttributes.getQualAttribute());
entityType.addAttribute(vcfAttributes.getFilterAttribute());
entityType.addAttribute(attributeFactory.create().setName(INFO).setDataType(COMPOUND));
entityType.addAttribute(attributeFactory.create().setName(SAMPLES).setDataType(MREF).setRefEntity(sampleEntityType));
Entity sampleEntity = new DynamicEntity(sampleEntityType);
sampleEntity.set(sampleIdAttrName, "0");
sampleEntity.set(formatDpAttrName, "5");
sampleEntity.set(formatEcAttrName, "5");
sampleEntity.set(formatGtAttrName, "1/1");
Entity vcfEntity = new DynamicEntity(entityType);
vcfEntity.set(idAttrName, "0");
vcfEntity.set(CHROM, "1");
vcfEntity.set(POS, 565286);
vcfEntity.set(ID, "rs1578391");
vcfEntity.set(REF, "C");
vcfEntity.set(ALT, "T");
vcfEntity.set(QUAL, null);
vcfEntity.set(FILTER, "flt");
vcfEntity.set(INFO, null);
vcfEntity.set(SAMPLES, newArrayList(sampleEntity));
StringWriter strWriter = new StringWriter();
try (BufferedWriter writer = new BufferedWriter(strWriter)) {
writeToVcf(vcfEntity, newArrayList(), newArrayList(), writer);
}
assertEquals(strWriter.toString(), "1 565286 rs1578391 C T . flt idAttr=0 GT:DP:EC 1/1:5:5");
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class VcfWriterUtilsIT method getGeneEntities.
private List<Entity> getGeneEntities(List<String> altAlleles) {
List<Entity> geneEntities = newArrayList();
for (String allele : altAlleles) {
Entity geneEntity = new DynamicEntity(geneMeta);
geneEntity.set("id", UUID.randomUUID().toString());
switch(allele) {
case "A":
geneEntity.set("Gene", "BRCA1");
break;
case "T":
geneEntity.set("Gene", "COL7A1");
break;
case "C":
geneEntity.set("Gene", "AIP");
break;
case "G":
geneEntity.set("Gene", "CHD7");
break;
default:
geneEntity.set("Gene", "NONE");
break;
}
geneEntities.add(geneEntity);
}
return geneEntities;
}
Aggregations