Skip to content

Commit

Permalink
Merge pull request #1451 from phac-nml/hotfix/ncbi-upload-template
Browse files Browse the repository at this point in the history
Fix NCBI Export
  • Loading branch information
ericenns authored Jan 24, 2023
2 parents 9e2c02a + 8046499 commit 773d014
Show file tree
Hide file tree
Showing 11 changed files with 206 additions and 69 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

# Changelog

## [22.09.7] - Unreleased
* [UI]: Fixed bugs on NCBI Export page preventing the NCBI `submission.xml` file from being properly written. See [PR 1451](https://github.com/phac-nml/irida/pull/1451)

## [22.09.6] - 2022/12/21
* [UI]: Fixed bug on NCBI Export page preventing the export from occuring. See [PR 1439](https://github.com/phac-nml/irida/pull/1439)

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {
}

group = "ca.corefacility.bioinformatics"
version = "22.09.6"
version = "22.09.7"
description = "irida"

java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
import ca.corefacility.bioinformatics.irida.model.export.NcbiBioSampleFiles;
import ca.corefacility.bioinformatics.irida.model.project.Project;
import ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair;
import ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject;
import ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile;
import ca.corefacility.bioinformatics.irida.model.user.User;
import ca.corefacility.bioinformatics.irida.ria.web.ajax.dto.NcbiExportSubmissionTableModel;
import ca.corefacility.bioinformatics.irida.ria.web.models.export.NcbiBioSampleModel;
import ca.corefacility.bioinformatics.irida.ria.web.models.export.NcbiExportSubmissionAdminTableModel;
import ca.corefacility.bioinformatics.irida.ria.web.models.export.NcbiSubmissionRequest;
import ca.corefacility.bioinformatics.irida.ria.web.models.export.NcbiSubmissionModel;
import ca.corefacility.bioinformatics.irida.ria.web.models.export.NcbiSubmissionRequest;
import ca.corefacility.bioinformatics.irida.ria.web.models.tables.TableRequest;
import ca.corefacility.bioinformatics.irida.ria.web.models.tables.TableResponse;
import ca.corefacility.bioinformatics.irida.service.ProjectService;
Expand Down Expand Up @@ -89,22 +88,8 @@ public TableResponse<NcbiExportSubmissionAdminTableModel> getNCBIExportsForAdmin
*/
public NcbiSubmissionModel getExportDetails(Long exportId) {
NcbiExportSubmission submission = ncbiService.read(exportId);
Project project = projectService.read(submission.getProject()
.getId());

List<NcbiBioSampleModel> bioSamples = submission.getBioSampleFiles()
.stream()
.map(bioSampleFile -> {
List<SequencingObject> pairs = bioSampleFile.getPairs()
.stream()
.peek(pair -> uiSampleService.enhanceQcEntries(pair, project))
.collect(Collectors.toList());
List<SequencingObject> singles = bioSampleFile.getFiles()
.stream()
.peek(single -> uiSampleService.enhanceQcEntries(single, project))
.collect(Collectors.toList());
return new NcbiBioSampleModel(bioSampleFile);
})
List<NcbiBioSampleModel> bioSamples = submission.getBioSampleFiles().stream().map(NcbiBioSampleModel::new)
.collect(Collectors.toList());

return new NcbiSubmissionModel(submission, bioSamples);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version='1.0' encoding='utf-8'?>

<Submission schema_version="2.0" xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.ncbi.nlm.nih.gov/viewvc/v1/trunk/submit/public-docs/common/submission.xsd?view=co">
<Description>
<Organization role="owner" type="institute">
Expand All @@ -17,13 +18,12 @@
</Description>

<Action th:each="sample : ${submission.bioSampleFiles}">
<!--/*-->
IRIDA sequence files may either be plaintext (.fastq) or gzip compressed (.fastq.gz)
NCBI requires that uploaded files should have the appropriate file extension.
Determine if the IRIDA sequence file is compressed by looking for .gz extension
and add the appropriate extension to the uploaded files.
<!--*/-->
<AddFiles target_db="SRA" th:each="file : ${sample.files}">
<!--/*--> IRIDA sequence files may either be
plaintext (.fastq) or gzip compressed (.fastq.gz) NCBI requires that uploaded files should
have the appropriate file extension. Determine if the IRIDA sequence file is compressed by
looking for .gz extension and add the appropriate extension to the uploaded files. <!--*/-->
<AddFiles
target_db="SRA" th:each="file : ${sample.files}">
<th:block th:if="${file.getFiles().toString().endsWith(&quot;.gz&quot;)}">
<File th:attr="file_path=${file.getId() + '.fastq.gz'}">
<DataType>generic-data</DataType>
Expand All @@ -34,13 +34,15 @@
<DataType>generic-data</DataType>
</File>
</th:block>
<Attribute name="instrument_model" th:text="${sample.instrumentModel.value}">_Model_</Attribute>
<Attribute name="instrument_model" th:text="${sample.instrumentModel.model}">_Model_</Attribute>
<Attribute name="library_name" th:text="${sample.libraryName}">_name_</Attribute>
<Attribute name="library_strategy" th:text="${sample.libraryStrategy.value}">_Strategy_</Attribute>
<Attribute name="library_source" th:text="${sample.librarySource.value}">_Source_</Attribute>
<Attribute name="library_selection" th:text="${sample.librarySelection.value}">_Selection_</Attribute>
<Attribute name="library_selection" th:text="${sample.librarySelection.value}">
_Selection_</Attribute>
<Attribute name="library_layout">SINGLE</Attribute>
<Attribute name="library_construction_protocol" th:text="${sample.libraryConstructionProtocol}">_Protocol_</Attribute>
<Attribute name="library_construction_protocol"
th:text="${sample.libraryConstructionProtocol}">_Protocol_</Attribute>
<AttributeRefId name="BioProject">
<RefId>
<PrimaryId db="BioProject" th:text="${submission.bioProjectId}">_Project_</PrimaryId>
Expand All @@ -56,8 +58,10 @@
th:text="${sample.id}">_spuid_</SPUID>
</Identifier>
</AddFiles>
<AddFiles target_db="SRA" th:each="pair : ${sample.pairs}" th:with="forward=${pair.getForwardSequenceFile()}, reverse=${pair.getReverseSequenceFile()}">
<th:block th:if="${forward.getFile().toString().endsWith(&quot;.gz&quot;)}">
<AddFiles
target_db="SRA" th:each="pair : ${sample.pairs}"
th:with="forward=${pair.getForwardSequenceFile()}, reverse=${pair.getReverseSequenceFile()}">
<th:block th:if="${forward.getFile().toString().endsWith(&quot;.gz&quot;)}">
<File th:attr="file_path=${forward.getId() + '.fastq.gz'}">
<DataType>generic-data</DataType>
</File>
Expand All @@ -67,7 +71,7 @@
<DataType>generic-data</DataType>
</File>
</th:block>
<th:block th:if="${reverse.getFile().toString().endsWith(&quot;.gz&quot;)}" >
<th:block th:if="${reverse.getFile().toString().endsWith(&quot;.gz&quot;)}">
<File th:attr="file_path=${reverse.getId() + '.fastq.gz'}">
<DataType>generic-data</DataType>
</File>
Expand All @@ -77,13 +81,15 @@
<DataType>generic-data</DataType>
</File>
</th:block>
<Attribute name="instrument_model" th:text="${sample.instrumentModel.value}">_Model_</Attribute>
<Attribute name="instrument_model" th:text="${sample.instrumentModel.model}">_Model_</Attribute>
<Attribute name="library_name" th:text="${sample.libraryName}">_name_</Attribute>
<Attribute name="library_strategy" th:text="${sample.libraryStrategy.value}">_Strategy_</Attribute>
<Attribute name="library_source" th:text="${sample.librarySource.value}">_Source_</Attribute>
<Attribute name="library_selection" th:text="${sample.librarySelection.value}">_Selection_</Attribute>
<Attribute name="library_selection" th:text="${sample.librarySelection.value}">
_Selection_</Attribute>
<Attribute name="library_layout">PAIRED</Attribute>
<Attribute name="library_construction_protocol" th:text="${sample.libraryConstructionProtocol}">_Protocol_</Attribute>
<Attribute name="library_construction_protocol"
th:text="${sample.libraryConstructionProtocol}">_Protocol_</Attribute>
<AttributeRefId name="BioProject">
<RefId>
<PrimaryId db="BioProject" th:text="${submission.bioProjectId}">_Project_</PrimaryId>
Expand All @@ -100,4 +106,4 @@
</Identifier>
</AddFiles>
</Action>
</Submission>
</Submission>
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ import ExportUploadStateTag from "../ExportUploadStateTag";
export const formatNcbiSubmissionDetails = (
submission: Omit<NcbiSubmission, "bioSamples">
): BasicListItem[] => {
const LOCALE = window.TL?.LANGUAGE_TAG || "en";
const releaseDate = submission.releaseDate
? formatInternationalizedDateTime(submission.releaseDate)
? new Date(submission.releaseDate).toLocaleDateString(LOCALE, {
month: "short",
year: "numeric",
day: "numeric",
timeZone: "UTC", // ignoring timezone
})
: i18n("NcbiExportDetailsView.not-released");

return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ function CreateNcbiExport(): JSX.Element {
pairs?: number[];
singles?: number[];
bioSample: string;
libraryName: { value: string };
libraryName: string;
libraryStrategy: { value: string };
librarySource: { value: string };
libraryConstructionProtocol: { value: string };
Expand All @@ -234,7 +234,7 @@ function CreateNcbiExport(): JSX.Element {
bioProject,
namespace,
organization,
releaseDate: releaseDate.unix(),
releaseDate: releaseDate.endOf("day").valueOf(),
samples: Object.values(_samples).map(
({
pairs = [],
Expand All @@ -251,7 +251,7 @@ function CreateNcbiExport(): JSX.Element {
singles,
pairs,
bioSample,
libraryName: libraryName.value,
libraryName,
libraryStrategy: libraryStrategy.value,
librarySource: librarySource.value,
libraryConstructionProtocol: libraryConstructionProtocol.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
Expand All @@ -30,6 +31,9 @@ public class NcbiExportPage extends AbstractPage {
@FindBy(xpath = "//*[@id=\"namespace\"]")
private WebElement namespaceInput;

@FindBy(xpath = "//*[@id=\"releaseDate\"]")
private WebElement releaseDateInput;

@FindBy(className = "t-defaults-panel")
private WebElement defaultsPanel;

Expand Down Expand Up @@ -73,6 +77,12 @@ public void enterNamespace(String value) {
namespaceInput.sendKeys(value);
}

public void setReleaseDateInput(String value) {
releaseDateInput.sendKeys(Keys.chord(Keys.CONTROL, "a"));
releaseDateInput.sendKeys(value);
releaseDateInput.sendKeys(Keys.ENTER);
}

public void toggleDefaultsPanel() {
defaultsPanel.click();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package ca.corefacility.bioinformatics.irida.ria.integration.pages.projects;

import java.time.Duration;
import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import ca.corefacility.bioinformatics.irida.ria.integration.pages.AbstractPage;

Expand All @@ -25,4 +29,11 @@ public static NcbiExportsListingPage goTo(WebDriver driver) {
public int getNumberOfBioSampleIdsDisplayed() {
return biodamplesIds.size();
}

public void gotoSubmissionPage(String bioprojectId) {
WebElement link = driver.findElement(By.xpath("//table/tbody//a[text() = '" + bioprojectId + "']"));
link.click();
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.urlMatches("/projects/\\d+/export/\\d+"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

import ca.corefacility.bioinformatics.irida.ria.integration.AbstractIridaUIITChromeDriver;
import ca.corefacility.bioinformatics.irida.ria.integration.pages.LoginPage;
import ca.corefacility.bioinformatics.irida.ria.integration.pages.projects.ExportDetailsPage;
import ca.corefacility.bioinformatics.irida.ria.integration.pages.projects.NcbiExportPage;
import ca.corefacility.bioinformatics.irida.ria.integration.pages.projects.NcbiExportsListingPage;
import ca.corefacility.bioinformatics.irida.ria.integration.pages.projects.ProjectSamplesPage;

import com.github.springtestdbunit.annotation.DatabaseSetup;
Expand All @@ -22,6 +24,7 @@ void testCreateNcbiSubmission() throws Exception {
String SAMPLE_3 = "sample3";
String BIOPROJECT = "BIOPROJECT-1";
String NAMESPACE = "NAMESPACE-FOOBAR";
String RELEASE_DATE = "2030-06-15";
String ORGANIZATION = "ORGANIZATION-FOOBAR";
String PROTOCOL = "AMAZING_PROTOCOL";
String DEFAULT_PROTOCOL = "DEFAULT_PROTOCOL";
Expand All @@ -40,6 +43,7 @@ void testCreateNcbiSubmission() throws Exception {
page.enterBioProject(BIOPROJECT);
page.enterNamespace(NAMESPACE);
page.enterOrganization(ORGANIZATION);
page.setReleaseDateInput(RELEASE_DATE);

// Test default sample settings.
page.toggleDefaultsPanel();
Expand Down Expand Up @@ -84,5 +88,16 @@ void testCreateNcbiSubmission() throws Exception {
assertTrue(page.isSuccessAlertDisplayed(), "Success notification should be displayed");
assertTrue(page.isUserRedirectedToProjectSamplesPage(PROJECT_ID),
"User should be redirected within 5 seconds of submission");

// Make sure all fields submitted successfully
NcbiExportsListingPage listingPage = NcbiExportsListingPage.goTo(driver());
listingPage.gotoSubmissionPage(BIOPROJECT);

ExportDetailsPage detailsPage = ExportDetailsPage.initPage(driver());
assertEquals(BIOPROJECT, detailsPage.getBioproject());
assertEquals(NAMESPACE, detailsPage.getNamespace());

assertEquals(ORGANIZATION, detailsPage.getOrganization());
assertTrue(detailsPage.getReleaseDate().equals("Jun 15, 2030"));
}
}
Loading

0 comments on commit 773d014

Please sign in to comment.