use of uk.ac.ebi.spot.goci.curation.model.SnpMappingForm 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.setAssociationExtension(association.getAssociationExtension());
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;
}
use of uk.ac.ebi.spot.goci.curation.model.SnpMappingForm 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());
form.setAssociationExtension(association.getAssociationExtension());
// 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;
}
Aggregations