use of uk.ac.ebi.spot.goci.model.EfoTrait in project goci by EBISPOT.
the class TraitEnrichmentService method doEnrichment.
@Override
public void doEnrichment(DiseaseTraitDocument document) {
long id = Long.valueOf(document.getId().split(":")[1]);
studyService.findByDiseaseTraitId(id).forEach(study -> {
document.embed(new StudyDocument(study));
Set<EfoTrait> efoTraits = new HashSet<>();
traitService.findMappedTraitByStudyId(study.getId()).forEach(efoTraits::add);
efoTraits.forEach(trait -> {
document.embed(new EfoDocument(trait));
associationService.findPublishedAssociationsByEfoTraitId(trait.getId()).forEach(association -> document.embed(new AssociationDocument(association)));
});
});
}
use of uk.ac.ebi.spot.goci.model.EfoTrait in project goci by EBISPOT.
the class SolrIndexer method mapEfo.
Integer mapEfo() {
Sort sort = new Sort(new Sort.Order("id"));
Pageable pager = new PageRequest(0, pageSize, sort);
Page<EfoTrait> efoTraitPage = efoTraitRepository.findAll(pager);
efoMapper.map(efoTraitPage.getContent());
while (efoTraitPage.hasNext()) {
if (maxPages != -1 && efoTraitPage.getNumber() >= maxPages - 1) {
break;
}
pager = pager.next();
efoTraitPage = efoTraitRepository.findAll(pager);
efoMapper.map(efoTraitPage.getContent());
if (sysOutLogging) {
System.out.print(".");
}
}
return (int) efoTraitPage.getTotalElements();
}
use of uk.ac.ebi.spot.goci.model.EfoTrait in project goci by EBISPOT.
the class CheckingService method checkURIs.
public void checkURIs() {
System.out.println("Loading data from GWAS database");
List<EfoTrait> allEfoTraits = traitService.findAllEfoTraits();
System.out.println("Data loading complete");
for (EfoTrait efoTrait : allEfoTraits) {
validateEfoTrait(efoTrait);
}
}
use of uk.ac.ebi.spot.goci.model.EfoTrait in project goci by EBISPOT.
the class AssociationRowProcessor method createAssociationFromUploadRow.
public Association createAssociationFromUploadRow(AssociationUploadRow row) {
Association newAssociation = new Association();
// Set EFO traits
if (row.getEfoTrait() != null) {
String[] uris = row.getEfoTrait().split(",");
Collection<String> efoUris = new ArrayList<>();
for (String uri : uris) {
String trimmedUri = uri.trim();
efoUris.add(trimmedUri);
}
Collection<EfoTrait> efoTraits = associationAttributeService.getEfoTraitsFromRepository(efoUris);
newAssociation.setEfoTraits(efoTraits);
}
/// Set OR
newAssociation.setOrPerCopyRecip(row.getOrPerCopyRecip());
newAssociation.setOrPerCopyRecipRange(row.getOrPerCopyRecipRange());
// Set beta
newAssociation.setBetaNum(row.getBetaNum());
newAssociation.setBetaUnit(row.getBetaUnit());
newAssociation.setBetaDirection(row.getBetaDirection());
// Calculate OR num if OR recip is present , otherwise set to whatever is in upload
boolean recipReverse = false;
if ((row.getOrPerCopyRecip() != null) && (row.getOrPerCopyNum() == null)) {
getLog().info("Calculating OR from OR recip value");
newAssociation.setOrPerCopyNum(((100 / row.getOrPerCopyRecip()) / 100));
recipReverse = true;
} else {
newAssociation.setOrPerCopyNum(row.getOrPerCopyNum());
}
// Calculate range , this logic is retained from Dani's original code
if ((row.getOrPerCopyRecipRange() != null) && recipReverse) {
newAssociation.setRange(associationCalculationService.reverseCI(row.getOrPerCopyRecipRange()));
} else if ((row.getRange() == null) && (row.getStandardError() != null)) {
if (row.getOrPerCopyNum() != null) {
newAssociation.setRange(associationCalculationService.setRange(row.getStandardError(), row.getOrPerCopyNum()));
} else {
if (row.getBetaNum() != null) {
newAssociation.setRange(associationCalculationService.setRange(row.getStandardError(), row.getBetaNum()));
}
}
} else {
newAssociation.setRange(row.getRange());
}
// Add brackets to the p-value description
if (row.getPvalueDescription() != null && !row.getPvalueDescription().isEmpty()) {
if (!row.getPvalueDescription().startsWith("(") && !row.getPvalueDescription().endsWith(")")) {
StringJoiner newPvalueDescription = new StringJoiner("", "(", ")");
newPvalueDescription.add(row.getPvalueDescription());
newAssociation.setPvalueDescription(newPvalueDescription.toString());
} else {
newAssociation.setPvalueDescription(row.getPvalueDescription());
}
} else {
newAssociation.setPvalueDescription(row.getPvalueDescription());
}
// Set values common to all association types
newAssociation.setRiskFrequency(row.getAssociationRiskFrequency());
newAssociation.setPvalueMantissa(row.getPvalueMantissa());
newAssociation.setPvalueExponent(row.getPvalueExponent());
newAssociation.setSnpType(row.getSnpType());
newAssociation.setStandardError(row.getStandardError());
newAssociation.setDescription(row.getDescription());
if (row.getMultiSnpHaplotype() != null) {
if (row.getMultiSnpHaplotype().equalsIgnoreCase("Y")) {
newAssociation.setMultiSnpHaplotype(true);
}
} else {
newAssociation.setMultiSnpHaplotype(false);
}
if (row.getSnpInteraction() != null) {
if (row.getSnpInteraction().equalsIgnoreCase("Y")) {
newAssociation.setSnpInteraction(true);
}
} else {
newAssociation.setSnpInteraction(false);
}
// If there is a risk allele proceed to create loci
if (row.getStrongestAllele() != null) {
newAssociation.setLoci(createLoci(row, newAssociation.getSnpInteraction(), newAssociation.getMultiSnpHaplotype()));
}
return newAssociation;
}
Aggregations