Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes from testing #75

Merged
merged 4 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}