use of uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism in project goci by EBISPOT.
the class AssociationRowProcessor method createLocusRiskAlleles.
private Collection<RiskAllele> createLocusRiskAlleles(String strongestAllele, String snp, String proxy, String riskFrequency, String snpStatus, String delimiter) {
Collection<RiskAllele> locusRiskAlleles = new ArrayList<>();
// For our list of snps, proxies and risk alleles separate by delimiter
List<String> snps = new ArrayList<>();
String[] separatedSnps = snp.split(delimiter);
for (String separatedSnp : separatedSnps) {
// if(separatedSnp != null & separatedSnp.trim().equals("")) {
snps.add(separatedSnp.trim());
// }
}
List<String> riskAlleles = new ArrayList<>();
String[] separatedRiskAlleles = strongestAllele.split(delimiter);
for (String separatedRiskAllele : separatedRiskAlleles) {
// if(separatedRiskAllele != null & separatedRiskAllele.trim().equals("")) {
riskAlleles.add(separatedRiskAllele.trim());
// }
}
List<String> proxies = new ArrayList<>();
if (proxy != null) {
String[] separatedProxies = proxy.split(delimiter);
for (String separatedProxy : separatedProxies) {
// if(separatedProxy != null & separatedProxy.trim().equals("")) {
proxies.add(separatedProxy.trim());
// }
}
}
// Value is only recorded for SNP interaction associations
List<String> riskFrequencies = new ArrayList<>();
Iterator<String> riskFrequencyIterator = null;
if (riskFrequency != null) {
String[] separatedRiskFrequencies = riskFrequency.split(delimiter);
for (String separatedRiskFrequency : separatedRiskFrequencies) {
riskFrequencies.add(separatedRiskFrequency.trim());
}
riskFrequencyIterator = riskFrequencies.iterator();
}
// Snp status
List<String> snpStatuses = new ArrayList<>();
Iterator<String> snpStatusIterator = null;
if (snpStatus != null) {
String[] separatedSnpStatuses = snpStatus.split(delimiter);
for (String separatedSnpStatus : separatedSnpStatuses) {
snpStatuses.add(separatedSnpStatus.trim());
}
snpStatusIterator = snpStatuses.iterator();
}
Iterator<String> riskAlleleIterator = riskAlleles.iterator();
Iterator<String> snpIterator = snps.iterator();
Iterator<String> proxyIterator = proxies.iterator();
// Loop through our risk alleles
if (riskAlleles.size() == snps.size()) {
while (riskAlleleIterator.hasNext()) {
String snpValue = snpIterator.next().trim();
String riskAlleleValue = riskAlleleIterator.next().trim();
SingleNucleotidePolymorphism newSnp = associationAttributeService.createSnp(snpValue);
// Create a new risk allele and assign newly created snp
RiskAllele newRiskAllele = associationAttributeService.createRiskAllele(riskAlleleValue, newSnp);
// Check for proxies and if we have one create a proxy snp
if (proxies.size() != 0) {
if (proxies.size() == snps.size()) {
String proxyValue = proxyIterator.next().trim();
Collection<SingleNucleotidePolymorphism> newRiskAlleleProxies = new ArrayList<>();
// else
if (proxyValue.contains(",")) {
String[] splitProxyValues = proxyValue.split(",");
for (String splitProxyValue : splitProxyValues) {
SingleNucleotidePolymorphism proxySnp = associationAttributeService.createSnp(splitProxyValue.trim());
newRiskAlleleProxies.add(proxySnp);
}
} else {
SingleNucleotidePolymorphism proxySnp = associationAttributeService.createSnp(proxyValue);
newRiskAlleleProxies.add(proxySnp);
}
newRiskAllele.setProxySnps(newRiskAlleleProxies);
} else {
getLog().error("Proxy SNP number and SNP number do not match");
}
}
// If there is no curator entered value for risk allele frequency don't save
String riskFrequencyValue = null;
if (riskFrequencyIterator != null) {
riskFrequencyValue = riskFrequencyIterator.next().trim();
}
if (riskFrequencyValue != null) {
newRiskAllele.setRiskFrequency(riskFrequencyValue);
}
// Handle snp statuses, these should only apply to SNP interaction associations
String snpStatusValue = null;
if (snpStatusIterator != null) {
snpStatusValue = snpStatusIterator.next().trim();
}
if (snpStatus != null && !snpStatus.equalsIgnoreCase("NR")) {
if (snpStatusValue.contains("GW") || snpStatusValue.contains("gw")) {
newRiskAllele.setGenomeWide(true);
}
if (snpStatusValue.contains("LL") || snpStatusValue.contains("ll")) {
newRiskAllele.setLimitedList(true);
}
}
locusRiskAlleles.add(newRiskAllele);
}
} else {
getLog().error("Mismatched number of snps and risk alleles");
}
return locusRiskAlleles;
}
use of uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism in project goci by EBISPOT.
the class PussycatGOCIController method renderSNP.
@RequestMapping(value = "/snps/{rsID}")
@ResponseBody
public String renderSNP(@PathVariable String rsID, HttpSession session) throws PussycatSessionNotReadyException, NoRenderableDataException {
SingleNucleotidePolymorphism snp = template(SingleNucleotidePolymorphism.class);
Filter filter = refine(snp).on(snp.getRsId()).hasValue(rsID);
return getPussycatSession(session).performRendering(getRenderletNexus(session), filter);
}
use of uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism in project goci by EBISPOT.
the class SnpGetter method getSnpRsIdList.
public Collection<String> getSnpRsIdList() {
Collection<String> rsIds = new ArrayList<>();
SingleNucleotidePolymorphismService snpService = getSingleNucleotidePolymorphismService();
List<SingleNucleotidePolymorphism> snps = snpService.findAll();
for (SingleNucleotidePolymorphism snp : snps) {
rsIds.add(snp.getRsId());
}
return rsIds;
}
use of uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism 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.SingleNucleotidePolymorphism 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;
}
Aggregations