Search in sources :

Example 6 with SingleNucleotidePolymorphism

use of uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism in project goci by EBISPOT.

the class AssociationService method loadAssociatedData.

public void loadAssociatedData(Association association) {
    int traitCount = association.getEfoTraits().size();
    Study study = studyService.fetchOne(association.getStudy());
    AtomicInteger reportedGeneCount = new AtomicInteger();
    Collection<SingleNucleotidePolymorphism> snps = new HashSet<>();
    Collection<Region> regions = new HashSet<>();
    Collection<Gene> mappedGenes = new HashSet<>();
    Map<String, Set<String>> mappedGeneEntrezIds = new HashMap<>();
    Map<String, Set<String>> mappedGeneEnsemblIds = new HashMap<>();
    association.getLoci().forEach(locus -> {
        locus.getStrongestRiskAlleles().stream().map(RiskAllele::getSnp).forEach(snp -> {
            Collection<Location> snpLocations = snp.getLocations();
            for (Location location : snpLocations) {
                regions.add(location.getRegion());
            }
            snp.getGenomicContexts().forEach(context -> {
                mappedGenes.add(context.getGene());
                String geneName = context.getGene().getGeneName();
                Collection<EntrezGene> geneEntrezGeneIds = context.getGene().getEntrezGeneIds();
                Collection<EnsemblGene> geneEnsemblGeneIds = context.getGene().getEnsemblGeneIds();
                if (mappedGeneEntrezIds.containsKey(geneName)) {
                    for (EntrezGene entrezGene : geneEntrezGeneIds) {
                        mappedGeneEntrezIds.get(geneName).add(entrezGene.getEntrezGeneId());
                    }
                } else {
                    Set<String> entrezIds = new HashSet<>();
                    for (EntrezGene entrezGene : geneEntrezGeneIds) {
                        entrezIds.add(entrezGene.getEntrezGeneId());
                    }
                    mappedGeneEntrezIds.put(geneName, entrezIds);
                }
                if (mappedGeneEnsemblIds.containsKey(geneName)) {
                    for (EnsemblGene ensemblGene : geneEnsemblGeneIds) {
                        mappedGeneEnsemblIds.get(geneName).add(ensemblGene.getEnsemblGeneId());
                    }
                } else {
                    Set<String> ensemblIds = new HashSet<>();
                    for (EnsemblGene ensemblGene : geneEnsemblGeneIds) {
                        ensemblIds.add(ensemblGene.getEnsemblGeneId());
                    }
                    mappedGeneEntrezIds.put(geneName, ensemblIds);
                }
            });
            snps.add(snp);
        });
        snps.addAll(locus.getStrongestRiskAlleles().stream().map(RiskAllele::getSnp).collect(Collectors.toList()));
        reportedGeneCount.addAndGet(locus.getAuthorReportedGenes().size());
        locus.getAuthorReportedGenes().forEach(authorReportedGene -> {
            authorReportedGene.getEnsemblGeneIds().size();
            authorReportedGene.getEntrezGeneIds().size();
        });
    });
    getLog().trace("Association '" + association.getId() + "' is mapped to " + "" + traitCount + " EFO traits where study id = " + study.getId() + " " + "(author reported " + reportedGeneCount + " gene(s)); " + "this reports on " + snps.size() + " SNPs in " + regions.size() + " regions, " + "mapped to " + mappedGenes.size() + " genes.");
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) EntrezGene(uk.ac.ebi.spot.goci.model.EntrezGene) RiskAllele(uk.ac.ebi.spot.goci.model.RiskAllele) EnsemblGene(uk.ac.ebi.spot.goci.model.EnsemblGene) EntrezGene(uk.ac.ebi.spot.goci.model.EntrezGene) EnsemblGene(uk.ac.ebi.spot.goci.model.EnsemblGene) Gene(uk.ac.ebi.spot.goci.model.Gene) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SingleNucleotidePolymorphism(uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism) Region(uk.ac.ebi.spot.goci.model.Region) HashSet(java.util.HashSet) Location(uk.ac.ebi.spot.goci.model.Location)

Example 7 with SingleNucleotidePolymorphism

use of uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism in project goci by EBISPOT.

the class LociAttributesService method createSnp.

public SingleNucleotidePolymorphism createSnp(String curatorEnteredSNP) {
    // Create new SNP
    SingleNucleotidePolymorphism newSNP = new SingleNucleotidePolymorphism();
    newSNP.setRsId(tidy_curator_entered_string(curatorEnteredSNP));
    return newSNP;
}
Also used : SingleNucleotidePolymorphism(uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism)

Example 8 with SingleNucleotidePolymorphism

use of uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism in project goci by EBISPOT.

the class SingleSnpMultiSnpAssociationService method createForm.

// Creates form which we can then return to view for editing etc.
@Override
public SnpAssociationForm createForm(Association association) {
    SnpAssociationStandardMultiForm form = new SnpAssociationStandardMultiForm();
    // Set association ID
    form.setAssociationId(association.getId());
    // Set simple string and float association attributes
    form.setRiskFrequency(association.getRiskFrequency());
    form.setPvalueDescription(association.getPvalueDescription());
    form.setSnpType(association.getSnpType());
    form.setMultiSnpHaplotype(association.getMultiSnpHaplotype());
    form.setSnpApproved(association.getSnpApproved());
    form.setPvalueMantissa(association.getPvalueMantissa());
    form.setPvalueExponent(association.getPvalueExponent());
    form.setStandardError(association.getStandardError());
    form.setRange(association.getRange());
    form.setDescription(association.getDescription());
    // Set OR/Beta values
    form.setOrPerCopyNum(association.getOrPerCopyNum());
    form.setOrPerCopyRecip(association.getOrPerCopyRecip());
    form.setOrPerCopyRecipRange(association.getOrPerCopyRecipRange());
    form.setBetaNum(association.getBetaNum());
    form.setBetaUnit(association.getBetaUnit());
    form.setBetaDirection(association.getBetaDirection());
    // Add collection of Efo traits
    form.setEfoTraits(association.getEfoTraits());
    // For each locus get genes and risk alleles
    Collection<Locus> loci = association.getLoci();
    Collection<Gene> locusGenes = new ArrayList<>();
    Collection<RiskAllele> locusRiskAlleles = new ArrayList<RiskAllele>();
    // For multi-snp and standard snps we assume their is only one locus
    for (Locus locus : loci) {
        locusGenes.addAll(locus.getAuthorReportedGenes());
        locusRiskAlleles.addAll(locus.getStrongestRiskAlleles().stream().sorted((v1, v2) -> Long.compare(v1.getId(), v2.getId())).collect(Collectors.toList()));
        // There should only be one locus thus should be safe to set these here
        form.setMultiSnpHaplotypeNum(locus.getHaplotypeSnpCount());
        form.setMultiSnpHaplotypeDescr(locus.getDescription());
    }
    // Get name of gene and add to form
    Collection<String> authorReportedGenes = new ArrayList<>();
    for (Gene locusGene : locusGenes) {
        authorReportedGenes.add(locusGene.getGeneName());
    }
    form.setAuthorReportedGenes(authorReportedGenes);
    // Handle snp rows
    Collection<GenomicContext> snpGenomicContexts = new ArrayList<GenomicContext>();
    Collection<SingleNucleotidePolymorphism> snps = new ArrayList<>();
    List<SnpFormRow> snpFormRows = new ArrayList<SnpFormRow>();
    List<SnpMappingForm> snpMappingForms = new ArrayList<SnpMappingForm>();
    for (RiskAllele riskAllele : locusRiskAlleles) {
        SnpFormRow snpFormRow = new SnpFormRow();
        snpFormRow.setStrongestRiskAllele(riskAllele.getRiskAlleleName());
        SingleNucleotidePolymorphism snp = riskAllele.getSnp();
        snps.add(snp);
        String rsID = snp.getRsId();
        snpFormRow.setSnp(rsID);
        Collection<Location> locations = snp.getLocations();
        for (Location location : locations) {
            SnpMappingForm snpMappingForm = new SnpMappingForm(rsID, location);
            snpMappingForms.add(snpMappingForm);
        }
        // Set proxy if one is present
        Collection<String> proxySnps = new ArrayList<>();
        if (riskAllele.getProxySnps() != null) {
            for (SingleNucleotidePolymorphism riskAlleleProxySnp : riskAllele.getProxySnps()) {
                proxySnps.add(riskAlleleProxySnp.getRsId());
            }
        }
        snpFormRow.setProxySnps(proxySnps);
        snpGenomicContexts.addAll(genomicContextRepository.findBySnpId(snp.getId()));
        snpFormRows.add(snpFormRow);
    }
    form.setSnpMappingForms(snpMappingForms);
    form.setGenomicContexts(snpGenomicContexts);
    form.setSnps(snps);
    form.setSnpFormRows(snpFormRows);
    return form;
}
Also used : RiskAllele(uk.ac.ebi.spot.goci.model.RiskAllele) ArrayList(java.util.ArrayList) GenomicContext(uk.ac.ebi.spot.goci.model.GenomicContext) SnpMappingForm(uk.ac.ebi.spot.goci.curation.model.SnpMappingForm) SnpAssociationStandardMultiForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationStandardMultiForm) SnpFormRow(uk.ac.ebi.spot.goci.curation.model.SnpFormRow) Gene(uk.ac.ebi.spot.goci.model.Gene) SingleNucleotidePolymorphism(uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism) Locus(uk.ac.ebi.spot.goci.model.Locus) Location(uk.ac.ebi.spot.goci.model.Location)

Example 9 with SingleNucleotidePolymorphism

use of uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism in project goci by EBISPOT.

the class SnpAssociationTableViewService method createSnpAssociationTableView.

/**
     * Create object, from Association, that will be returned to view
     *
     * @param association Association object
     */
public SnpAssociationTableView createSnpAssociationTableView(Association association) {
    SnpAssociationTableView snpAssociationTableView = new SnpAssociationTableView();
    // For SNP interaction studies snp, proxy snps, risk alleles etc
    // should be separated by an 'x'
    String delimiter = "; ";
    if (association.getSnpInteraction()) {
        delimiter = " x ";
    }
    snpAssociationTableView.setAssociationId(association.getId());
    // For each locus relevant attributes
    Collection<Locus> loci = association.getLoci();
    Collection<String> allLociGenes = new ArrayList<>();
    Collection<String> allLociRiskAlleles = new ArrayList<String>();
    Collection<String> allLociSnps = new ArrayList<String>();
    Collection<String> allLociProxySnps = new ArrayList<String>();
    Collection<String> allLociRiskAlleleFrequencies = new ArrayList<String>();
    Collection<String> allLociSnpStatuses = new ArrayList<String>();
    // By looking at each locus in turn we can keep order in view
    for (Locus locus : loci) {
        // Store gene names, a locus can have a number of genes attached.
        // Per locus create a comma separated list and add to an array.
        // Further processing will then delimit this list
        // either by ; or 'x' depending on association type
        Collection<String> currentlocusGenes = new ArrayList<>();
        String commaSeparatedGenes = "";
        for (Gene gene : locus.getAuthorReportedGenes()) {
            currentlocusGenes.add(gene.getGeneName());
        }
        if (!currentlocusGenes.isEmpty()) {
            commaSeparatedGenes = String.join(", ", currentlocusGenes);
            allLociGenes.add(commaSeparatedGenes);
        } else {
            allLociGenes.add("NR");
        }
        //This sort ensures that haplotype SNPs are displayed in the correct order
        Collection<RiskAllele> ra = locus.getStrongestRiskAlleles().stream().sorted((v1, v2) -> Long.compare(v1.getId(), v2.getId())).collect(Collectors.toList());
        for (RiskAllele riskAllele : ra) {
            allLociRiskAlleles.add(riskAllele.getRiskAlleleName());
            // Based on assumption we only have one locus with a single risk allele attached
            if (!association.getMultiSnpHaplotype() && !association.getSnpInteraction()) {
                if (riskAllele.getRiskFrequency() != null && !riskAllele.getRiskFrequency().isEmpty()) {
                    allLociRiskAlleleFrequencies.add(riskAllele.getRiskFrequency());
                }
            }
            // SNPs attached to risk allele
            SingleNucleotidePolymorphism snp = riskAllele.getSnp();
            allLociSnps.add(snp.getRsId());
            // Set proxies if present
            Collection<String> currentLocusProxies = new ArrayList<>();
            String commaSeparatedProxies = "";
            if (riskAllele.getProxySnps() != null) {
                for (SingleNucleotidePolymorphism proxySnp : riskAllele.getProxySnps()) {
                    currentLocusProxies.add(proxySnp.getRsId());
                }
            }
            // Comma separate proxies in view
            if (!currentLocusProxies.isEmpty()) {
                commaSeparatedProxies = String.join(", ", currentLocusProxies);
                allLociProxySnps.add(commaSeparatedProxies);
            } else {
                allLociProxySnps.add("NR");
            }
            // Only required for SNP interaction studies
            if (association.getSnpInteraction() != null) {
                if (association.getSnpInteraction()) {
                    // Genome wide Vs Limited List
                    Collection<String> snpStatus = new ArrayList<>();
                    String commaSeparatedSnpStatus = "";
                    if (riskAllele.getLimitedList() != null) {
                        if (riskAllele.getLimitedList()) {
                            snpStatus.add("LL");
                        }
                    }
                    if (riskAllele.getGenomeWide() != null) {
                        if (riskAllele.getGenomeWide()) {
                            snpStatus.add("GW");
                        }
                    }
                    if (!snpStatus.isEmpty()) {
                        commaSeparatedSnpStatus = String.join(", ", snpStatus);
                        allLociSnpStatuses.add(commaSeparatedSnpStatus);
                    } else {
                        allLociSnpStatuses.add("NR");
                    }
                    // Allele risk frequency
                    if (riskAllele.getRiskFrequency() != null && !riskAllele.getRiskFrequency().isEmpty()) {
                        allLociRiskAlleleFrequencies.add(riskAllele.getRiskFrequency());
                    } else {
                        allLociRiskAlleleFrequencies.add("NR");
                    }
                }
            }
        }
    }
    // Create delimited strings for view
    String authorReportedGenes = null;
    if (allLociGenes.size() > 1) {
        authorReportedGenes = String.join(delimiter, allLociGenes);
    } else {
        authorReportedGenes = String.join("", allLociGenes);
    }
    snpAssociationTableView.setAuthorReportedGenes(authorReportedGenes);
    String strongestRiskAlleles = null;
    if (allLociRiskAlleles.size() > 1) {
        strongestRiskAlleles = String.join(delimiter, allLociRiskAlleles);
    } else {
        strongestRiskAlleles = String.join("", allLociRiskAlleles);
    }
    snpAssociationTableView.setStrongestRiskAlleles(strongestRiskAlleles);
    String associationSnps = null;
    if (allLociSnps.size() > 1) {
        associationSnps = String.join(delimiter, allLociSnps);
    } else {
        associationSnps = String.join("", allLociSnps);
    }
    snpAssociationTableView.setSnps(associationSnps);
    String associationProxies = null;
    if (allLociProxySnps.size() > 1) {
        associationProxies = String.join(delimiter, allLociProxySnps);
    } else {
        associationProxies = String.join("", allLociProxySnps);
    }
    snpAssociationTableView.setProxySnps(associationProxies);
    // Set both risk frequencies
    String associationRiskAlleleFrequencies = null;
    if (allLociRiskAlleleFrequencies.size() > 1) {
        associationRiskAlleleFrequencies = String.join(delimiter, allLociRiskAlleleFrequencies);
    } else {
        associationRiskAlleleFrequencies = String.join("", allLociRiskAlleleFrequencies);
    }
    snpAssociationTableView.setRiskAlleleFrequencies(associationRiskAlleleFrequencies);
    snpAssociationTableView.setAssociationRiskFrequency(association.getRiskFrequency());
    String associationSnpStatuses = null;
    if (allLociSnpStatuses.size() > 1) {
        associationSnpStatuses = String.join(delimiter, allLociSnpStatuses);
    } else {
        associationSnpStatuses = String.join("", allLociSnpStatuses);
    }
    snpAssociationTableView.setSnpStatuses(associationSnpStatuses);
    snpAssociationTableView.setPvalueMantissa(association.getPvalueMantissa());
    snpAssociationTableView.setPvalueExponent(association.getPvalueExponent());
    snpAssociationTableView.setPvalueDescription(association.getPvalueDescription());
    Collection<String> efoTraits = new ArrayList<>();
    for (EfoTrait efoTrait : association.getEfoTraits()) {
        efoTraits.add(efoTrait.getTrait());
    }
    String associationEfoTraits = null;
    associationEfoTraits = String.join(", ", efoTraits);
    snpAssociationTableView.setEfoTraits(associationEfoTraits);
    // Set OR values
    snpAssociationTableView.setOrPerCopyNum(association.getOrPerCopyNum());
    snpAssociationTableView.setOrPerCopyRecip(association.getOrPerCopyRecip());
    snpAssociationTableView.setOrPerCopyRecipRange(association.getOrPerCopyRecipRange());
    // Set beta values
    snpAssociationTableView.setBetaNum(association.getBetaNum());
    snpAssociationTableView.setBetaDirection(association.getBetaDirection());
    snpAssociationTableView.setBetaUnit(association.getBetaUnit());
    snpAssociationTableView.setRange(association.getRange());
    snpAssociationTableView.setDescription(association.getDescription());
    snpAssociationTableView.setStandardError(association.getStandardError());
    snpAssociationTableView.setAssociationType(association.getSnpType());
    if (association.getMultiSnpHaplotype() != null) {
        if (association.getMultiSnpHaplotype()) {
            snpAssociationTableView.setMultiSnpHaplotype("Yes");
        }
        if (!association.getMultiSnpHaplotype()) {
            snpAssociationTableView.setMultiSnpHaplotype("No");
        }
    }
    if (association.getSnpInteraction() != null) {
        if (association.getSnpInteraction()) {
            snpAssociationTableView.setSnpInteraction("Yes");
        }
        if (!association.getSnpInteraction()) {
            snpAssociationTableView.setSnpInteraction("No");
        }
    }
    if (association.getSnpApproved() != null) {
        if (association.getSnpApproved()) {
            snpAssociationTableView.setSnpApproved("Yes");
        }
        if (!association.getSnpApproved()) {
            snpAssociationTableView.setSnpApproved("No");
        }
    }
    // Get validation warnings
    snpAssociationTableView.setValidationWarnings(associationValidationReportService.getWarningSet(association.getId()));
    // Get mapping details
    if (association.getLastMappingPerformedBy() != null) {
        snpAssociationTableView.setLastMappingPerformedBy(association.getLastMappingPerformedBy());
    }
    snpAssociationTableView.setMappingStatus("false");
    if (association.getLastMappingDate() != null) {
        snpAssociationTableView.setMappingStatus("true");
    }
    if (association.getLastMappingDate() != null) {
        DateFormat df = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");
        String dateOfLastMapping = df.format(association.getLastMappingDate());
        snpAssociationTableView.setLastMappingDate(dateOfLastMapping);
    }
    return snpAssociationTableView;
}
Also used : RiskAllele(uk.ac.ebi.spot.goci.model.RiskAllele) SnpAssociationTableView(uk.ac.ebi.spot.goci.curation.model.SnpAssociationTableView) Collection(java.util.Collection) Autowired(org.springframework.beans.factory.annotation.Autowired) SimpleDateFormat(java.text.SimpleDateFormat) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Locus(uk.ac.ebi.spot.goci.model.Locus) Gene(uk.ac.ebi.spot.goci.model.Gene) Service(org.springframework.stereotype.Service) EfoTrait(uk.ac.ebi.spot.goci.model.EfoTrait) Association(uk.ac.ebi.spot.goci.model.Association) SingleNucleotidePolymorphism(uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism) DateFormat(java.text.DateFormat) RiskAllele(uk.ac.ebi.spot.goci.model.RiskAllele) ArrayList(java.util.ArrayList) EfoTrait(uk.ac.ebi.spot.goci.model.EfoTrait) Gene(uk.ac.ebi.spot.goci.model.Gene) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SingleNucleotidePolymorphism(uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism) Locus(uk.ac.ebi.spot.goci.model.Locus) SimpleDateFormat(java.text.SimpleDateFormat) SnpAssociationTableView(uk.ac.ebi.spot.goci.curation.model.SnpAssociationTableView)

Example 10 with SingleNucleotidePolymorphism

use of uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism in project goci by EBISPOT.

the class SnpInteractionAssociationService method createForm.

// Create a form to return to view from Association model object
@Override
public SnpAssociationForm createForm(Association association) {
    // Create form
    SnpAssociationInteractionForm form = new SnpAssociationInteractionForm();
    // Set simple string and boolean values
    form.setAssociationId(association.getId());
    form.setPvalueDescription(association.getPvalueDescription());
    form.setSnpType(association.getSnpType());
    form.setSnpApproved(association.getSnpApproved());
    form.setPvalueMantissa(association.getPvalueMantissa());
    form.setPvalueExponent(association.getPvalueExponent());
    form.setStandardError(association.getStandardError());
    form.setRange(association.getRange());
    form.setDescription(association.getDescription());
    form.setRiskFrequency(association.getRiskFrequency());
    // Set OR/Beta values
    form.setOrPerCopyNum(association.getOrPerCopyNum());
    form.setOrPerCopyRecip(association.getOrPerCopyRecip());
    form.setOrPerCopyRecipRange(association.getOrPerCopyRecipRange());
    form.setBetaNum(association.getBetaNum());
    form.setBetaUnit(association.getBetaUnit());
    form.setBetaDirection(association.getBetaDirection());
    // Add collection of Efo traits
    form.setEfoTraits(association.getEfoTraits());
    // Create form columns
    List<SnpFormColumn> snpFormColumns = new ArrayList<>();
    // For each locus get genes and risk alleles
    Collection<Locus> loci = association.getLoci();
    Collection<GenomicContext> snpGenomicContexts = new ArrayList<GenomicContext>();
    Collection<SingleNucleotidePolymorphism> snps = new ArrayList<SingleNucleotidePolymorphism>();
    List<SnpMappingForm> snpMappingForms = new ArrayList<SnpMappingForm>();
    // Create a column per locus
    if (loci != null && !loci.isEmpty()) {
        for (Locus locus : loci) {
            SnpFormColumn snpFormColumn = new SnpFormColumn();
            // Set genes
            Collection<String> authorReportedGenes = new ArrayList<>();
            for (Gene gene : locus.getAuthorReportedGenes()) {
                authorReportedGenes.add(gene.getGeneName());
            }
            snpFormColumn.setAuthorReportedGenes(authorReportedGenes);
            // Set risk allele
            Collection<RiskAllele> locusRiskAlleles = locus.getStrongestRiskAlleles();
            String strongestRiskAllele = null;
            String snp = null;
            Collection<String> proxySnps = new ArrayList<>();
            Boolean genomeWide = false;
            Boolean limitedList = false;
            String riskFrequency = null;
            // For snp x snp interaction studies should only have one risk allele per locus
            if (locusRiskAlleles != null && locusRiskAlleles.size() == 1) {
                for (RiskAllele riskAllele : locusRiskAlleles) {
                    strongestRiskAllele = riskAllele.getRiskAlleleName();
                    snp = riskAllele.getSnp().getRsId();
                    SingleNucleotidePolymorphism snp_obj = riskAllele.getSnp();
                    snps.add(snp_obj);
                    Collection<Location> locations = snp_obj.getLocations();
                    for (Location location : locations) {
                        SnpMappingForm snpMappingForm = new SnpMappingForm(snp, location);
                        snpMappingForms.add(snpMappingForm);
                    }
                    snpGenomicContexts.addAll(genomicContextRepository.findBySnpId(snp_obj.getId()));
                    // Set proxy
                    if (riskAllele.getProxySnps() != null) {
                        for (SingleNucleotidePolymorphism riskAlleleProxySnp : riskAllele.getProxySnps()) {
                            proxySnps.add(riskAlleleProxySnp.getRsId());
                        }
                    }
                    if (riskAllele.getGenomeWide() != null && riskAllele.getGenomeWide()) {
                        genomeWide = true;
                    }
                    if (riskAllele.getLimitedList() != null && riskAllele.getLimitedList()) {
                        limitedList = true;
                    }
                    riskFrequency = riskAllele.getRiskFrequency();
                }
            } else {
                throw new RuntimeException("More than one risk allele found for locus " + locus.getId() + ", this is not supported yet for SNP interaction associations");
            }
            // Set column attributes
            snpFormColumn.setStrongestRiskAllele(strongestRiskAllele);
            snpFormColumn.setSnp(snp);
            snpFormColumn.setProxySnps(proxySnps);
            snpFormColumn.setGenomeWide(genomeWide);
            snpFormColumn.setLimitedList(limitedList);
            snpFormColumn.setRiskFrequency(riskFrequency);
            snpFormColumns.add(snpFormColumn);
        }
    }
    form.setSnpMappingForms(snpMappingForms);
    form.setGenomicContexts(snpGenomicContexts);
    form.setSnps(snps);
    form.setSnpFormColumns(snpFormColumns);
    form.setNumOfInteractions(snpFormColumns.size());
    return form;
}
Also used : SnpAssociationInteractionForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationInteractionForm) RiskAllele(uk.ac.ebi.spot.goci.model.RiskAllele) ArrayList(java.util.ArrayList) GenomicContext(uk.ac.ebi.spot.goci.model.GenomicContext) SnpMappingForm(uk.ac.ebi.spot.goci.curation.model.SnpMappingForm) Gene(uk.ac.ebi.spot.goci.model.Gene) SingleNucleotidePolymorphism(uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism) Locus(uk.ac.ebi.spot.goci.model.Locus) SnpFormColumn(uk.ac.ebi.spot.goci.curation.model.SnpFormColumn) Location(uk.ac.ebi.spot.goci.model.Location)

Aggregations

SingleNucleotidePolymorphism (uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism)24 ArrayList (java.util.ArrayList)15 RiskAllele (uk.ac.ebi.spot.goci.model.RiskAllele)12 Association (uk.ac.ebi.spot.goci.model.Association)9 Gene (uk.ac.ebi.spot.goci.model.Gene)9 Locus (uk.ac.ebi.spot.goci.model.Locus)8 Location (uk.ac.ebi.spot.goci.model.Location)6 GenomicContext (uk.ac.ebi.spot.goci.model.GenomicContext)5 Study (uk.ac.ebi.spot.goci.model.Study)4 Date (java.util.Date)3 EfoTrait (uk.ac.ebi.spot.goci.model.EfoTrait)3 Region (uk.ac.ebi.spot.goci.model.Region)3 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Collection (java.util.Collection)2 Collectors (java.util.stream.Collectors)2 Test (org.junit.Test)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Service (org.springframework.stereotype.Service)2 SnpMappingForm (uk.ac.ebi.spot.goci.curation.model.SnpMappingForm)2