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;
}
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;
}
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));
}
}
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);
}
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;
}
Aggregations