Skip to content

Commit 351ff60

Browse files
zhx828calvinlu3
andauthored
Allow adding same mutation into VUS list before reviewing (#152)
* Allow adding same mutation into VUS list before reviewing - If a mutation is deleted from the mutation list and hasn't been reviewed,we allow curator adding the same mutation to VUS list. Upon rejecting the deletion, the mutation will also be removed from VUS list - Update language when adding mutation into mutation list or VUS list when it's already in the system * Update app/scripts/controllers/gene.js Co-authored-by: Calvin Lu <[email protected]> --------- Co-authored-by: Calvin Lu <[email protected]>
1 parent d49998f commit 351ff60

File tree

1 file changed

+38
-16
lines changed

1 file changed

+38
-16
lines changed

app/scripts/controllers/gene.js

+38-16
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ angular.module('oncokbApp')
5858
console.log(error);
5959
});
6060
}
61-
function isValidVariant(originalVariantName) {
61+
function isValidVariant(originalVariantName, addToVusList) {
6262
var variantName = originalVariantName.trim().toLowerCase();
6363
var validMutation = true;
64-
var message = originalVariantName + ' ';
64+
var message = '';
6565
var mutationNameBlackList = [
6666
'activating mutations',
6767
'activating mutation',
@@ -70,18 +70,30 @@ angular.module('oncokbApp')
7070
];
7171
if (mutationNameBlackList.indexOf(variantName) !== -1) {
7272
validMutation = false;
73-
message += 'is a not allowed name!';
73+
message += 'is not allowed to be added. Forbidden name. Please use Oncogenic Mutations instead.';
7474
}
7575
if (validMutation) {
7676
_.some($scope.gene.mutations, function (mutation) {
77-
if (mutation.name.toLowerCase() === variantName) {
77+
var mutations = parseMutationString(mutation.name).map(function (alt) {
78+
return alt.alteration.toLowerCase();
79+
});
80+
if (mutations.includes(variantName)) {
7881
validMutation = false;
79-
if (mutation.name_review && mutation.name_review.removed === true) {
80-
message += 'just got removed, we will reuse the old one';
81-
delete mutation.name_review.removed;
82-
mainUtils.deleteUUID(mutation.name_uuid);
82+
if (addToVusList) {
83+
if (mutation.name_review && mutation.name_review.removed === true) {
84+
message += 'was previously removed from mutation list but hasn\'t been reviewed. We will continue adding it to the VUS list. However, if the deletion is rejected, it will also be deleted from the VUS list.';
85+
validMutation = true;
86+
} else {
87+
message += 'is in the mutation list. You cannot add to VUS list.';
88+
}
8389
} else {
84-
message += 'has already been added in the mutation section!';
90+
if (mutation.name_review && mutation.name_review.removed === true) {
91+
message += 'was removed but hasn\'t been reviewed. We will revert the deletion.';
92+
delete mutation.name_review.removed;
93+
mainUtils.deleteUUID(mutation.name_uuid);
94+
} else {
95+
message += 'is already in the mutation list.';
96+
}
8597
}
8698
return true;
8799
}
@@ -91,18 +103,18 @@ angular.module('oncokbApp')
91103
_.some($scope.vusItems, function (vusItem) {
92104
if (vusItem.name.toLowerCase() === variantName) {
93105
validMutation = false;
94-
message += 'has already been added in the VUS section!';
106+
message += 'is already in the VUS list.';
95107
return true;
96108
}
97109
});
98110
}
99-
if (!validMutation) {
100-
dialogs.notify('Warning', message);
111+
if (message) {
112+
dialogs.error('Error', originalVariantName + ' ' + message);
101113
}
102114
return validMutation;
103115
}
104116
$scope.addMutation = function (newMutationName) {
105-
if (isValidVariant(newMutationName)) {
117+
if (isValidVariant(newMutationName, false)) {
106118
var mutation = new FirebaseModel.Mutation(newMutationName);
107119
mutation.name_review = {
108120
updatedBy: $rootScope.me.name,
@@ -319,7 +331,6 @@ angular.module('oncokbApp')
319331
return item.trim();
320332
});
321333
var altResults = [];
322-
var proteinChange = '';
323334

324335
for (var i = 0; i < parts.length; i++) {
325336
if (!parts[i]) {
@@ -2595,7 +2606,7 @@ angular.module('oncokbApp')
25952606

25962607
$scope.addVUSItem = function (newVUSName) {
25972608
if (newVUSName) {
2598-
if (isValidVariant(newVUSName)) {
2609+
if (isValidVariant(newVUSName, true)) {
25992610
var vusItem = new FirebaseModel.VUSItem(newVUSName, $rootScope.me.name, $rootScope.me.email);
26002611
$scope.vusItems.$add(vusItem).then(function(variant) {
26012612
$scope.vusUpdate();
@@ -2607,7 +2618,7 @@ angular.module('oncokbApp')
26072618
$scope.editVUSItem = function(vusItem, newVUSName) {
26082619
var deferred = $q.defer();
26092620
if (newVUSName) {
2610-
if (isValidVariant(newVUSName)) {
2621+
if (isValidVariant(newVUSName,true)) {
26112622
var obj = $firebaseObject(firebase.database().ref('VUS/' + $routeParams.geneName + '/' + vusItem.$id));
26122623
obj.name = newVUSName;
26132624
obj.$save().then(function(ref) {
@@ -3012,6 +3023,17 @@ angular.module('oncokbApp')
30123023
cancelDeleteSection('tumor', mutation, tumor, ti, treatment);
30133024
}
30143025
});
3026+
3027+
// delete the same mutation from the VUS list
3028+
// (we allow the same mutation in the VUS list after deleting it from mutation list before reviewing)
3029+
var mutations = parseMutationString(mutation.name).map(function (alt) {
3030+
return alt.alteration.toLowerCase();
3031+
});
3032+
_.forEach($scope.vusItems, function (vusItem) {
3033+
if (mutations.includes(vusItem.name.toLowerCase())) {
3034+
$scope.removeVUS(vusItem);
3035+
}
3036+
});
30153037
break;
30163038
case 'tumor':
30173039
cancelDeleteItem(tumor.cancerTypes_review, $scope.getTumorUuids(tumor));

0 commit comments

Comments
 (0)