diff --git a/repository-services/isajson-biosamples/src/main/java/com/elixir/biohackaton/ISAToSRA/biosamples/service/BioSamplesSubmitter.java b/repository-services/isajson-biosamples/src/main/java/com/elixir/biohackaton/ISAToSRA/biosamples/service/BioSamplesSubmitter.java index 06424ee..8c8ad47 100644 --- a/repository-services/isajson-biosamples/src/main/java/com/elixir/biohackaton/ISAToSRA/biosamples/service/BioSamplesSubmitter.java +++ b/repository-services/isajson-biosamples/src/main/java/com/elixir/biohackaton/ISAToSRA/biosamples/service/BioSamplesSubmitter.java @@ -94,7 +94,9 @@ private BioSample createAndUpdateChildSampleWithRelationship( final BioSample bioSample = new BioSample.Builder(sample.getName() != null ? sample.getName() : "child_sample") .withRelease(Instant.now()) .withAttributes( - Collections.singletonList(Attribute.build("organism", parentSampleOrganism))) + List.of(Attribute.build("organism", parentSampleOrganism), + Attribute.build("collection date", "not provided"), + Attribute.build("geographic location (country and/or sea)", "not provided"))) .build(); try { final EntityModel persistedSampleEntity = this.createSampleInBioSamples(bioSample, webinToken); @@ -147,7 +149,9 @@ private BioSample createSourceBioSample(final List studies, final String final BioSample sourceSample = new BioSample.Builder(source.getName()) .withRelease(Instant.now()) - .withAttributes(Collections.singleton(organismAttribute.get())) + .withAttributes(List.of(organismAttribute.get(), + Attribute.build("collection date", "not provided"), + Attribute.build("geographic location (country and/or sea)", "not provided"))) .build(); final EntityModel persistedParentSampleEntity = this.createSampleInBioSamples(sourceSample, webinToken); diff --git a/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/controller/WebinIsaToXmlSubmissionController.java b/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/controller/WebinIsaToXmlSubmissionController.java index e195d10..50a1ac4 100644 --- a/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/controller/WebinIsaToXmlSubmissionController.java +++ b/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/controller/WebinIsaToXmlSubmissionController.java @@ -88,7 +88,7 @@ public String performSubmissionToEna( webinElement, studies, randomSubmissionIdentifier); final Map typeToBioSamplesAccessionMap = getBiosamples(studies); - final Map experimentSequenceMap = + final Map experimentSequenceMap = this.webinExperimentXmlCreator.createENAExperimentSetElement( typeToBioSamplesAccessionMap, webinElement, studies, randomSubmissionIdentifier); diff --git a/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/WebinExperimentXmlCreator.java b/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/WebinExperimentXmlCreator.java index 065e45e..a9c2272 100644 --- a/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/WebinExperimentXmlCreator.java +++ b/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/WebinExperimentXmlCreator.java @@ -5,7 +5,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; @@ -16,7 +15,7 @@ public class WebinExperimentXmlCreator { public static final String OTHER_MATERIAL_LIBRARY_NAME_DETERMINES_EXPERIMENT = "Library Name"; - public Map createENAExperimentSetElement( + public Map createENAExperimentSetElement( final Map typeToBioSamplesAccessionMap, final Element webinElement, final List studies, @@ -110,15 +109,14 @@ private AtomicReference>> populateProtocolToParamete return protocolToParameterMap; } - private Map mapExperiments( + private Map mapExperiments( final List studies, final Element root, final Map> protocolToParameterMap, final Map bioSampleAccessions, final String randomSubmissionIdentifier) { final Map> protocolToParameterValuesMap = new HashMap<>(); - final Map experimentSequence = new HashMap<>(); - final AtomicInteger sequenceCounter = new AtomicInteger(0); + final Map experimentSequence = new HashMap<>(); studies.forEach( study -> @@ -133,11 +131,11 @@ private Map mapExperiments( otherMaterial -> { final Element experimentElement = root.addElement("EXPERIMENT"); final String otherMaterialId = otherMaterial.getId(); + final String experimentId = + otherMaterialId + "-" + randomSubmissionIdentifier; - experimentSequence.put( - sequenceCounter.incrementAndGet(), otherMaterialId); - experimentElement.addAttribute( - "alias", otherMaterialId + "-" + randomSubmissionIdentifier); + experimentSequence.put(otherMaterialId, experimentId); + experimentElement.addAttribute("alias", experimentId); experimentElement .addElement("TITLE") .addText(otherMaterial.getName()); diff --git a/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/WebinHttpSubmissionService.java b/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/WebinHttpSubmissionService.java index 095a836..df8e074 100644 --- a/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/WebinHttpSubmissionService.java +++ b/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/WebinHttpSubmissionService.java @@ -16,7 +16,7 @@ public class WebinHttpSubmissionService { final RestTemplate restTemplate = new RestTemplate(); private static final String webinSubmissionUrl = - "https://wwwdev.ebi.ac.uk/ena/dev/submit/webin-v2/submit"; + "https://wwwdev.ebi.ac.uk/ena/submit/webin-v2/submit"; public String performWebinSubmission( final String submissionAccountId, final String webinXml, final String webinPassword) { diff --git a/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/WebinRunXmlCreator.java b/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/WebinRunXmlCreator.java index e89166d..72b66d7 100644 --- a/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/WebinRunXmlCreator.java +++ b/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/WebinRunXmlCreator.java @@ -14,12 +14,13 @@ public class WebinRunXmlCreator { public void createENARunSetElement( final Element webinElement, final List studies, - final Map experimentSequenceMap, + final Map experimentSequenceMap, final String randomSubmissionIdentifier) { - final String lastExperimentId = - experimentSequenceMap.get( - Collections.max(experimentSequenceMap.entrySet(), Map.Entry.comparingByValue()) - .getKey()); + final String lastExperimentKeyInRawFile = + Collections.max(experimentSequenceMap.entrySet(), Map.Entry.comparingByKey()).getKey(); + final String lastExperimentIdGenerated = + Collections.max(experimentSequenceMap.entrySet(), Map.Entry.comparingByKey()).getValue(); + final Element runSetElement = webinElement.addElement("RUN_SET"); studies.forEach( @@ -37,7 +38,7 @@ public void createENARunSetElement( runElement.addElement("TITLE").addText(assayId); runElement .addElement("EXPERIMENT_REF") - .addAttribute("refname", lastExperimentId); + .addAttribute("refname", lastExperimentIdGenerated); final AtomicReference dataFileOutput = new AtomicReference<>(); assay @@ -48,7 +49,7 @@ public void createENARunSetElement( .getInputs() .forEach( input -> { - if (input.getId().equals(lastExperimentId)) { + if (input.getId().equals(lastExperimentKeyInRawFile)) { dataFileOutput.set( processSequence.getOutputs().get(0)); } diff --git a/test-data/biosamples-input-isa.json b/test-data/biosamples-input-isa.json index 6155570..682a6cf 100644 --- a/test-data/biosamples-input-isa.json +++ b/test-data/biosamples-input-isa.json @@ -853,7 +853,7 @@ "dataFiles": [ { "@id": "#data/334", - "name": "RD file 1b", + "name": "ENA_TEST2.R2.fastq.gz", "type": "Raw Data File", "comments": [ {