Search in sources :

Example 16 with Study

use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.

the class StudyPrintService method generatePrintView.

public Collection<SnpAssociationTableView> generatePrintView(Long studyId) {
    // Get relevant study details
    Study studyToView = studyRepository.findOne(studyId);
    // Association information
    Collection<Association> associations = new ArrayList<>();
    associations.addAll(associationRepository.findByStudyId(studyId));
    // For our associations create a table view object and return
    Collection<SnpAssociationTableView> snpAssociationTableViews = new ArrayList<SnpAssociationTableView>();
    for (Association association : associations) {
        SnpAssociationTableView snpAssociationTableView = snpAssociationTableViewService.createSnpAssociationTableView(association);
        snpAssociationTableViews.add(snpAssociationTableView);
    }
    return snpAssociationTableViews;
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) Association(uk.ac.ebi.spot.goci.model.Association) ArrayList(java.util.ArrayList) SnpAssociationTableView(uk.ac.ebi.spot.goci.curation.model.SnpAssociationTableView)

Example 17 with Study

use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.

the class StudySampleDescriptionService method addStudyInitialReplcationSampleDescription.

public void addStudyInitialReplcationSampleDescription(Long studyId, InitialSampleDescription initialSampleDescription, ReplicationSampleDescription replicationSampleDescription, SecureUser user) {
    // Find existing study to add details to
    Study study = studyRepository.findOne(studyId);
    // Check changes and record update details
    String updateDescription = generateUpdateDescription(initialSampleDescription.getInitialSampleDescription(), replicationSampleDescription.getReplicationSampleDescription(), study);
    // Set our descriptions which are attributes of the study
    study.setInitialSampleSize(initialSampleDescription.getInitialSampleDescription());
    study.setReplicateSampleSize(replicationSampleDescription.getReplicationSampleDescription());
    // Save study
    trackingOperationService.update(study, user, "STUDY_SAMPLE_DESCRIPTION_UPDATE", updateDescription);
    studyRepository.save(study);
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study)

Example 18 with Study

use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.

the class StudyUpdateService method generateUpdateDescription.

/**
     * Generate a description of update made
     *
     * @param existingStudy Study based on whats stored in database
     * @param study         Updated study
     */
private String generateUpdateDescription(Study existingStudy, Study study) {
    String updateDescription = null;
    List<String> updateDetails = new ArrayList<>();
    // Check disease trait for changes
    String existingDiseaseTraitName = null;
    if (existingStudy.getDiseaseTrait() != null && existingStudy.getDiseaseTrait().getTrait() != null) {
        existingDiseaseTraitName = existingStudy.getDiseaseTrait().getTrait();
    }
    String updatedDiseaseTraitName = null;
    if (study.getDiseaseTrait() != null && study.getDiseaseTrait().getTrait() != null) {
        updatedDiseaseTraitName = study.getDiseaseTrait().getTrait();
    }
    String diseaseTraitUpdateDescription = checkForDiseaseTraitUpdate(existingDiseaseTraitName, updatedDiseaseTraitName);
    if (diseaseTraitUpdateDescription != null) {
        updateDetails.add(diseaseTraitUpdateDescription);
    }
    // Check EFO trait for changes
    List<String> existingStudyEfoTraits = new ArrayList<>();
    List<String> updatedStudyEfoTraits = new ArrayList<>();
    existingStudyEfoTraits = existingStudy.getEfoTraits().stream().filter(efoTrait -> efoTrait.getTrait() != null).filter(efoTrait -> !efoTrait.getTrait().isEmpty()).map(efoTrait -> efoTrait.getTrait()).collect(Collectors.toList());
    if (study.getEfoTraits() != null) {
        updatedStudyEfoTraits = study.getEfoTraits().stream().filter(efoTrait -> !efoTrait.getTrait().isEmpty()).map(efoTrait -> efoTrait.getTrait()).collect(Collectors.toList());
    }
    String efoTraitUpdateDescription = checkForEfoTraitUpdate(existingStudyEfoTraits, updatedStudyEfoTraits);
    if (efoTraitUpdateDescription != null) {
        updateDetails.add(efoTraitUpdateDescription);
    }
    StringJoiner updateDetailsJoiner = new StringJoiner(", ");
    if (!updateDetails.isEmpty()) {
        updateDetails.forEach(s -> updateDetailsJoiner.add(s));
        updateDescription = updateDetailsJoiner.toString();
    }
    return updateDescription;
}
Also used : Logger(org.slf4j.Logger) EventType(uk.ac.ebi.spot.goci.model.EventType) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Housekeeping(uk.ac.ebi.spot.goci.model.Housekeeping) Collectors(java.util.stream.Collectors) TrackingOperationService(uk.ac.ebi.spot.goci.service.TrackingOperationService) ArrayList(java.util.ArrayList) List(java.util.List) Service(org.springframework.stereotype.Service) StringJoiner(java.util.StringJoiner) Qualifier(org.springframework.beans.factory.annotation.Qualifier) Study(uk.ac.ebi.spot.goci.model.Study) StudyRepository(uk.ac.ebi.spot.goci.repository.StudyRepository) SecureUser(uk.ac.ebi.spot.goci.model.SecureUser) ArrayList(java.util.ArrayList) StringJoiner(java.util.StringJoiner)

Example 19 with Study

use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.

the class StudyAssociationBatchDeletionEventService method createBatchUploadEvent.

/**
     * Upload a file to the study specific dir
     *
     * @param studyId          Study to assign event to
     * @param associationCount Number of associations deleted
     * @param user             User that triggered event
     */
public void createBatchUploadEvent(Long studyId, Integer associationCount, SecureUser user) {
    Study study = studyRepository.findOne(studyId);
    String description = associationCount.toString().concat(" associations deleted");
    createEvent(study, user, description);
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study)

Example 20 with Study

use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.

the class AncestryController method viewStudySampleDescription.

/* Ancestry/Sample information associated with a study */
// Generate view of ancestry/sample information linked to a study
@RequestMapping(value = "/studies/{studyId}/sampledescription", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String viewStudySampleDescription(Model model, @PathVariable Long studyId) {
    // Two types of ancestry information which the view needs to form two different tables
    Collection<Ancestry> initialStudyAncestryDescriptions = new ArrayList<>();
    Collection<Ancestry> replicationStudyAncestryDescriptions = new ArrayList<>();
    String initialType = "initial";
    String replicationType = "replication";
    initialStudyAncestryDescriptions.addAll(ancestryRepository.findByStudyIdAndType(studyId, initialType));
    replicationStudyAncestryDescriptions.addAll(ancestryRepository.findByStudyIdAndType(studyId, replicationType));
    Collection<Ancestry> allAncestry = new ArrayList<>();
    allAncestry.addAll(initialStudyAncestryDescriptions);
    allAncestry.addAll(replicationStudyAncestryDescriptions);
    for (Ancestry ancestry : allAncestry) {
        if (ancestry.getCountryOfRecruitment() == null || ancestry.getCountryOfRecruitment().isEmpty()) {
            String message = "No country of recruitment recorded for at least one ancestry entry!";
            model.addAttribute("noCountryRecruitment", message);
            break;
        }
    }
    // Add all ancestry/sample information for the study to our model
    model.addAttribute("initialStudyAncestryDescriptions", initialStudyAncestryDescriptions);
    model.addAttribute("replicationStudyAncestryDescriptions", replicationStudyAncestryDescriptions);
    // Return an empty ancestry object so curators can add new ancestry/sample information to study
    model.addAttribute("ancestry", new Ancestry());
    // Return an SampleDescription object for each type
    Study study = studyRepository.findOne(studyId);
    if (study.getInitialSampleSize() != null && !study.getInitialSampleSize().isEmpty()) {
        InitialSampleDescription initialSampleDescription = new InitialSampleDescription();
        initialSampleDescription.setInitialSampleDescription(study.getInitialSampleSize());
        model.addAttribute("initialSampleDescription", initialSampleDescription);
    } else {
        model.addAttribute("initialSampleDescription", new InitialSampleDescription());
    }
    if (study.getReplicateSampleSize() != null && !study.getReplicateSampleSize().isEmpty()) {
        ReplicationSampleDescription replicationSampleDescription = new ReplicationSampleDescription();
        replicationSampleDescription.setReplicationSampleDescription(study.getReplicateSampleSize());
        model.addAttribute("replicationSampleDescription", replicationSampleDescription);
    } else {
        model.addAttribute("replicationSampleDescription", new ReplicationSampleDescription());
    }
    // Also passes back study object to view so we can create links back to main study page
    model.addAttribute("study", study);
    return "study_sample_description";
}
Also used : InitialSampleDescription(uk.ac.ebi.spot.goci.curation.model.InitialSampleDescription) Study(uk.ac.ebi.spot.goci.model.Study) ArrayList(java.util.ArrayList) Ancestry(uk.ac.ebi.spot.goci.model.Ancestry) ReplicationSampleDescription(uk.ac.ebi.spot.goci.curation.model.ReplicationSampleDescription) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Study (uk.ac.ebi.spot.goci.model.Study)44 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)20 ArrayList (java.util.ArrayList)7 Association (uk.ac.ebi.spot.goci.model.Association)7 Housekeeping (uk.ac.ebi.spot.goci.model.Housekeeping)6 MultiStudyNoteForm (uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm)5 Date (java.util.Date)4 Test (org.junit.Test)4 Ancestry (uk.ac.ebi.spot.goci.model.Ancestry)4 NoteSubject (uk.ac.ebi.spot.goci.model.NoteSubject)4 SecureUser (uk.ac.ebi.spot.goci.model.SecureUser)4 SingleNucleotidePolymorphism (uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism)4 ParseException (java.text.ParseException)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Service (org.springframework.stereotype.Service)3 StudyNoteForm (uk.ac.ebi.spot.goci.curation.model.StudyNoteForm)3 RiskAllele (uk.ac.ebi.spot.goci.model.RiskAllele)3 StudyNote (uk.ac.ebi.spot.goci.model.StudyNote)3 IOException (java.io.IOException)2