use of uk.ac.ebi.spot.goci.model.Association in project goci by EBISPOT.
the class PussycatGOCIController method renderTrait.
@RequestMapping(value = "/traits/{efoURI}")
@ResponseBody
public String renderTrait(@PathVariable String efoURI, HttpSession session) throws PussycatSessionNotReadyException, NoRenderableDataException {
Association ta = template(Association.class);
Filter filter = refine(ta).on(ta.getEfoTraits()).hasValue(URI.create(efoURI));
return getPussycatSession(session).performRendering(getRenderletNexus(session), filter);
}
use of uk.ac.ebi.spot.goci.model.Association in project goci by EBISPOT.
the class TestFiltering method testFilter.
@Test
public void testFilter() {
SingleNucleotidePolymorphism template = template(SingleNucleotidePolymorphism.class);
Filter<SingleNucleotidePolymorphism, String> filter = refine(template).on(template.getRsId()).hasValue("rs123456");
assertEquals("Filter type does not match expected", SingleNucleotidePolymorphism.class, filter.getFilteredType());
assertEquals("Filtered method does not match expected", "getRsId", filter.getFilteredMethod().getName());
assertEquals("Filtered value does not match expected", "rs123456", filter.getFilteredValues().get(0));
Association template2 = template(Association.class);
Filter<Association, Float> filter2 = refine(template2).on(template2.getPvalueMantissa()).hasValue(Float.valueOf("10"));
assertEquals("Filter type does not match expected", Association.class, filter2.getFilteredType());
assertEquals("Filtered method does not match expected", "getPvalueMantissa", filter2.getFilteredMethod().getName());
assertEquals(Float.valueOf("10"), filter2.getFilteredValues().get(0), 0.0d);
DateFormat df1 = new SimpleDateFormat("yyyy-MM-dd");
DateFormat df2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S");
Date from = null;
Date to = null;
try {
from = df1.parse("2005-01-01");
to = df1.parse("2010-01-01");
} catch (ParseException e) {
e.printStackTrace();
}
String fromValue = df2.format(from).toString();
String toValue = df2.format(to).toString();
System.out.println(fromValue);
System.out.println(toValue);
Study study = template(Study.class);
Filter dateFilter = refine(study).on(study.getPublicationDate()).hasRange(fromValue, toValue);
Filter dateFilter2 = refine(study).on(study.getPublicationDate()).hasRange(fromValue, toValue);
assertEquals("Filter type does not match expected", Study.class, dateFilter.getFilteredType());
assertEquals("Filtered method does not match expected", "getPublicationDate", dateFilter.getFilteredMethod().getName());
assertEquals("Filtered value does not match expected", "2010-01-01T00:00:00.0", dateFilter.getFilteredRange().to());
assertEquals("Hashcodes of the two date filters differ", dateFilter.hashCode(), dateFilter2.hashCode());
}
use of uk.ac.ebi.spot.goci.model.Association in project goci by EBISPOT.
the class MappingDetailsService method createMappingSummary.
/**
* An additional date should be added to the "Curator information" tab called "Last automated mapping date". This
* should record the last date all SNPs were mapped using the automated mapping pipeline i.e. when there has been an
* Ensembl release. This should be left blank for studies where SNPs have different mapping dates or were mapped by
* a curator, indicating that the curator should check the "SNP associations page" for last mapping info.
*
* @param study Study with mapping details
*/
public MappingDetails createMappingSummary(Study study) {
MappingDetails mappingSummary = new MappingDetails();
Collection<Association> studyAssociations = associationRepository.findByStudyId(study.getId());
if (studyAssociations != null && !studyAssociations.isEmpty()) {
// Determine if we have more than one performer
Set<String> allAssociationMappingPerformers = new HashSet<String>();
for (Association association : studyAssociations) {
allAssociationMappingPerformers.add(association.getLastMappingPerformedBy());
}
Map<String, String> mappingDateToPerformerMap = new HashMap<>();
SimpleDateFormat dt = new SimpleDateFormat("yyyy-MM-dd");
// If only one performer we need to check dates to see mapping didn't happen at different times
if (allAssociationMappingPerformers.size() == 1) {
String performer = allAssociationMappingPerformers.iterator().next();
// Only care about automated mapping
if (performer != null) {
if (performer.equals("automatic_mapping_process")) {
// Go through all associations and store mapping performer and date
for (Association association : studyAssociations) {
String date = dt.format(association.getLastMappingDate());
mappingDateToPerformerMap.put(date, performer);
}
}
}
}
// If its only been mapped by an automated process, all with same date
if (mappingDateToPerformerMap.size() == 1) {
for (String date : mappingDateToPerformerMap.keySet()) {
Date newDate = null;
try {
newDate = dt.parse(date);
} catch (ParseException e) {
e.printStackTrace();
}
mappingSummary.setMappingDate(newDate);
mappingSummary.setPerformer(mappingDateToPerformerMap.get(date));
}
}
}
return mappingSummary;
}
use of uk.ac.ebi.spot.goci.model.Association 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;
}
use of uk.ac.ebi.spot.goci.model.Association in project goci by EBISPOT.
the class SnpAssociationFormService method setCommonAssociationElements.
/**
* Set common association attributes
*
* @return Form, contains details of association to create
*/
default default Association setCommonAssociationElements(SnpAssociationForm form) {
Association association = new Association();
// Set common string, boolean and float association attributes
association.setSnpType(form.getSnpType());
association.setSnpApproved(form.getSnpApproved());
association.setStandardError(form.getStandardError());
// Add collection of EFO traits
association.setEfoTraits(form.getEfoTraits());
// Set mantissa and exponent
association.setPvalueMantissa(form.getPvalueMantissa());
association.setPvalueExponent(form.getPvalueExponent());
// Set OR/Beta values
association.setOrPerCopyNum(form.getOrPerCopyNum());
association.setOrPerCopyRecip(form.getOrPerCopyRecip());
association.setBetaNum(form.getBetaNum());
association.setBetaDirection(form.getBetaDirection());
// Tidy up common string values
if (form.getPvalueDescription() != null) {
association.setPvalueDescription(form.getPvalueDescription().trim());
}
if (form.getRange() != null) {
association.setRange(form.getRange().trim());
}
if (form.getDescription() != null) {
association.setDescription(form.getDescription().trim());
}
if (form.getRiskFrequency() != null) {
association.setRiskFrequency(form.getRiskFrequency().trim());
}
if (form.getOrPerCopyRecipRange() != null) {
association.setOrPerCopyRecipRange(form.getOrPerCopyRecipRange().trim());
}
if (form.getBetaUnit() != null) {
association.setBetaUnit(form.getBetaUnit().trim());
}
return association;
}
Aggregations