Search in sources :

Example 6 with EfoTrait

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)));
        });
    });
}
Also used : EfoDocument(uk.ac.ebi.spot.goci.model.EfoDocument) StudyDocument(uk.ac.ebi.spot.goci.model.StudyDocument) EfoTrait(uk.ac.ebi.spot.goci.model.EfoTrait) HashSet(java.util.HashSet) AssociationDocument(uk.ac.ebi.spot.goci.model.AssociationDocument)

Example 7 with EfoTrait

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();
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) EfoTrait(uk.ac.ebi.spot.goci.model.EfoTrait)

Example 8 with EfoTrait

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);
    }
}
Also used : EfoTrait(uk.ac.ebi.spot.goci.model.EfoTrait)

Example 9 with 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;
}
Also used : Association(uk.ac.ebi.spot.goci.model.Association) ArrayList(java.util.ArrayList) EfoTrait(uk.ac.ebi.spot.goci.model.EfoTrait) StringJoiner(java.util.StringJoiner)

Aggregations

EfoTrait (uk.ac.ebi.spot.goci.model.EfoTrait)9 ArrayList (java.util.ArrayList)3 Association (uk.ac.ebi.spot.goci.model.Association)3 Locus (uk.ac.ebi.spot.goci.model.Locus)3 RiskAllele (uk.ac.ebi.spot.goci.model.RiskAllele)3 SingleNucleotidePolymorphism (uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism)2 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 StringJoiner (java.util.StringJoiner)1 Collectors (java.util.stream.Collectors)1 AddAxiom (org.semanticweb.owlapi.model.AddAxiom)1 IRI (org.semanticweb.owlapi.model.IRI)1 OWLAnnotationAssertionAxiom (org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom)1 OWLAnnotationProperty (org.semanticweb.owlapi.model.OWLAnnotationProperty)1 OWLClass (org.semanticweb.owlapi.model.OWLClass)1 OWLClassAssertionAxiom (org.semanticweb.owlapi.model.OWLClassAssertionAxiom)1 OWLDataProperty (org.semanticweb.owlapi.model.OWLDataProperty)1 OWLDataPropertyAssertionAxiom (org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom)1