Search in sources :

Example 16 with RiskAllele

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

the class LociAttributesService method saveRiskAlleles.

public Collection<RiskAllele> saveRiskAlleles(Collection<RiskAllele> strongestRiskAlleles) {
    //Create new risk allele, at present we always create a new risk allele for each locus within an association
    Collection<RiskAllele> riskAlleles = new ArrayList<RiskAllele>();
    strongestRiskAlleles.forEach(riskAllele -> {
        getLog().info("Saving " + riskAllele.getRiskAlleleName());
        SingleNucleotidePolymorphism savedSnp = saveSnp(riskAllele.getSnp());
        riskAllele.setSnp(savedSnp);
        Collection<SingleNucleotidePolymorphism> savedProxySnps = new ArrayList<SingleNucleotidePolymorphism>();
        if (riskAllele.getProxySnps() != null && !riskAllele.getProxySnps().isEmpty()) {
            riskAllele.getProxySnps().forEach(singleNucleotidePolymorphism -> {
                savedProxySnps.add(saveSnp(singleNucleotidePolymorphism));
            });
        }
        riskAllele.setProxySnps(savedProxySnps);
        riskAlleleRepository.save(riskAllele);
        riskAlleles.add(riskAllele);
    });
    return riskAlleles;
}
Also used : RiskAllele(uk.ac.ebi.spot.goci.model.RiskAllele) ArrayList(java.util.ArrayList) SingleNucleotidePolymorphism(uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism)

Example 17 with RiskAllele

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

the class LociAttributesService method createRiskAllele.

public RiskAllele createRiskAllele(String curatorEnteredRiskAllele, SingleNucleotidePolymorphism snp) {
    //Create new risk allele, at present we always create a new risk allele for each locus within an association
    RiskAllele riskAllele = new RiskAllele();
    riskAllele.setRiskAlleleName(tidy_curator_entered_string(curatorEnteredRiskAllele));
    riskAllele.setSnp(snp);
    return riskAllele;
}
Also used : RiskAllele(uk.ac.ebi.spot.goci.model.RiskAllele)

Example 18 with RiskAllele

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

the class LociAttributesService method deleteLocusAndRiskAlleles.

public void deleteLocusAndRiskAlleles(Association association) {
    if (association.getLoci() != null) {
        Collection<RiskAllele> riskAlleles = new ArrayList<>();
        for (Locus locus : association.getLoci()) {
            locus.getStrongestRiskAlleles().forEach(riskAlleles::add);
            deleteLocus(locus);
        }
        riskAlleles.forEach(riskAllele -> riskAlleleRepository.delete(riskAllele));
    }
}
Also used : RiskAllele(uk.ac.ebi.spot.goci.model.RiskAllele) ArrayList(java.util.ArrayList) Locus(uk.ac.ebi.spot.goci.model.Locus)

Example 19 with RiskAllele

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

the class AssociationDeletionService method deleteAssociation.

public void deleteAssociation(Association association, SecureUser user) {
    getLog().info("Deleting association ".concat(String.valueOf(association.getId())));
    // For each association get the loci
    Collection<Locus> loci = new ArrayList<Locus>();
    loci.addAll(association.getLoci());
    // SNPs are not deleted as they may be used in other associations.
    for (Locus locus : loci) {
        Collection<RiskAllele> locusRiskAlleles = locus.getStrongestRiskAlleles();
        locus.setStrongestRiskAlleles(new ArrayList<>());
        for (RiskAllele riskAllele : locusRiskAlleles) {
            lociAttributesService.deleteRiskAllele(riskAllele);
        }
        lociAttributesService.deleteLocus(locus);
    }
    // Add deletion event
    trackingOperationService.delete(association, user);
    DeletedAssociation deletedAssociation = createDeletedAssociation(association);
    // Delete associations
    associationRepository.delete(association);
    // Save deleted association
    getLog().info("Saving details of deleted association: ".concat(String.valueOf(deletedAssociation.getId())));
    deletedAssociationRepository.save(deletedAssociation);
}
Also used : RiskAllele(uk.ac.ebi.spot.goci.model.RiskAllele) ArrayList(java.util.ArrayList) Locus(uk.ac.ebi.spot.goci.model.Locus) DeletedAssociation(uk.ac.ebi.spot.goci.model.DeletedAssociation)

Example 20 with RiskAllele

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

the class SingleSnpMultiSnpAssociationService method createAssociation.

public Association createAssociation(SnpAssociationStandardMultiForm form) {
    // Set common string, boolean and float association attributes
    Association association = setCommonAssociationElements(form);
    association.setSnpInteraction(false);
    // Add loci to association, for multi-snp and standard snps we assume their is only one locus
    Collection<Locus> loci = new ArrayList<>();
    Locus locus = new Locus();
    // Set locus description and haplotype count
    // Set this number to the number of rows entered by curator
    Integer numberOfRows = form.getSnpFormRows().size();
    if (numberOfRows > 1) {
        locus.setHaplotypeSnpCount(numberOfRows);
        association.setMultiSnpHaplotype(true);
    }
    if (form.getMultiSnpHaplotypeDescr() != null && !form.getMultiSnpHaplotypeDescr().isEmpty()) {
        locus.setDescription(form.getMultiSnpHaplotypeDescr());
    } else {
        if (numberOfRows > 1) {
            locus.setDescription(numberOfRows + "-SNP haplotype");
        } else {
            locus.setDescription("Single variant");
        }
    }
    // Create gene from each string entered, may sure to check pre-existence
    Collection<String> authorReportedGenes = form.getAuthorReportedGenes();
    Collection<Gene> locusGenes = lociAttributesService.createGene(authorReportedGenes);
    // Set locus genes
    locus.setAuthorReportedGenes(locusGenes);
    // Handle rows entered for haplotype by curator
    Collection<SnpFormRow> rows = form.getSnpFormRows();
    Collection<RiskAllele> locusRiskAlleles = new ArrayList<>();
    for (SnpFormRow row : rows) {
        // Create snps from row information
        String curatorEnteredSNP = row.getSnp();
        SingleNucleotidePolymorphism snp = lociAttributesService.createSnp(curatorEnteredSNP);
        // Get the curator entered risk allele
        String curatorEnteredRiskAllele = row.getStrongestRiskAllele();
        // Create a new risk allele and assign newly created snp
        RiskAllele riskAllele = lociAttributesService.createRiskAllele(curatorEnteredRiskAllele, snp);
        // If association is not a multi-snp haplotype save frequency to risk allele
        if (!form.getMultiSnpHaplotype()) {
            riskAllele.setRiskFrequency(form.getRiskFrequency());
        }
        // Check for proxies and if we have one create a proxy snps
        if (row.getProxySnps() != null && !row.getProxySnps().isEmpty()) {
            Collection<SingleNucleotidePolymorphism> riskAlleleProxySnps = new ArrayList<>();
            for (String curatorEnteredProxySnp : row.getProxySnps()) {
                SingleNucleotidePolymorphism proxySnp = lociAttributesService.createSnp(curatorEnteredProxySnp);
                riskAlleleProxySnps.add(proxySnp);
            }
            riskAllele.setProxySnps(riskAlleleProxySnps);
        }
        locusRiskAlleles.add(riskAllele);
    }
    // Assign all created risk alleles to locus
    locus.setStrongestRiskAlleles(locusRiskAlleles);
    // Add locus to collection and link to our association
    loci.add(locus);
    association.setLoci(loci);
    return association;
}
Also used : RiskAllele(uk.ac.ebi.spot.goci.model.RiskAllele) ArrayList(java.util.ArrayList) Association(uk.ac.ebi.spot.goci.model.Association) 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)

Aggregations

RiskAllele (uk.ac.ebi.spot.goci.model.RiskAllele)22 ArrayList (java.util.ArrayList)16 Locus (uk.ac.ebi.spot.goci.model.Locus)12 SingleNucleotidePolymorphism (uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism)12 Gene (uk.ac.ebi.spot.goci.model.Gene)11 Association (uk.ac.ebi.spot.goci.model.Association)9 Test (org.junit.Test)4 EfoTrait (uk.ac.ebi.spot.goci.model.EfoTrait)4 Location (uk.ac.ebi.spot.goci.model.Location)3 Study (uk.ac.ebi.spot.goci.model.Study)3 Collection (java.util.Collection)2 HashSet (java.util.HashSet)2 Collectors (java.util.stream.Collectors)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Service (org.springframework.stereotype.Service)2 SnpFormColumn (uk.ac.ebi.spot.goci.curation.model.SnpFormColumn)2 SnpFormRow (uk.ac.ebi.spot.goci.curation.model.SnpFormRow)2 SnpMappingForm (uk.ac.ebi.spot.goci.curation.model.SnpMappingForm)2 GenomicContext (uk.ac.ebi.spot.goci.model.GenomicContext)2 IOException (java.io.IOException)1