Skip to content

Commit

Permalink
Merge pull request #75 from apriltuesday/fixes-from-testing
Browse files Browse the repository at this point in the history
Fixes from testing
  • Loading branch information
apriltuesday authored Nov 7, 2024
2 parents 6fe7422 + 19c2eed commit d3e7230
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ 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())),
getAliasAccessionPairs(Sample.Fields.id, receipt.getSamples()),
null,
null,
getAliasAccessionPairs(OtherMaterial.Fields.id, receipt.getExperiments()),
getAliasAccessionPairs(DataFile.Fields.id, receipt.getRuns()),
Expand All @@ -63,6 +64,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<ReceiptObject> items) {
return new ReceiptAccessionsMap() {
Expand All @@ -73,7 +80,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)));
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit d3e7230

Please sign in to comment.