From f875d645ab2a67397bc01fceafee64960c015bc1 Mon Sep 17 00:00:00 2001 From: Nathan Dunn Date: Fri, 8 Feb 2019 20:49:39 -0800 Subject: [PATCH] looks correct, but need to fix the subfeature rendering --- client/apollo/js/JSONUtils.js | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/client/apollo/js/JSONUtils.js b/client/apollo/js/JSONUtils.js index e6de1fa5be..182d961fd6 100644 --- a/client/apollo/js/JSONUtils.js +++ b/client/apollo/js/JSONUtils.js @@ -225,21 +225,40 @@ JSONUtils.parseCigar = function( cigar ) { * Generate exon subfeatures only from M vs N. * @param feature */ -JSONUtils.generateSubFeaturesFromCigar = function(feature){ +JSONUtils.generateFeaturesFromCigar = function(feature){ var cigarData = feature.data.cigar ; + var baseObject = new Object(); + // 12M3N5M9N4M // split Cigar var ops = this.parseCigar(cigarData); var currOffset = 0; - var mismatches = []; + // var mismatches = []; + // {"track":"ctgA","features":[{"location":{"fmin":17399,"fmax":23000,"strand":1},"type":{"cv":{"name":"sequence"},"name":"mRNA"},"name":"Apple3","children":[{"location":{"fmin":17999,"fmax":21200,"strand":1},"type":{"cv":{"name":"sequence"},"name":"CDS"}},{"location":{"fmin":20999,"fmax":21200,"strand":1},"type":{"cv":{"name":"sequence"},"name":"exon"}},{"location":{"fmin":18999,"fmax":19500,"strand":1},"type":{"cv":{"name":"sequence"},"name":"exon"}},{"location":{"fmin":17999,"fmax":18800,"strand":1},"type":{"cv":{"name":"sequence"},"name":"exon"}}]}],"operation":"add_transcript","clientToken":"85401581821119996091324637603"} + // feature.children = feature.children ? feature.children : []; + console.log('childrens: '+feature.children); + console.log('subfeatures: ' + feature.subfeature) + // feature.children = feature.children ? feature.children : []; + feature.subfeatures = []; + baseObject.children= []; array.forEach( ops, function( oprec ) { var op = oprec[0]; var len = oprec[1]; if( op === 'M' || op === '=' || op === 'E' ) { // TODO: create an exon subfeature for each - - } + // add subfeature + + var exon = new SimpleFeature({parent: feature}); + exon.set('start', currOffset); + exon.set('end', currOffset + len); + exon.set('strand', feature.strand); + exon.set('type', 'exon'); + feature.subfeatures.push(JSONUtils.createApolloFeature(exon, "exon")); + baseObject.children.push(JSONUtils.createApolloFeature(exon, "exon")); + + } + currOffset = currOffset + len ; // if( op == 'I' ) // // GAH: shouldn't length of insertion really by 0, since JBrowse internally uses zero-interbase coordinates? // mismatches.push( { start: currOffset, type: 'insertion', base: ''+len, length: 1 }); @@ -256,6 +275,7 @@ JSONUtils.generateSubFeaturesFromCigar = function(feature){ // if( op != 'I' && op != 'S' && op != 'H' ) currOffset += len; }); + console.log('output',feature,baseObject) return feature ; };