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));
}
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";
}
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";
}
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;
}
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();
}
Aggregations