Skip to content

Commit

Permalink
Merge c382400 into 7b2031d
Browse files Browse the repository at this point in the history
  • Loading branch information
nathandunn committed Apr 24, 2019
2 parents 7b2031d + c382400 commit 452a547
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 147 deletions.
220 changes: 82 additions & 138 deletions client/apollo/js/View/Track/AnnotTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -1160,9 +1160,9 @@ define([
// TODO: pull from the server at some point
// TODO: this list is duplicated
var recognizedBioType = [
'transcript' ,'tRNA','snRNA','snoRNA','ncRNA','rRNA','mRNA','miRNA','repeat_region','transposable_element','terminator','Shine_Dalgarno_sequence'
'transcript' ,'tRNA','snRNA','snoRNA','ncRNA','rRNA','mRNA','miRNA','repeat_region','transposable_element','terminator'
];
var strandedOneLevelTypes = ['terminator','Shine_Dalgarno_sequence'];
var strandedOneLevelTypes = ['terminator'];

if(force_type) {
biotype = featureToAdd.get('type');
Expand Down Expand Up @@ -1363,8 +1363,6 @@ define([
},

createGenericOneLevelAnnotations: function (feats, type, strandless) {


var target_track = this;
var featuresToAdd = new Array();
var parentFeatures = new Object();
Expand Down Expand Up @@ -1751,6 +1749,40 @@ define([
},


/**
* allow removal for
*/
removeVariantEffect: function(){
var track = this;
var trackName = this.getUniqueTrackName();
var selected = this.selectionManager.getSelection();
console.log('selected',selected);
// var feature = selected[0].feature ;
// var location = feature.afeature.location ;
// var variant_type = feature.data.type;
console.log('feature to remove variant from',selected);
var featureUniqueName;
if (selected[0].feature.parent()) {
//selected is an exon, get its parent
var parent = selected[0].feature.parent();
featureUniqueName = parent.afeature.uniquename;
}
else {
featureUniqueName = selected[0].feature.afeature.uniquename;
}

var features = [featureUniqueName];
var postData = {
"track": trackName,
"features": features,
"operation": "remove_variant_effect",
"clientToken": track.getClientToken()
};
this.selectionManager.clearSelection();
track.executeUpdateOperation(JSON.stringify(postData));
track.changed();
},

viewVariantEffect: function() {
var track = this;
var trackName = this.getUniqueTrackName();
Expand Down Expand Up @@ -2314,16 +2346,11 @@ define([

changeAnnotationType: function(type) {
var selected = this.selectionManager.getSelection();
console.log('c')
if (selected[0].feature.afeature.type.name === type) {
console.log('d')
this.alertAnnotationType(selected[0], type);
console.log('d.1')
}
else {
console.log('e')
this.changeAnnotations(selected[0], type);
console.log('f')
this.selectionManager.clearSelection();
}
},
Expand Down Expand Up @@ -6843,7 +6870,7 @@ define([
initAnnotContextMenu: function () {

// TODO: this list is duplicated
var topTypes = ['repeat_region','transposable_element','gene','pseudogene', 'SNV', 'SNP', 'MNV', 'MNP', 'indel', 'insertion', 'deletion','terminator','Shine_Dalgarno_sequence'];
var topTypes = ['repeat_region','transposable_element','gene','pseudogene', 'SNV', 'SNP', 'MNV', 'MNP', 'indel', 'insertion', 'deletion','terminator'];

var thisB = this;
contextMenuItems = new Array();
Expand Down Expand Up @@ -6976,13 +7003,12 @@ define([
}
}));
changeAnnotationMenu.addChild(new dijitMenuItem( {
label: "Terminator",
onClick: function(event) {
console.log('selecting terminator')
label: "terminator",
onclick: function(event) {
var selected = thisB.selectionManager.getSelection();
var selectedFeatureType = selected[0].feature.afeature.type.name === "exon" ?
selected[0].feature.afeature.parent_type.name : selected[0].feature.afeature.type.name;
if (selectedFeatureType != "transposable_element" && selectedFeatureType != "repeat_region" && selectedFeatureType != "Shine_Dalgarno_sequence") {
if (selectedFeatureType != "transposable_element" && selectedFeatureType != "repeat_region") {
var message = "Warning: You will not be able to revert back to " + selectedFeatureType + " via 'Change annotation type' menu option, use 'Undo' instead. Do you want to proceed?";
thisB.confirmChangeAnnotationType(thisB, [selected], "terminator", message);
}
Expand All @@ -6992,34 +7018,12 @@ define([
}
}));
changeAnnotationMenu.addChild(new dijitMenuItem( {
label: "Shine Dalgarno sequence",
onClick: function(event) {
console.log('selecging shinging the dalgarno')
var selected = thisB.selectionManager.getSelection();
var selectedFeatureType = selected[0].feature.afeature.type.name === "exon" ?
selected[0].feature.afeature.parent_type.name : selected[0].feature.afeature.type.name;
console.log('sel feat type',selectedFeatureType)
if (selectedFeatureType != "transposable_element" && selectedFeatureType != "repeat_region" && selectedFeatureType != "terminator") {
var message = "Warning: You will not be able to revert back to " + selectedFeatureType + " via 'Change annotation type' menu option, use 'Undo' instead. Do you want to proceed?";
console.log('a')
thisB.confirmChangeAnnotationType(thisB, [selected], "Shine_Dalgarno_sequence", message);
console.log('a.1')
}
else {
console.log('b')
thisB.changeAnnotationType("Shine_Dalgarno_sequence");
console.log('b.1')
}
}
}));
changeAnnotationMenu.addChild(new dijitMenuItem( {
label: "Repeat region",
label: "repeat_region",
onClick: function(event) {
console.log('selecting repeat region')
var selected = thisB.selectionManager.getSelection();
var selectedFeatureType = selected[0].feature.afeature.type.name === "exon" ?
selected[0].feature.afeature.parent_type.name : selected[0].feature.afeature.type.name;
if (selectedFeatureType != "transposable_element" && selectedFeatureType != "terminator" && selectedFeatureType != "Shine_Dalgarno_sequence" ) {
if (selectedFeatureType != "transposable_element" && selectedFeatureType != "terminator" ) {
var message = "Warning: You will not be able to revert back to " + selectedFeatureType + " via 'Change annotation type' menu option, use 'Undo' instead. Do you want to proceed?";
thisB.confirmChangeAnnotationType(thisB, [selected], "repeat_region", message);
}
Expand All @@ -7029,13 +7033,12 @@ define([
}
}));
changeAnnotationMenu.addChild(new dijitMenuItem( {
label: "Transposable element",
label: "transposable_element",
onClick: function(event) {
console.log('selecting transp elements')
var selected = thisB.selectionManager.getSelection();
var selectedFeatureType = selected[0].feature.afeature.type.name === "exon" ?
selected[0].feature.afeature.parent_type.name : selected[0].feature.afeature.type.name;
if (selectedFeatureType != "repeat_region" && selectedFeatureType != "terminator" && selectedFeatureType != "Shine_Dalgarno_sequence") {
if (selectedFeatureType != "repeat_region" && selectedFeatureType != "terminator") {
var message = "Warning: You will not be able to revert back to " + selectedFeatureType + " via 'Change annotation type' menu option, use 'Undo' instead. Do you want to proceed?";
thisB.confirmChangeAnnotationType(thisB, [selected], "transposable_element", message);
}
Expand Down Expand Up @@ -7076,24 +7079,6 @@ define([
annot_context_menu.addChild(dissociateTranscriptToGeneItem);
contextMenuItems["dissociate_transcript_from_gene"] = index++;

var associateFeatureToGeneItem = new dijit.MenuItem({
label: "Associate Feature to Gene",
onClick: function () {
thisB.associateFeatureToGene();
}
});
annot_context_menu.addChild(associateFeatureToGeneItem);
contextMenuItems["associate_feature_to_gene"] = index++;

var dissociateFeatureToGeneItem = new dijit.MenuItem({
label: "Dissociate Feature from Gene",
onClick: function () {
thisB.dissociateFeatureFromGene();
}
});
annot_context_menu.addChild(dissociateFeatureToGeneItem);
contextMenuItems["dissociate_feature_from_gene"] = index++;

annot_context_menu.addChild(new dijit.MenuSeparator());
index++;

Expand All @@ -7106,6 +7091,15 @@ define([
annot_context_menu.addChild(viewVariantEffect);
contextMenuItems["view_variant_effect"] = index++;

var removeVariantEffect = new dijit.MenuItem({
label: "Remove Variant Effects",
onClick: function () {
thisB.removeVariantEffect();
}
});
annot_context_menu.addChild(removeVariantEffect);
contextMenuItems["remove_variant_effect"] = index++;

annot_context_menu.addChild(new dijit.MenuSeparator());
index++;

Expand Down Expand Up @@ -7519,9 +7513,8 @@ define([
this.updateRemoveCDSMenuItem();
this.updateAssociateTranscriptToGeneItem();
this.updateDissociateTranscriptFromGeneItem();
this.updateAssociateFeatureToGeneItem();
this.updateDissociateFeatureFromGeneItem();
this.updateViewVariantEffect();
this.updateRemoveVariantEffect();
this.updateSetReadthroughStopCodonMenuItem();
this.updateMergeMenuItem();
this.updateSplitMenuItem();
Expand Down Expand Up @@ -7584,49 +7577,6 @@ define([
}
},


updateAssociateFeatureToGeneItem: function() {
var menuItem = this.getMenuItem("associate_feature_to_gene");
var selected = this.selectionManager.getSelection();
var currentType = selected[0].feature.get('type');
if (selected.length != 2) {
menuItem.set("disabled", true);
return;
}
if (JSONUtils.variantTypes.includes(currentType.toUpperCase())) {
menuItem.set("disabled", true);
return;
}
for (var i = 0; i < selected.length; ++i) {
if (!this.canEdit(selected[i].feature)) {
menuItem.set("disabled", true);
return;
}
}

if (AnnotTrack.getTopLevelAnnotation(selected[0].feature).data.parent_id === AnnotTrack.getTopLevelAnnotation(selected[1].feature).data.parent_id) {
menuItem.set("disabled", true);
return;
}

if (JSONUtils.checkForComment(AnnotTrack.getTopLevelAnnotation(selected[0].feature), JSONUtils.MANUALLY_ASSOCIATE_FEATURE_TO_GENE)
|| JSONUtils.checkForComment(AnnotTrack.getTopLevelAnnotation(selected[1].feature), JSONUtils.MANUALLY_ASSOCIATE_FEATURE_TO_GENE)) {
menuItem.set("disabled", true);
return;
}

// TODO: if one is a parent gene and the other is a regulator, then it is not disabled, otherwise it is disabled


// if (JSONUtils.overlaps(selected[0].feature, selected[1].feature)) {
// menuItem.set("disabled", false);
// }
// else {
// menuItem.set("disabled", true);
// }
menuItem.set("disabled", false);
},

/**
* TODO, scale to multiple, just one for right now
*/
Expand All @@ -7644,55 +7594,45 @@ define([
}
},

updateDissociateTranscriptFromGeneItem: function() {
var menuItem = this.getMenuItem("dissociate_transcript_from_gene");
/**
* TODO, scale to multiple, just one for right now
*/
updateRemoveVariantEffect: function(){
var menuItem = this.getMenuItem("remove_variant_effect");
var selected = this.selectionManager.getSelection();
if (selected.length != 1) {
menuItem.set("disabled", true);
return;
}
var currentType = selected[0].feature.get('type');
if (JSONUtils.variantTypes.includes(currentType.toUpperCase()) || JSONUtils.regulatorTypes.includes(currentType.toUpperCase())) {
menuItem.set("disabled", true);
return;
}
if (!this.canEdit(selected[0].feature)) {
menuItem.set("disabled", true);
return;
}
if (JSONUtils.checkForComment(AnnotTrack.getTopLevelAnnotation(selected[0].feature), JSONUtils.MANUALLY_DISSOCIATE_TRANSCRIPT_FROM_GENE)) {
menuItem.set("disabled", true);
menuItem.set("disabled", true);
if (selected.length === 0) {
return;
}

// var currentType = selected[0].feature.get('type');
// if (JSONUtils.variantTypes.includes(currentType.toUpperCase())) {
// // TODO: search for sequence alterations in that space?
menuItem.set("disabled", false);
// }
},

updateDissociateFeatureFromGeneItem: function() {
var menuItem = this.getMenuItem("dissociate_feature_from_gene");
updateDissociateTranscriptFromGeneItem: function() {
var menuItem = this.getMenuItem("dissociate_transcript_from_gene");
var selected = this.selectionManager.getSelection();
if (selected.length != 1) {
menuItem.set("disabled", true);
return;
}
var currentType = selected[0].feature.get('type');
if (!JSONUtils.regulatorTypes.includes(currentType.toUpperCase())) {
if (JSONUtils.variantTypes.includes(currentType.toUpperCase()) || JSONUtils.regulatorTypes.includes(currentType.toUpperCase())) {
menuItem.set("disabled", true);
return;
}
if (!this.canEdit(selected[0].feature)) {
menuItem.set("disabled", true);
return;
}
if (JSONUtils.checkForComment(AnnotTrack.getTopLevelAnnotation(selected[0].feature), JSONUtils.MANUALLY_DISSOCIATE_FEATURE_FROM_GENE)) {
if (JSONUtils.checkForComment(AnnotTrack.getTopLevelAnnotation(selected[0].feature), JSONUtils.MANUALLY_DISSOCIATE_TRANSCRIPT_FROM_GENE)) {
menuItem.set("disabled", true);
return;
}
menuItem.set("disabled", false);
},

isSingleFeatureLabel:function(label){
return (label === "Transposable element" || label === "Terminator" || label === "Shine Dalgarno sequence" || label === "Repeat region" ) ;
menuItem.set("disabled", false);
},

updateChangeAnnotationTypeMenu: function(changeAnnotationMenu) {
Expand Down Expand Up @@ -7726,17 +7666,21 @@ define([
menuItems[i].setDisabled(false);
}
}
else if (selectedType === "terminator") {
menuItems[i].setDisabled(!this.isSingleFeatureLabel(menuItems[i].label));
}
else if (selectedType === "Shine_Dalgarno_sequence") {
menuItems[i].setDisabled(!this.isSingleFeatureLabel(menuItems[i].label));
}
else if (selectedType === "repeat_region") {
menuItems[i].setDisabled(!this.isSingleFeatureLabel(menuItems[i].label));
if (menuItems[i].label === "transposable_element") {
menuItems[i].setDisabled(false);
}
else {
menuItems[i].setDisabled(true);
}
}
else if (selectedType === "transposable_element") {
menuItems[i].setDisabled(!this.isSingleFeatureLabel(menuItems[i].label));
if (menuItems[i].label === "repeat_region") {
menuItems[i].setDisabled(false);
}
else {
menuItems[i].setDisabled(true);
}
}
else if (JSONUtils.variantTypes.includes(selectedType.toUpperCase())) {
menuItems[i].setDisabled(true);
Expand Down

0 comments on commit 452a547

Please sign in to comment.