Search in sources :

Example 1 with VcfMetaFormat

use of org.molgenis.vcf.meta.VcfMetaFormat in project molgenis by molgenis.

the class VcfToEntity method createSampleEntityType.

private EntityType createSampleEntityType(String entityTypeId, Iterable<VcfMetaFormat> formatMetaData) {
    EntityType result = null;
    if (formatMetaData.iterator().hasNext()) {
        String sampleEntityTypeId = entityTypeId + "Sample";
        result = entityTypeFactory.create(sampleEntityTypeId);
        result.setLabel(sampleEntityTypeId);
        Attribute idAttr = attrMetaFactory.create().setName(ID).setAggregatable(true).setVisible(false);
        Attribute nameAttr = attrMetaFactory.create().setName(NAME).setDataType(TEXT).setAggregatable(true).setNillable(false);
        Attribute originalNameAttr = attrMetaFactory.create().setName(ORIGINAL_NAME).setDataType(TEXT);
        result.addAttribute(idAttr, ROLE_ID);
        result.addAttribute(nameAttr, ROLE_LABEL, ROLE_LOOKUP);
        for (VcfMetaFormat meta : formatMetaData) {
            String name = meta.getId();
            if (NameValidator.KEYWORDS.contains(name) || NameValidator.KEYWORDS.contains(name.toUpperCase())) {
                name = name + "_";
            }
            Attribute attr = attrMetaFactory.create().setName(name.replaceAll("[-.*$&%^()#!@?_]", "")).setDataType(vcfFieldTypeToMolgenisFieldType(meta)).setAggregatable(true).setLabel(meta.getId());
            result.addAttribute(attr);
        }
        result.addAttribute(originalNameAttr);
    }
    return result;
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) VcfMetaFormat(org.molgenis.vcf.meta.VcfMetaFormat) Attribute(org.molgenis.data.meta.model.Attribute)

Aggregations

Attribute (org.molgenis.data.meta.model.Attribute)1 EntityType (org.molgenis.data.meta.model.EntityType)1 VcfMetaFormat (org.molgenis.vcf.meta.VcfMetaFormat)1