Skip to content

Commit

Permalink
Merge pull request #71 from agduncan94/develop
Browse files Browse the repository at this point in the history
Release 0.1.8
  • Loading branch information
agduncan94 authored Jul 27, 2020
2 parents e921554 + 20554d2 commit 9a6d302
Show file tree
Hide file tree
Showing 15 changed files with 437 additions and 133 deletions.
10 changes: 5 additions & 5 deletions cypress/integration/ExploreGDC.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ describe('Explore GDC', function() {
})

checkAllResultsTab(
['Showing 1 to 20 of 3,110', 'TCGA-A5-A1OF', 'TCGA-AJ-A3EK'],
['Showing 1 to 20 of 21,168', 'TP53', 'TTN'],
['Showing 1 to 20 of 120,824', 'chr2:g.208248388C>T', 'chr17:g.7673803G>A']
['Showing 1 to 20 of 3,111', 'TCGA-A5-A1OF', 'TCGA-AJ-A3EK'],
['Showing 1 to 20 of 21,169', 'TP53', 'TTN'],
['Showing 1 to 20 of 120,896', 'chr2:g.208248388C>T', 'chr17:g.7673803G>A']
)

// Select is cancer gene census - 1
Expand All @@ -131,9 +131,9 @@ describe('Explore GDC', function() {
})

checkAllResultsTab(
['Showing 1 to 20 of 364', 'TCGA-A5-A1OF', 'TCGA-AJ-A3EK'],
['Showing 1 to 20 of 365', 'TCGA-A5-A1OF', 'TCGA-AJ-A3EK'],
['Showing 1 to 20 of 575', 'TP53', 'PIK3CA'],
['Showing 1 to 20 of 5,949', 'chr7:g.140753336A>T', 'chr2:g.208248388C>T']
['Showing 1 to 20 of 5,952', 'chr7:g.140753336A>T', 'chr2:g.208248388C>T']
)

selectResultsTab(0)
Expand Down
2 changes: 1 addition & 1 deletion gdc-viewer/js/Model/GeneFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ get: function(name) {
}
fetch('https://api.gdc.cancer.gov/v0/graphql/projectsTable', {
method: 'post',
headers: { 'X-Requested-With': null },
headers: { 'X-Requested-With': null, 'Content-Type': 'application/json' },
body: JSON.stringify(bodyValProjectsTable)
}).then(function(response) {
return(response.json());
Expand Down
2 changes: 1 addition & 1 deletion gdc-viewer/js/Model/SSMFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ get: function(name) {
}
fetch('https://api.gdc.cancer.gov/v0/graphql/projectsTable', {
method: 'post',
headers: { 'X-Requested-With': null },
headers: { 'X-Requested-With': null, 'Content-Type': 'application/json' },
body: JSON.stringify(bodyValProjectsTable)
}).then(function(response) {
return(response.json());
Expand Down
114 changes: 114 additions & 0 deletions gdc-viewer/js/Store/SeqFeature/BaseBEDLikeFeature.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/**
* Base class for BEDlike files from the GDC
*/
define([
'dojo/_base/declare',
'dojo/_base/array',
'dojo/_base/lang',
'JBrowse/Store/SeqFeature/BED',
'./BedLikeParser',
'JBrowse/Store/SeqFeature',
'JBrowse/Model/XHRBlob',
'JBrowse/Model/BlobFilehandleWrapper'
],
function(
declare,
array,
lang,
BED,
Parser,
SeqFeatureStore,
XHRBlob,
BlobFilehandleWrapper
) {
return declare([ SeqFeatureStore, BED ], {
/**
* Constructor
* @param {*} args
*/
constructor: function (args) {
this.data = new BlobFilehandleWrapper(
new XHRBlob(
this.resolveUrl(
args.urlTemplate
)
)
);
},

_loadFeatures: function () {
var thisB = this;
var features = this.bareFeatures = [];

var featuresSorted = true;
var seenRefs = this.refSeqs = {};
var parser = new Parser(
{
featureCallback: function (fs) {
array.forEach(fs, function (feature) {
var prevFeature = features[ features.length - 1 ];
var regRefName = thisB.browser.regularizeReferenceName(feature.seq_id);
if (regRefName in seenRefs && prevFeature && prevFeature.seq_id != feature.seq_id) {featuresSorted = false;}
if (prevFeature && prevFeature.seq_id == feature.seq_id && feature.start < prevFeature.start) {featuresSorted = false;}

if (!(regRefName in seenRefs)) {seenRefs[ regRefName ] = features.length;}

if (thisB.config.featureCallback) {
features.push(thisB.config.featureCallback(feature, thisB));
} else {
features.push(feature);
}
});
},
endCallback: function () {
if (!featuresSorted) {
features.sort(thisB._compareFeatureData);
// need to rebuild the refseq index if changing the sort order
thisB._rebuildRefSeqs(features);
}

thisB._estimateGlobalStats()
.then(function (stats) {
thisB.globalStats = stats;
thisB._deferred.stats.resolve();
});

thisB._deferred.features.resolve(features);
},
commentCallback: (this.config.commentCallback || function (i) { }),
store: this
});

var fail = lang.hitch(this, '_failAllDeferred');
// parse the whole file and store it
let i = 0;
this.data.fetchLines(
function (line) {
try {
if (i == 0) {
parser.setExtraFields(line)
} else {
// Creates a line where the first columns are BED format and the remaining are extra metadata
parser.addLine(thisB.convertLineToBED(line));
}
i++;
} catch (e) {
fail('Error parsing ' + thisB.getName(), e);
throw e;
}
},
lang.hitch(parser, 'finish'),
fail
);
},

/**
* Stub for getParser
*/
getParser: function() {
return new Promise(function(resolve, reject) {
resolve({'getMetadata': function() {}});
});
},
});
});
59 changes: 59 additions & 0 deletions gdc-viewer/js/Store/SeqFeature/BedLikeParser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
define([
'dojo/_base/declare',
'dojo/_base/array',
'JBrowse/Store/SeqFeature/BED/Parser',
],
function (
declare,
array,
Parser
) {
var bed_feature_names = 'seq_id start end name score strand'.split(" ");
var extra_feature_names = []

return declare(Parser, {
setExtraFields: function(extraFields) {
extra_feature_names = extraFields.trim().split('\t')
},

parse_feature: function( line ) {
var f = array.map( line.split("\t"), function(a) {
if( a == '.' ) {
return null;
}
return a;
});

// unescape only the ref and source columns
f[0] = this.unescape( f[0] );

var parsed = {};
const combinedFeatures = bed_feature_names.concat(extra_feature_names)
for( var i = 0; i < combinedFeatures.length; i++ ) {
if(f[i]) {
parsed[ combinedFeatures[i].toLowerCase() ] = f[i] == '.' ? null : f[i];
}
}

if( parsed.start !== null )
parsed.start = parseInt( parsed.start, 10 );
if( parsed.end !== null )
parsed.end = parseInt( parsed.end, 10 );
if( parsed.score != null )
parsed.score = parseFloat( parsed.score, 10 );

parsed.strand = {'+':1,'-':-1}[parsed.strand] || 0;

return parsed;
},

unescape(s) {
if( s === null )
return null;

return s.replace( /%([0-9A-Fa-f]{2})/g, function( match, seq ) {
return String.fromCharCode( parseInt( seq, 16 ) );
});
},
});
});
2 changes: 1 addition & 1 deletion gdc-viewer/js/Store/SeqFeature/CNVs.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function(
// Fetch CNVs and create features
fetch(thisB.graphQLUrl + '/CNVsTable', {
method: 'post',
headers: { 'X-Requested-With': null },
headers: { 'X-Requested-With': null, 'Content-Type': 'application/json' },
body: bodyVal
}).then(function(response) {
return(response.json());
Expand Down
2 changes: 1 addition & 1 deletion gdc-viewer/js/Store/SeqFeature/Genes.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function(
// Fetch Genes and create features
fetch(thisB.graphQLUrl + '/GenesTable', {
method: 'post',
headers: { 'X-Requested-With': null },
headers: { 'X-Requested-With': null, 'Content-Type': 'application/json' },
body: bodyVal
}).then(function(response) {
return(response.json());
Expand Down
43 changes: 43 additions & 0 deletions gdc-viewer/js/Store/SeqFeature/IsoformExpressionQuantification.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* IsoformExpressionQuantification store class
* See https://docs.gdc.cancer.gov/Data/Bioinformatics_Pipelines/miRNA_Pipeline/#mirna-expression-workflow
*
* Supports (Data format, Data category, Data Type)
* * TSV, Transcriptome Profiling, Isoform Expression Quantification
* * TXT, Transcriptome Profiling, Isoform Expression Quantification
*/
define([
'dojo/_base/declare',
'./BaseBEDLikeFeature',
],
function (
declare,
BaseBEDLikeFeature
) {
return declare(BaseBEDLikeFeature, {
// Converts a non-BED file line to BED, and appends the original line to the end
convertLineToBED: function(line) {
originalLine = line.split('\t');
// Second column contains location in the format refseq:chr:start-end:strand
// This needs to be redistributed to form BED format
// Create BED line
featureLocation = originalLine[1];
splitLocation = featureLocation.split(':');
splitPos = splitLocation[2].split('-');
locationArray = [splitLocation[1].replace('chr', ''), splitPos[0], splitPos[1]];

bedLikeLine = locationArray;
bedLikeLine.push(originalLine[0]) // name
bedLikeLine.push(originalLine[2]) // score
bedLikeLine.push(splitLocation[3]) // strand

// Combine BED line and existing line
fullLine = bedLikeLine.concat(originalLine)
return fullLine.join('\t');
},

getName: function() {
return 'IsoformExpressionQuantification';
},
});
});
25 changes: 25 additions & 0 deletions gdc-viewer/js/Store/SeqFeature/SEG.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* SEG store class for CopyNumberSegment files
* Supports (Data format, Data category, Data Type)
* * TXT, Copy number variation, Copy number Segment
* * TXT, Copy number variation, Masked copy number Segment
* * TXT, Copy number variation, Allele-specific copy number Segment
*/
define([
'dojo/_base/declare',
'./BaseBEDLikeFeature',
],
function (
declare,
BaseBEDLikeFeature
) {
return declare(BaseBEDLikeFeature, {
convertLineToBED: function(line) {
return line = line.slice(line.indexOf('\t') + 1);
},

getName: function() {
return 'SEG'
}
});
});
2 changes: 1 addition & 1 deletion gdc-viewer/js/Store/SeqFeature/SimpleSomaticMutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ function(
// Fetch SSMs and create features
fetch(thisB.graphQLUrl + '/SsmsTable', {
method: 'post',
headers: { 'X-Requested-With': null },
headers: { 'X-Requested-With': null, 'Content-Type': 'application/json' },
body: bodyVal
}).then(function(response) {
return(response.json());
Expand Down
8 changes: 4 additions & 4 deletions gdc-viewer/js/View/GDCDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function (
// Update the accordions with results from the GDC
fetch(thisB.baseGraphQLUrl + '/facetResults', {
method: 'post',
headers: { 'X-Requested-With': null },
headers: { 'X-Requested-With': null, 'Content-Type': 'application/json' },
body: JSON.stringify(bodyVal)
}).then(function(response) {
return(response.json());
Expand Down Expand Up @@ -437,7 +437,7 @@ function (

fetch(url, {
method: 'post',
headers: { 'X-Requested-With': null },
headers: { 'X-Requested-With': null, 'Content-Type': 'application/json' },
body: JSON.stringify(bodyVal)
}).then(function(response) {
return(response.json());
Expand Down Expand Up @@ -549,7 +549,7 @@ function (

fetch(url, {
method: 'post',
headers: { 'X-Requested-With': null },
headers: { 'X-Requested-With': null, 'Content-Type': 'application/json' },
body: JSON.stringify(bodyVal)
}).then(function(response) {
return(response.json());
Expand Down Expand Up @@ -670,7 +670,7 @@ function (

fetch(url, {
method: 'post',
headers: { 'X-Requested-With': null },
headers: { 'X-Requested-With': null, 'Content-Type': 'application/json' },
body: JSON.stringify(bodyVal)
}).then(function(response) {
return(response.json());
Expand Down
2 changes: 1 addition & 1 deletion gdc-viewer/js/View/GDCPrimarySitesDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function (

fetch(thisB.baseGraphQLUrl + '/primarySites', {
method: 'post',
headers: { 'X-Requested-With': null },
headers: { 'X-Requested-With': null, 'Content-Type': 'application/json' },
body: JSON.stringify(bodyVal)
}).then(function(response) {
return(response.json());
Expand Down
2 changes: 1 addition & 1 deletion gdc-viewer/js/View/GDCProjectDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function (

fetch(url, {
method: 'post',
headers: { 'X-Requested-With': null },
headers: { 'X-Requested-With': null, 'Content-Type': 'application/json' },
body: JSON.stringify(bodyVal)
}).then(function(response) {
return(response.json());
Expand Down
Loading

0 comments on commit 9a6d302

Please sign in to comment.