Skip to content

Commit

Permalink
Merge branch 'rollback-retro-sistr-updates'
Browse files Browse the repository at this point in the history
  • Loading branch information
apetkau committed Apr 4, 2018
2 parents 14d1e47 + e830a00 commit 8f6d7b0
Show file tree
Hide file tree
Showing 57 changed files with 446 additions and 270 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changes
=======

0.20.0 to 0.21.0
----------------
* [Administration]: Disabled automated SISTR results from saving to sample metadata. Also disabled retrospective results from being added during the database update. Installations that have already performed the 0.20.0 update will have their retrospective automated SISTR results automatically added to sample metadata. Installations that jump directly to 0.20.1 and above will not have this data added to sample metadata. (0.20.1)

0.19.0 to 0.20.0
----------------
* [Developer]: Fixed exception being thrown related to permission denied for updating samples when a normal user (collaborator on a project) runs the assembly pipeline (0.19.1).
Expand Down
Binary file modified doc/images/tutorials/common/projects/create-new-project-form.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>ca.corefacility.bioinformatics</groupId>
<artifactId>irida</artifactId>
<packaging>war</packaging>
<version>0.20.0</version>
<version>0.20.1</version>
<name>irida</name>
<url>http://www.irida.ca</url>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public class Project extends IridaResourceSupport

@NotNull
@Column(name="sistr_typing_uploads")
private boolean sistrTypingUploads;
@Enumerated(EnumType.STRING)
private AutomatedSISTRSetting sistrTypingUploads;

@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE, mappedBy = "project")
private List<ProjectUserJoin> users;
Expand Down Expand Up @@ -139,7 +140,7 @@ public class Project extends IridaResourceSupport

public Project() {
assembleUploads = false;
sistrTypingUploads = false;
sistrTypingUploads = AutomatedSISTRSetting.OFF;
createdDate = new Date();
}

Expand Down Expand Up @@ -168,7 +169,8 @@ public void setId(final Long id) {
public boolean equals(Object other) {
if (other instanceof Project) {
Project p = (Project) other;
return Objects.equals(createdDate, p.createdDate) && Objects.equals(name, p.name);
return Objects.equals(createdDate, p.createdDate) && Objects.equals(modifiedDate, modifiedDate) && Objects
.equals(name, p.name);
}

return false;
Expand Down Expand Up @@ -286,11 +288,23 @@ public void setMaximumCoverage(Integer maximumCoverage) {
this.maximumCoverage = maximumCoverage;
}

public boolean getSistrTypingUploads() {
public AutomatedSISTRSetting getSistrTypingUploads() {
return sistrTypingUploads;
}

public void setSistrTypingUploads(boolean sistrTypingUploads) {
public void setSistrTypingUploads(AutomatedSISTRSetting sistrTypingUploads) {
this.sistrTypingUploads = sistrTypingUploads;
}

/**
* Setting for how to run automated SISTR analyses.
* OFF - Do not run
* AUTO - Run SISTR
* AUTO_METADATA - Run and save results to metadata
*/
public enum AutomatedSISTRSetting {
OFF,
AUTO,
AUTO_METADATA
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package ca.corefacility.bioinformatics.irida.processing.impl;

import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -65,12 +67,13 @@ public SistrTypingFileProcessor(SequencingObjectRepository objectRepository,
* {@inheritDoc}
*/
@Override
@Transactional
public void process(SequencingObject sequencingObject) {
logger.debug("Setting up SISTR typing for sequence " + sequencingObject.getId());

User admin = userRepository.loadUserByUsername("admin");

Project.AutomatedSISTRSetting automatedSISTRSetting = shouldTypeWithSISTR(sequencingObject);

// Ensure it's a paired upload. Single end can't currently be
// assembled/typed.
if (sequencingObject instanceof SequenceFilePair) {
Expand All @@ -87,8 +90,16 @@ public void process(SequencingObject sequencingObject) {

// build an AnalysisSubmission
Builder builder = new AnalysisSubmission.Builder(pipelineUUID);

if(automatedSISTRSetting.equals(Project.AutomatedSISTRSetting.AUTO_METADATA)){
builder.updateSamples(true);
}
else if(automatedSISTRSetting.equals(Project.AutomatedSISTRSetting.AUTO)){
builder.updateSamples(false);
}

AnalysisSubmission submission = builder.inputFiles(Sets.newHashSet((SequenceFilePair) sequencingObject))
.priority(AnalysisSubmission.Priority.LOW).updateSamples(true)
.priority(AnalysisSubmission.Priority.LOW)
.name("Automated SISTR Typing " + sequencingObject.toString()).build();
submission.setSubmitter(admin);

Expand Down Expand Up @@ -123,19 +134,18 @@ public Boolean modifiesFile() {
public boolean shouldProcessFile(Long sequencingObjectId) {
SequencingObject sequencingObject = objectRepository.findOne(sequencingObjectId);

return shouldTypeWithSISTR(sequencingObject);
return !shouldTypeWithSISTR(sequencingObject).equals(Project.AutomatedSISTRSetting.OFF);
}

/**
* Check whether any {@link Project} associated with the
* {@link SequencingObject} is set to type with SISTR.
*
* @param object
* {@link SequencingObject} to check to type with SISTR.
*
* @param object {@link SequencingObject} to check to type with SISTR.
* @return true if it should type with SISTR, false otherwise
*/
private boolean shouldTypeWithSISTR(SequencingObject object) {
boolean type = false;
private Project.AutomatedSISTRSetting shouldTypeWithSISTR(SequencingObject object) {
Project.AutomatedSISTRSetting type = Project.AutomatedSISTRSetting.OFF;

SampleSequencingObjectJoin sampleForSequencingObject = ssoRepository.getSampleForSequencingObject(object);

Expand All @@ -147,7 +157,13 @@ private boolean shouldTypeWithSISTR(SequencingObject object) {
List<Join<Project, Sample>> projectForSample = psjRepository
.getProjectForSample(sampleForSequencingObject.getSubject());

type = projectForSample.stream().anyMatch(j -> j.getSubject().getSistrTypingUploads());
Set<Project.AutomatedSISTRSetting> sistrOptions = projectForSample.stream()
.map(j -> j.getSubject().getSistrTypingUploads()).collect(Collectors.toSet());

if (sistrOptions.contains(Project.AutomatedSISTRSetting.AUTO_METADATA)) {
return Project.AutomatedSISTRSetting.AUTO_METADATA;
} else if (sistrOptions.contains(Project.AutomatedSISTRSetting.AUTO))
return Project.AutomatedSISTRSetting.AUTO;
} else {
logger.warn("Cannot find sample for sequencing object. Not typing with SISTR");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ public Map<String, String> updateAssemblySetting(@PathVariable Long projectId, @
*/
@RequestMapping(value = "/sistr", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> updateSistrSetting(@PathVariable Long projectId, @RequestParam boolean sistr,
public Map<String, String> updateSistrSetting(@PathVariable Long projectId, @RequestParam
Project.AutomatedSISTRSetting sistr,
final Model model, Locale locale) {
Project read = projectService.read(projectId);

Expand All @@ -311,7 +312,7 @@ public Map<String, String> updateSistrSetting(@PathVariable Long projectId, @Req
projectService.updateProjectSettings(read, updates);

String message = null;
if (sistr) {
if (sistr.equals(Project.AutomatedSISTRSetting.AUTO) || sistr.equals(Project.AutomatedSISTRSetting.AUTO_METADATA)) {
message = messageSource.getMessage("project.settings.notifications.sistr.enabled",
new Object[] { read.getLabel() }, locale);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
<include file="add-job-error-table.xml"
relativeToChangelogFile="true"/>
<include file="pipeline-metadata-entry.xml" relativeToChangelogFile="true"/>
<include file="post-update-fix.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

<changeSet id="pipeline-metadata-entry" author="tom">

<validCheckSum>7:04d990c0430b5fd7bd63f5bfc462584b</validCheckSum>
<validCheckSum>7:fe424670afa75882a10c9178073eecc1</validCheckSum>

<createTable tableName="pipeline_metadata_entry">
<column name="id" type="bigint(20)">
<constraints nullable="false" primaryKey="true" foreignKeyName="FK_PIPELINE_METADATA_ENTRY"
Expand Down Expand Up @@ -38,9 +41,5 @@
<modifyDataType columnName="value" newDataType="longtext" tableName="metadata_entry"/>
<modifyDataType columnName="value" newDataType="longtext" tableName="metadata_entry_AUD"/>

<customChange
class="ca.corefacility.bioinformatics.irida.database.changesets.AutomatedSISTRUpdate"></customChange>


</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">

<changeSet id="post-update-fix" author="tom">

<renameColumn
columnDataType="bit(1)"
newColumnName="sistr_tmp"
oldColumnName="sistr_typing_uploads"
tableName="project"/>

<addColumn tableName="project">
<column name="sistr_typing_uploads" type="varchar(255)"/>
</addColumn>

<sql>
UPDATE project SET sistr_typing_uploads="AUTO" WHERE sistr_tmp=1
</sql>

<sql>
UPDATE project SET sistr_typing_uploads="OFF" WHERE sistr_tmp=0
</sql>

<addNotNullConstraint
columnDataType="varchar(255)"
columnName="sistr_typing_uploads"
defaultNullValue="OFF"
tableName="project"/>

<dropColumn tableName="project" columnName="sistr_tmp"/>

<renameColumn
columnDataType="bit(1)"
newColumnName="sistr_tmp"
oldColumnName="sistr_typing_uploads"
tableName="project_AUD"/>

<addColumn tableName="project_AUD">
<column name="sistr_typing_uploads" type="varchar(255)"/>
</addColumn>

<sql>
UPDATE project_AUD SET sistr_typing_uploads="AUTO" WHERE sistr_tmp=1
</sql>

<sql>
UPDATE project_AUD SET sistr_typing_uploads="OFF" WHERE sistr_tmp=0
</sql>

<dropColumn tableName="project_AUD" columnName="sistr_tmp"/>

</changeSet>
</databaseChangeLog>
Loading

0 comments on commit 8f6d7b0

Please sign in to comment.