Skip to content

Commit

Permalink
Biosample implementation in IsaJsonEna is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedram-A-Keyvani committed Oct 15, 2024
1 parent 2bc37dc commit 4da4045
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 92 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.http.MediaType.APPLICATION_XML_VALUE;

import com.elixir.biohackaton.ISAToSRA.biosamples.service.BioSamplesAccessionsParser;
import com.elixir.biohackaton.ISAToSRA.receipt.isamodel.*;
import com.elixir.biohackaton.ISAToSRA.receipt.marsmodel.*;
import com.elixir.biohackaton.ISAToSRA.sra.model.Receipt;
Expand Down Expand Up @@ -36,8 +35,6 @@
@Slf4j
@RestController
public class WebinIsaToXmlSubmissionController {
@Autowired private BioSamplesAccessionsParser bioSamplesAccessionsParser;

@Autowired private WebinStudyXmlCreator webinStudyXmlCreator;

@Autowired private WebinExperimentXmlCreator webinExperimentXmlCreator;
Expand Down Expand Up @@ -80,18 +77,16 @@ public String performSubmissionToEna(
}

final IsaJson isaJson = this.objectMapper.readValue(submissionPayload, IsaJson.class);
final List<Study> studies = getStudies(isaJson);
final Map<String, String> typeToBioSamplesAccessionMap =
this.bioSamplesAccessionsParser.parseIsaFileAndGetBioSampleAccessions(
studies, new HashMap<>());

final Document document = DocumentHelper.createDocument();
final Element webinElement = startPreparingWebinV2SubmissionXml(document);
final String randomSubmissionIdentifier = String.valueOf(Math.random());

final List<Study> studies = getStudies(isaJson);
this.webinStudyXmlCreator.createENAStudySetElement(
webinElement, studies, randomSubmissionIdentifier);

final Map<String, String> typeToBioSamplesAccessionMap = getBiosamples(studies);
final Map<Integer, String> experimentSequenceMap =
this.webinExperimentXmlCreator.createENAExperimentSetElement(
typeToBioSamplesAccessionMap, webinElement, studies, randomSubmissionIdentifier);
Expand Down Expand Up @@ -135,6 +130,31 @@ public Investigation getInvestigation(final IsaJson isaJson) {
return null;
}

public Map<String, String> getBiosamples(List<Study> studies) {
HashMap<String, String> biosamples = new HashMap<>();
for (Study study : studies) {
for (Source source : study.materials.sources) {
String sourceAccession = getCharacteresticAnnotation(source.characteristics);
if (!sourceAccession.isBlank()) {
biosamples.put("SOURCE", sourceAccession);
return biosamples;
}
}
}

return biosamples;
}

private String getCharacteresticAnnotation(List<Characteristic> characteristics) {
for (Characteristic characteristic : characteristics) {
if ("#characteristic_category/accession".equals(characteristic.category.id)) {
return characteristic.value.annotationValue;
}
}

return "";
}

private static Element startPreparingWebinV2SubmissionXml(Document document) {
final Element webinElement = document.addElement("WEBIN");
final Element submissionElement = webinElement.addElement("SUBMISSION");
Expand Down

0 comments on commit 4da4045

Please sign in to comment.