Skip to content

Commit

Permalink
Merge pull request #13166 from assuntad23/13140/bugfix/autopair-issues
Browse files Browse the repository at this point in the history
converting forward and reverse filters to reactive Vue array
  • Loading branch information
mvdbeek authored Jan 18, 2022
2 parents be14264 + d0d46c4 commit 210039e
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,39 @@ describe("PairedListCollectionCreator", () => {
const pairname = wrapper.find("span.pair-name");
expect(pairname.text()).toBe("UII_moo_1");
});

it("autopairs correctly when filters are typed in", async () => {
wrapper = mount(PairedListCollectionCreator, {
propsData: {
initialElements: DATA._4,
creationFn: () => {
return;
},
oncreate: () => {
return;
},
oncancel: () => {
return;
},
hideSourceItems: false,
},
});
await wrapper.vm.$nextTick();
//change filter to _R1/_R2
wrapper.find("div.forward-unpaired-filter > input").setValue("_R1");
await wrapper.vm.$nextTick();
wrapper.find("div.reverse-unpaired-filter > input").setValue("_R2");
await wrapper.vm.$nextTick();
//assert forward filter
const forwardFilter = wrapper.find("div.forward-unpaired-filter > input").element.value;
expect(forwardFilter).toBe("_R1");
//assert reverse filter
const reverseFilter = wrapper.find("div.reverse-unpaired-filter > input").element.value;
expect(reverseFilter).toBe("_R2");
// click Autopair
wrapper.find("a.autopair-link").trigger("click");
await wrapper.vm.$nextTick();
//assert all pairs matched
expect(wrapper.findAll("li.dataset unpaired").length == 0).toBeTruthy();
});
});
18 changes: 10 additions & 8 deletions client/src/components/Collections/PairedListCollectionCreator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,10 @@ export default {
mixins: [mixin],
created() {
this.strategy = this.autopairLCS;
this.filters = this.commonFilters[this.filters] || this.commonFilters[this.DEFAULT_FILTERS];
//TODO convert to Fwd/Rev
// Setup inital filters and shallow copy the items
this.forwardFilter = this.commonFilters[this.DEFAULT_FILTERS][0];
this.reverseFilter = this.commonFilters[this.DEFAULT_FILTERS][1];
this._elementsSetUp();
},
components: {
Expand All @@ -462,15 +465,15 @@ export default {
dot12s: [".1.fastq", ".2.fastq"],
},
DEFAULT_FILTERS: "illumina",
filters: this.DEFAULT_FILTERS,
forwardFilter: "",
reverseFilter: "",
automaticallyPair: true,
initialPairsPossible: true,
matchPercentage: 0.99,
twoPassAutoPairing: true,
removeExtensions: true,
workingElements: [],
forwardFilter: "",
reverseFilter: "",
selectedForwardElement: null,
selectedReverseElement: null,
/** autopair by exact match */
Expand Down Expand Up @@ -837,7 +840,7 @@ export default {
var _regexps = [];
function getRegExps() {
if (!_regexps.length) {
_regexps = [new RegExp(this.filters[0]), new RegExp(this.filters[1])];
_regexps = [new RegExp(this.forwardFilter), new RegExp(this.reverseFilter)];
}
return _regexps;
}
Expand Down Expand Up @@ -925,8 +928,8 @@ export default {
};
},
changeFilters: function (filter) {
this.filters[0] = this.forwardFilter = this.commonFilters[filter][0];
this.filters[1] = this.reverseFilter = this.commonFilters[filter][1];
this.forwardFilter = this.commonFilters[filter][0];
this.reverseFilter = this.commonFilters[filter][1];
},
clickedCreate: function (collectionName) {
this.checkForDuplicates();
Expand All @@ -946,7 +949,6 @@ export default {
this.pairedElements.forEach((pair) => {
if (Object.prototype.hasOwnProperty.call(existingPairNames, pair.name)) {
valid = false;
console.log("found a dupe");
this.duplicatePairNames.push(pair.name);
}
existingPairNames[pair.name] = true;
Expand Down
12 changes: 11 additions & 1 deletion client/tests/qunit/test-data/paired-collection-creator.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ var datasets3 = [
{name: "UII_moo_1.2.fastq", state: STATES.OK}
]

var datasets4= [
{ name: "SET1-01_R1.fastq", state: STATES.OK },
{ name: "SET1-01_R2.fastq", state: STATES.OK },
{ name: "SET1-02_R1.fastq", state: STATES.OK },
{ name: "SET1-02_R2.fastq", state: STATES.OK },
{ name: "SET1-03_R1.fastq", state: STATES.OK },
{ name: "SET1-03_R2.fastq", state: STATES.OK },
]

var datasets1CreateRequestJSON = {
type: "dataset_collection",
collection_type: "list:paired",
Expand Down Expand Up @@ -161,5 +170,6 @@ export default {
_1: datasets1,
_1requestJSON: datasets1CreateRequestJSON,
_2: datasets2,
_3: datasets3
_3: datasets3,
_4: datasets4
};

0 comments on commit 210039e

Please sign in to comment.