-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from agduncan94/develop
Release 0.1.8
- Loading branch information
Showing
15 changed files
with
437 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {}}); | ||
}); | ||
}, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ) ); | ||
}); | ||
}, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
gdc-viewer/js/Store/SeqFeature/IsoformExpressionQuantification.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
}, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.