Search in sources :

Example 11 with AttributeFactory

use of org.molgenis.data.meta.model.AttributeFactory in project molgenis by molgenis.

the class ThousandGenomesAnnotator method init.

@Override
public void init() {
    List<Attribute> attributes = createThousandGenomesOutputAttributes();
    AnnotatorInfo thousandGenomeInfo = AnnotatorInfo.create(Status.READY, AnnotatorInfo.Type.POPULATION_REFERENCE, NAME, "The 1000 Genomes Project is an international collaboration to produce an " + "extensive public catalog of human genetic variation, including SNPs and structural variants, " + "and their haplotype contexts. This resource will support genome-wide association studies and other " + "medical research studies. " + "The genomes of about 2500 unidentified people from about 25 populations around the world will be" + "sequenced using next-generation sequencing technologies. " + "The results of the study will be freely and publicly accessible to researchers worldwide. " + "Further information about the project is available in the About tab. Information about downloading, " + "browsing or using the 1000 Genomes data is available at: http://www.1000genomes.org/ ", attributes);
    LocusQueryCreator locusQueryCreator = new LocusQueryCreator(vcfAttributes);
    MultiAllelicResultFilter multiAllelicResultFilter = new MultiAllelicResultFilter(singletonList(attributeFactory.create().setName(THOUSAND_GENOME_AF_RESOURCE_ATTRIBUTE_NAME).setDataType(DECIMAL)), vcfAttributes);
    EntityAnnotator entityAnnotator = new AbstractAnnotator(THOUSAND_GENOME_MULTI_FILE_RESOURCE, thousandGenomeInfo, locusQueryCreator, multiAllelicResultFilter, dataService, resources, (annotationSourceFileName) -> {
        thousendGenomesAnnotatorSettings.set(ROOT_DIRECTORY, annotationSourceFileName);
        thousendGenomesAnnotatorSettings.set(FILEPATTERN, "ALL.chr%s.phase3_shapeit2_mvncall_integrated_v5.20130502.genotypes.vcf.gz");
        thousendGenomesAnnotatorSettings.set(CHROMOSOMES, "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22");
    }) {

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

        @Override
        protected Object getResourceAttributeValue(Attribute attr, Entity entityType) {
            String attrName = THOUSAND_GENOME_AF.equals(attr.getName()) ? THOUSAND_GENOME_AF_RESOURCE_ATTRIBUTE_NAME : attr.getName();
            return entityType.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) 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)

Example 12 with AttributeFactory

use of org.molgenis.data.meta.model.AttributeFactory in project molgenis by molgenis.

the class AnnotatorUtils method createCompoundForAnnotator.

private static void createCompoundForAnnotator(EntityType entityType, AttributeFactory attributeFactory, RepositoryAnnotator annotator, List<Attribute> attributes, String compoundName) {
    Attribute compound;
    compound = attributeFactory.create().setName(compoundName).setLabel(annotator.getFullName()).setDataType(COMPOUND).setLabel(annotator.getSimpleName());
    attributes.stream().filter(part -> entityType.getAttribute(part.getName()) == null).forEachOrdered(part -> part.setParent(compound));
    entityType.addAttribute(compound);
    // Only add attributes that do not already exist. We assume existing attributes are added in a previous annotation run.
    // This is a potential risk if an attribute with that name already exist that was not added by the annotator.
    // This risk is relatively low since annotator attributes are prefixed.
    attributes = attributes.stream().filter(attribute -> entityType.getAttribute(attribute.getName()) == null).collect(toList());
    entityType.addAttributes(attributes);
}
Also used : AttributeFactory(org.molgenis.data.meta.model.AttributeFactory) RepositoryAnnotator(org.molgenis.data.annotation.core.RepositoryAnnotator) HashMap(java.util.HashMap) StringUtils(org.apache.commons.lang3.StringUtils) Attribute(org.molgenis.data.meta.model.Attribute) EntityType(org.molgenis.data.meta.model.EntityType) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) VcfAttributes(org.molgenis.data.vcf.model.VcfAttributes) COMPOUND(org.molgenis.data.meta.AttributeType.COMPOUND) Map(java.util.Map) MolgenisDataException(org.molgenis.data.MolgenisDataException) Collections(java.util.Collections) Attribute(org.molgenis.data.meta.model.Attribute)

Aggregations

AttributeFactory (org.molgenis.data.meta.model.AttributeFactory)12 Attribute (org.molgenis.data.meta.model.Attribute)11 AnnotatorInfo (org.molgenis.data.annotation.core.entity.AnnotatorInfo)9 EntityAnnotator (org.molgenis.data.annotation.core.entity.EntityAnnotator)9 AbstractAnnotator (org.molgenis.data.annotation.core.entity.impl.framework.AbstractAnnotator)8 LocusQueryCreator (org.molgenis.data.annotation.core.query.LocusQueryCreator)7 SingleFileLocationCmdLineAnnotatorSettingsConfigurer (org.molgenis.data.annotation.web.settings.SingleFileLocationCmdLineAnnotatorSettingsConfigurer)7 MultiAllelicResultFilter (org.molgenis.data.annotation.core.filter.MultiAllelicResultFilter)5 Entity (org.molgenis.data.Entity)4 MolgenisDataException (org.molgenis.data.MolgenisDataException)2 VcfAttributes (org.molgenis.data.vcf.model.VcfAttributes)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors.toList (java.util.stream.Collectors.toList)1 StringUtils (org.apache.commons.lang3.StringUtils)1