Skip to content

Commit

Permalink
fixes subfeature annotation (#2070)
Browse files Browse the repository at this point in the history
* seems to fix the problem for all types

* removed logging
  • Loading branch information
nathandunn committed Feb 26, 2019
1 parent f0438cf commit 9b35abf
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions client/apollo/js/JSONUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,22 @@ JSONUtils.generateSubFeaturesFromCigar = function(feature){
return feature;
};

JSONUtils.getPreferredSubFeature = function(type,test_feature){
if (JSONUtils.verbose_conversion) {
console.log('parent type',type,'subfeature type',test_feature.get('type'))
}
if( (type==='mRNA' && test_feature.get('type')==='gene')
|| (type.endsWith('RNA') && test_feature.get('type').endsWith('gene') )
|| (type.endsWith('transcript') && test_feature.get('type').endsWith('gene') )
){
var subfeatures = test_feature.get('subfeatures');
if(subfeatures && subfeatures.length===1){
return subfeatures[0];
}
}
return null ;
};

/**
* creates a feature in ApolloEditorService JSON format
* takes as argument:
Expand Down Expand Up @@ -298,10 +314,11 @@ JSONUtils.generateSubFeaturesFromCigar = function(feature){
JSONUtils.createApolloFeature = function( jfeature, specified_type, useName, specified_subtype ) {
var diagnose = (JSONUtils.verbose_conversion && jfeature.children() && jfeature.children().length > 0);
if (diagnose) {
console.log("converting JBrowse feature to Apollo feture, specified type: " + specified_type);
console.log("converting JBrowse feature to Apollo feture, specified type: " + specified_type + " " + specified_subtype);
console.log(jfeature);
}


var afeature = {};
var astrand;
// Apollo feature strand must be an integer
Expand All @@ -326,18 +343,23 @@ JSONUtils.createApolloFeature = function( jfeature, specified_type, useName, spe
var typename;
if (specified_type) {
typename = specified_type;
var preferredSubFeature = this.getPreferredSubFeature(specified_type,jfeature);
if(preferredSubFeature){
return this.createApolloFeature(preferredSubFeature,specified_type,useName,specified_subtype)
}
}
else if ( jfeature.get('type') ) {
else
if ( jfeature.get('type') ) {
typename = jfeature.get('type');
}

if (typename) {
afeature.type = {
"cv": {
"name": "sequence"
}
};
afeature.type.name = typename;
"name": "sequence"
}
};
afeature.type.name = typename;
}

// if (useName && name) {
Expand Down

0 comments on commit 9b35abf

Please sign in to comment.