Skip to content

Commit

Permalink
added official gene set ui pieces (#2282)
Browse files Browse the repository at this point in the history
* added official gene set ui pieces

* only admin

* added log notes

* adds and removes on server properly

* properly being pulled from the server

* pulling out of the backend properly now

* note is being copied up

* fixed integration test

* still working on detecting feature track

* fixed menu item

* fixed unnecessary branch statements

* fixes viewing annotation panel

* works with all types now when editing

* thanks are all working properlyish now

* I think its propagating properly for all bugs, but have to double check

* looks less hideous

* moved it so its not wrapped

* added official set of stuff

* had to add description

* fixed a pretty bad error

* fixed problem with one-level

* removing and updating logging
  • Loading branch information
nathandunn authored Feb 4, 2020
1 parent 0b6d0f6 commit f64e906
Show file tree
Hide file tree
Showing 20 changed files with 380 additions and 254 deletions.
73 changes: 48 additions & 25 deletions client/apollo/js/JSONUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ define([ 'dojo/_base/declare',
function JSONUtils() {
}

JSONUtils.verbose_conversion = false ;
JSONUtils.verbose_conversion = false;
JSONUtils.variantTypes = [ "SNV", "SNP", "MNV", "MNP", "INDEL", "SUBSTITUTION", "INSERTION", "DELETION" ];
JSONUtils.regulatorTypes = [ "TERMINATOR" ];

Expand Down Expand Up @@ -167,7 +167,7 @@ JSONUtils.makeSimpleFeature = function(feature, parent) {
var ftags = feature.tags();
for (var tindex = 0; tindex < ftags.length; tindex++) {
var tag = ftags[tindex];
// forcing lower case, since still having case issues with NCList features
// forcing lower case, since still having case issues with NCList features
result.set(tag.toLowerCase(), feature.get(tag.toLowerCase()));
}
var subfeats = feature.get('subfeatures');
Expand Down Expand Up @@ -324,6 +324,26 @@ JSONUtils.getPreferredSubFeature = function(type,test_feature){
return null ;
};

function copyOfficialData(fromFeature,toFeature){
for(var key of Object.keys(fromFeature.data)) {
// var key = fromFeature.data[keyIndex];
// toFeature[key] = fromFeature.data[key];
if (key.toLowerCase() === 'note' || key.toLowerCase() === 'description') {
toFeature['description'] = fromFeature.data[key];
}
// else{
// toFeature[key] = fromFeature.data[key];
// }
// this is set for the output GFF3
// if(key === 'source'){
// toFeature['source'] = fromFeature.data[key];
// }
}


return toFeature;
}

/**
* creates a feature in ApolloEditorService JSON format
* takes as argument:
Expand Down Expand Up @@ -352,14 +372,14 @@ JSONUtils.getPreferredSubFeature = function(type,test_feature){
* ignoring JBrowse ID / name fields for now
* currently, for features with lazy-loaded children, ignores children
*/
JSONUtils.createApolloFeature = function( jfeature, specified_type, useName, specified_subtype ) {
JSONUtils.createApolloFeature = function( jfeature, specified_type, useName, specified_subtype ,is_official) {
var official = is_official === undefined ? false : is_official;
var diagnose = (JSONUtils.verbose_conversion && jfeature.children() && jfeature.children().length > 0);
if (diagnose) {
if (diagnose || true) {
console.log("converting JBrowse feature to Apollo feture, specified type: " + specified_type + " " + specified_subtype);
console.log(jfeature);
console.log(jfeature,JSON.stringify(jfeature));
}


var afeature = {};
var astrand;
// Apollo feature strand must be an integer
Expand All @@ -386,7 +406,7 @@ JSONUtils.createApolloFeature = function( jfeature, specified_type, useName, spe
typename = specified_type;
var preferredSubFeature = this.getPreferredSubFeature(specified_type,jfeature);
if(preferredSubFeature){
return this.createApolloFeature(preferredSubFeature,specified_type,useName,specified_subtype)
return this.createApolloFeature(preferredSubFeature,specified_type,useName,specified_subtype,official)
}
}
else
Expand Down Expand Up @@ -416,18 +436,23 @@ JSONUtils.createApolloFeature = function( jfeature, specified_type, useName, spe
}
afeature.orig_id = id ;

/*
afeature.properties = [];
var property = { value : "source_id=" + jfeature.get('id'),
type : {
cv: {
name: "feature_property"
},
name: "feature_property"
}
};
afeature.properties.push(property);
*/
// add all other properties if there
if(official){
copyOfficialData(jfeature,afeature);
}

/*
afeature.properties = [];
var property = { value : "source_id=" + jfeature.get('id'),
type : {
cv: {
name: "feature_property"
},
name: "feature_property"
}
};
afeature.properties.push(property);
*/

if (diagnose) { console.log("converting to Apollo feature: " + typename); }
var subfeats;
Expand Down Expand Up @@ -514,18 +539,18 @@ JSONUtils.createApolloFeature = function( jfeature, specified_type, useName, spe
foundExons = true;
}
if (converted_subtype) {
afeature.children.push( JSONUtils.createApolloFeature( subfeat, converted_subtype ) );
afeature.children.push( JSONUtils.createApolloFeature( subfeat, converted_subtype , official) );
if (diagnose) { console.log(" subfeat original type: " + subtype + ", converted type: " + converted_subtype); }
}
else {
if (diagnose) { console.log(" edited out subfeature, type: " + subtype); }
}
}
if (cds) {
afeature.children.push( JSONUtils.createApolloFeature( cds, "CDS"));
afeature.children.push( JSONUtils.createApolloFeature( cds, "CDS",official));
if (!foundExons) {
for (var i = 0; i < cdsFeatures.length; ++i) {
afeature.children.push(JSONUtils.createApolloFeature(cdsFeatures[i], "exon"));
afeature.children.push(JSONUtils.createApolloFeature(cdsFeatures[i], "exon",official));
}
}
}
Expand All @@ -539,7 +564,7 @@ JSONUtils.createApolloFeature = function( jfeature, specified_type, useName, spe
fake_exon.set('end', jfeature.get('end'));
fake_exon.set('strand', jfeature.get('strand'));
fake_exon.set('type', 'exon');
afeature.children = [ JSONUtils.createApolloFeature( fake_exon ) ];
afeature.children = [ JSONUtils.createApolloFeature( fake_exon , undefined,official) ];
}
if (diagnose) { console.log("result:"); console.log(afeature); }
return afeature;
Expand Down Expand Up @@ -678,7 +703,6 @@ JSONUtils.createApolloVariant = function( feat, useName ) {
}

afeature.variant_info = metadata;
console.log("created Apollo feature: ", afeature);
return afeature;
};

Expand Down Expand Up @@ -712,7 +736,6 @@ JSONUtils.classifyVariant = function( refAllele, altAlleles, fmin, fmax ) {
type = "deletion"
}
}
console.log("variant type inferred: ", type);
return type;
};

Expand Down
Loading

0 comments on commit f64e906

Please sign in to comment.