Search in sources :

Example 6 with Ancestry

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

the class StudyAncestryService method deleteAll.

public void deleteAll(Long studyId, SecureUser user) {
    // Get all study ancestry's
    Study study = studyRepository.findOne(studyId);
    Collection<Ancestry> studyAncestry = ancestryRepository.findByStudyId(studyId);
    // Delete ancestry
    studyAncestry.forEach(ancestry -> deleteAncestry(ancestry, user));
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) DeletedAncestry(uk.ac.ebi.spot.goci.model.DeletedAncestry) Ancestry(uk.ac.ebi.spot.goci.model.Ancestry)

Example 7 with Ancestry

use of uk.ac.ebi.spot.goci.model.Ancestry 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) Ancestry(uk.ac.ebi.spot.goci.model.Ancestry) ReplicationSampleDescription(uk.ac.ebi.spot.goci.curation.model.ReplicationSampleDescription) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with Ancestry

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

the class AncestryController method viewSampleDescription.

/* Existing ancestry/sample information */
// View ancestry/sample information
@RequestMapping(value = "/sampledescriptions/{ancestryId}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String viewSampleDescription(Model model, @PathVariable Long ancestryId) {
    Ancestry ancestryToView = ancestryRepository.findOne(ancestryId);
    // 
    // if(ancestryToView.getCountryOfRecruitment() == null || ancestryToView.getCountryOfRecruitment().isEmpty()){
    // String message = "No country of recruitment recorded for at least one ancestry entry!";
    // model.addAttribute("noCountryRecruitment",message);
    // }
    // 
    model.addAttribute("ancestry", ancestryToView);
    model.addAttribute("study", studyRepository.findOne(ancestryToView.getStudy().getId()));
    return "edit_sample_description";
}
Also used : Ancestry(uk.ac.ebi.spot.goci.model.Ancestry) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with Ancestry

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

the class AncestryEventsViewService method createAncestrySummary.

private String createAncestrySummary(Ancestry ancestry) {
    String ancestrySummary = null;
    StringJoiner joiner = new StringJoiner("; ");
    joiner.add("Type: ".concat(ancestry.getType()));
    joiner.add("Ancestry: ".concat(ancestry.getAncestralGroups().stream().map(i -> i.getAncestralGroup()).collect(Collectors.joining(", "))));
    joiner.add("Country of recruitment: ".concat(ancestry.getCountryOfOrigin().stream().map(i -> i.getCountryName()).collect(Collectors.joining(", "))));
    joiner.add("Country of origin: ".concat(ancestry.getCountryOfRecruitment().stream().map(i -> i.getCountryName()).collect(Collectors.joining(", "))));
    ancestrySummary = joiner.toString();
    return ancestrySummary;
}
Also used : DeletedAncestry(uk.ac.ebi.spot.goci.model.DeletedAncestry) AncestryRepository(uk.ac.ebi.spot.goci.repository.AncestryRepository) DeletedAncestryRepository(uk.ac.ebi.spot.goci.repository.DeletedAncestryRepository) Collection(java.util.Collection) AncestryEventView(uk.ac.ebi.spot.goci.curation.model.AncestryEventView) Autowired(org.springframework.beans.factory.annotation.Autowired) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) List(java.util.List) Service(org.springframework.stereotype.Service) EventTypeService(uk.ac.ebi.spot.goci.service.EventTypeService) StringJoiner(java.util.StringJoiner) EventView(uk.ac.ebi.spot.goci.curation.model.EventView) Ancestry(uk.ac.ebi.spot.goci.model.Ancestry) StringJoiner(java.util.StringJoiner)

Example 10 with Ancestry

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

the class AncestryMappingService method processAncestries.

public void processAncestries() {
    printOutOntologyContent();
    ;
    List<Ancestry> allAncestries = getAllAncestries();
    for (Ancestry ancestry : allAncestries) {
        Long id = ancestry.getId();
        String coo = null;
        if (ancestry.getCountryOfOrigin() != null) {
            for (Country c : ancestry.getCountryOfOrigin()) {
                if (coo == null) {
                    coo = c.getCountryName();
                } else {
                    coo = coo.concat(", ").concat(c.getCountryName());
                }
            }
        } else {
            coo = "NR";
        }
        String cor = null;
        if (ancestry.getCountryOfRecruitment() != null) {
            for (Country c : ancestry.getCountryOfRecruitment()) {
                if (cor == null) {
                    cor = c.getCountryName();
                } else {
                    cor = cor.concat(", ").concat(c.getCountryName());
                }
            }
        } else {
            cor = "NR";
        }
        String ancestralGroup = null;
        if (ancestry.getAncestralGroups() != null) {
            for (AncestralGroup a : ancestry.getAncestralGroups()) {
                if (ancestralGroup == null) {
                    ancestralGroup = a.getAncestralGroup();
                } else {
                    ancestralGroup = ancestralGroup.concat(", ").concat(a.getAncestralGroup());
                }
            }
        } else {
            ancestralGroup = "NR";
        }
        if (ancestralGroup != null) {
            if (ancestralGroup.contains(",")) {
                String[] groups = ancestralGroup.split(",");
                for (String group : groups) {
                    mapAncestralGroup(id, group.toLowerCase());
                }
            } else {
                mapAncestralGroup(id, ancestralGroup.toLowerCase());
            }
        }
        if (coo != null) {
            if (coo.contains(",")) {
                String[] countries = coo.split(",");
                for (String country : countries) {
                    mapCoO(id, country.toLowerCase());
                }
            } else {
                mapCoO(id, coo.toLowerCase());
            }
        }
        if (cor != null) {
            if (cor.contains(",")) {
                String[] countries = cor.split(",");
                for (String country : countries) {
                    mapCoR(id, country.toLowerCase());
                }
            } else {
                mapCoR(id, cor.toLowerCase());
            }
        }
    }
    getErrors().info("All ancestries processed");
    printResult();
}
Also used : AncestralGroup(uk.ac.ebi.spot.goci.model.AncestralGroup) Ancestry(uk.ac.ebi.spot.goci.model.Ancestry) Country(uk.ac.ebi.spot.goci.model.Country)

Aggregations

Ancestry (uk.ac.ebi.spot.goci.model.Ancestry)10 ArrayList (java.util.ArrayList)3 DeletedAncestry (uk.ac.ebi.spot.goci.model.DeletedAncestry)3 Study (uk.ac.ebi.spot.goci.model.Study)3 Test (org.junit.Test)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 AncestryEventView (uk.ac.ebi.spot.goci.curation.model.AncestryEventView)2 EventView (uk.ac.ebi.spot.goci.curation.model.EventView)2 Collection (java.util.Collection)1 List (java.util.List)1 StringJoiner (java.util.StringJoiner)1 Collectors (java.util.stream.Collectors)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Service (org.springframework.stereotype.Service)1 MvcResult (org.springframework.test.web.servlet.MvcResult)1 InitialSampleDescription (uk.ac.ebi.spot.goci.curation.model.InitialSampleDescription)1 ReplicationSampleDescription (uk.ac.ebi.spot.goci.curation.model.ReplicationSampleDescription)1 SnpAssociationTableView (uk.ac.ebi.spot.goci.curation.model.SnpAssociationTableView)1 AncestralGroup (uk.ac.ebi.spot.goci.model.AncestralGroup)1 Association (uk.ac.ebi.spot.goci.model.Association)1