From 803bccd475b85c4257c1a862da32200ccdd89fcb Mon Sep 17 00:00:00 2001 From: April Shen Date: Thu, 7 Nov 2024 18:13:43 +0100 Subject: [PATCH 1/4] fix for getting accessions into mars receipt --- .../WebinIsaToXmlSubmissionController.java | 2 ++ .../ISAToSRA/sra/service/MarsReceiptService.java | 12 ++++++++++-- .../ISAToSRA/receipt/MarsReceiptProvider.java | 1 + .../ISAToSRA/receipt/ReceiptAccessionsMap.java | 8 ++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) 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 50a1ac4..1531232 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 @@ -106,6 +106,8 @@ public String performSubmissionToEna( webinHttpSubmissionService.performWebinSubmission( webinUserName, document.asXML(), webinPassword); final Receipt receiptJson = receiptConversionService.readReceiptXml(receiptXml); + System.out.println(receiptXml); + System.out.println(receiptJson); final MarsReceipt marsReceipt = marsReceiptService.convertReceiptToMars(receiptJson, isaJson); return marsReceiptService.convertMarsReceiptToJson(marsReceipt); diff --git a/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/MarsReceiptService.java b/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/MarsReceiptService.java index 49907e5..5bdfca3 100644 --- a/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/MarsReceiptService.java +++ b/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/MarsReceiptService.java @@ -54,7 +54,7 @@ public MarsReceipt convertReceiptToMars(final Receipt receipt, final IsaJson isa getAliasAccessionPairs( Study.Fields.title, Optional.ofNullable(receipt.getStudies()).orElse(receipt.getProjects())), - getAliasAccessionPairs(Sample.Fields.id, receipt.getSamples()), + null, null, getAliasAccessionPairs(OtherMaterial.Fields.id, receipt.getExperiments()), getAliasAccessionPairs(DataFile.Fields.id, receipt.getRuns()), @@ -63,6 +63,12 @@ public MarsReceipt convertReceiptToMars(final Receipt receipt, final IsaJson isa isaJson); } + private static String getPreRandomizedAlias(ReceiptObject receiptObject) { + // Convert Arabidopsis thaliana-0.49105604184136276 -> Arabidopsis thaliana + String alias = receiptObject.getAlias(); + return alias.substring(0, alias.lastIndexOf("-")); + } + private ReceiptAccessionsMap getAliasAccessionPairs( String keyNameInput, final List items) { return new ReceiptAccessionsMap() { @@ -73,7 +79,9 @@ private ReceiptAccessionsMap getAliasAccessionPairs( Optional.ofNullable(items).orElse(new ArrayList<>()).stream() .filter(item -> item != null) .collect( - Collectors.toMap(ReceiptObject::getAlias, ReceiptObject::getAccession))); + Collectors.toMap( + MarsReceiptService::getPreRandomizedAlias, + ReceiptObject::getAccession))); } }; } diff --git a/repository-services/receipt/src/main/java/com/elixir/biohackaton/ISAToSRA/receipt/MarsReceiptProvider.java b/repository-services/receipt/src/main/java/com/elixir/biohackaton/ISAToSRA/receipt/MarsReceiptProvider.java index 2d85361..db9ba8c 100644 --- a/repository-services/receipt/src/main/java/com/elixir/biohackaton/ISAToSRA/receipt/MarsReceiptProvider.java +++ b/repository-services/receipt/src/main/java/com/elixir/biohackaton/ISAToSRA/receipt/MarsReceiptProvider.java @@ -58,6 +58,7 @@ protected MarsReceipt buildMarsReceipt( isaJson, marsMessage, marsAccessions); + System.out.println("Mars accessions: " + marsAccessions); return MarsReceipt.builder() .targetRepository(targetRepository) .accessions(marsAccessions) diff --git a/repository-services/receipt/src/main/java/com/elixir/biohackaton/ISAToSRA/receipt/ReceiptAccessionsMap.java b/repository-services/receipt/src/main/java/com/elixir/biohackaton/ISAToSRA/receipt/ReceiptAccessionsMap.java index 4e64ad5..dd88d62 100644 --- a/repository-services/receipt/src/main/java/com/elixir/biohackaton/ISAToSRA/receipt/ReceiptAccessionsMap.java +++ b/repository-services/receipt/src/main/java/com/elixir/biohackaton/ISAToSRA/receipt/ReceiptAccessionsMap.java @@ -19,4 +19,12 @@ public ReceiptAccessionsMap(String keyName, String keyValue) { } }; } + + public String toString() { + String result = "ReceiptAccessionsMap:" + keyName + "\n"; + for (String key: accessionMap.keySet()) { + result += key + ":" + accessionMap.get(key) + "\n"; + } + return result; + } } From 78fe01c531d950f0e16afaea01b5c96d477f4be5 Mon Sep 17 00:00:00 2001 From: April Shen Date: Thu, 7 Nov 2024 18:14:38 +0100 Subject: [PATCH 2/4] ena service to use ena rather than ena.embl --- .../biohackaton/ISAToSRA/sra/service/MarsReceiptService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/MarsReceiptService.java b/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/MarsReceiptService.java index 5bdfca3..16fd50a 100644 --- a/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/MarsReceiptService.java +++ b/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/MarsReceiptService.java @@ -50,7 +50,7 @@ public String convertMarsReceiptToJson(final MarsReceipt marsReceipt) { */ public MarsReceipt convertReceiptToMars(final Receipt receipt, final IsaJson isaJson) { return buildMarsReceipt( - "ena.embl", // https://registry.identifiers.org/registry/ena.embl + "ena", // TODO decide whether to use instead https://registry.identifiers.org/registry/ena.embl getAliasAccessionPairs( Study.Fields.title, Optional.ofNullable(receipt.getStudies()).orElse(receipt.getProjects())), From 6449e8c60666d8a917848c5d1ecf9a3b7a76a0d1 Mon Sep 17 00:00:00 2001 From: April Shen Date: Thu, 7 Nov 2024 18:15:49 +0100 Subject: [PATCH 3/4] remove debug print --- .../elixir/biohackaton/ISAToSRA/receipt/MarsReceiptProvider.java | 1 - 1 file changed, 1 deletion(-) diff --git a/repository-services/receipt/src/main/java/com/elixir/biohackaton/ISAToSRA/receipt/MarsReceiptProvider.java b/repository-services/receipt/src/main/java/com/elixir/biohackaton/ISAToSRA/receipt/MarsReceiptProvider.java index db9ba8c..2d85361 100644 --- a/repository-services/receipt/src/main/java/com/elixir/biohackaton/ISAToSRA/receipt/MarsReceiptProvider.java +++ b/repository-services/receipt/src/main/java/com/elixir/biohackaton/ISAToSRA/receipt/MarsReceiptProvider.java @@ -58,7 +58,6 @@ protected MarsReceipt buildMarsReceipt( isaJson, marsMessage, marsAccessions); - System.out.println("Mars accessions: " + marsAccessions); return MarsReceipt.builder() .targetRepository(targetRepository) .accessions(marsAccessions) From 19c2eed473500b0c6d2eb213cb40ee5e73c651f7 Mon Sep 17 00:00:00 2001 From: April Shen Date: Thu, 7 Nov 2024 18:19:26 +0100 Subject: [PATCH 4/4] spotless... --- .../biohackaton/ISAToSRA/sra/service/MarsReceiptService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/MarsReceiptService.java b/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/MarsReceiptService.java index 16fd50a..d9ec770 100644 --- a/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/MarsReceiptService.java +++ b/repository-services/isajson-ena/src/main/java/com/elixir/biohackaton/ISAToSRA/sra/service/MarsReceiptService.java @@ -50,7 +50,8 @@ public String convertMarsReceiptToJson(final MarsReceipt marsReceipt) { */ public MarsReceipt convertReceiptToMars(final Receipt receipt, final IsaJson isaJson) { return buildMarsReceipt( - "ena", // TODO decide whether to use instead https://registry.identifiers.org/registry/ena.embl + "ena", // TODO decide whether to use instead + // https://registry.identifiers.org/registry/ena.embl getAliasAccessionPairs( Study.Fields.title, Optional.ofNullable(receipt.getStudies()).orElse(receipt.getProjects())),