Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var sizes = GenomePlot.chromosomes[ d.toString() ];
// the space between adjacent chroms
var space = GenomePlot.MAX_CHROMOSOME_BASE - sizes.chromSizeLeft - sizes.chromSizeRight;
return GenomePlot.linearGenomicToPaddedPixelScaleX( sizes.chromSizeLeft + space/2 ).toFixed(GenomePlot.FLOAT_PRECISION);
} )
.attr( "y1", function( d ) { return GenomePlot.linearWindowPixelToPaddedPixelScaleY( (d === 23 ? 12 : (d-1)) * GenomePlot.pixelsPerLine ).toFixed(GenomePlot.FLOAT_PRECISION); } )
.attr( "y2", function( d ) { return GenomePlot.linearWindowPixelToPaddedPixelScaleY( (d === 23 ? 13 : (d)) * GenomePlot.pixelsPerLine ).toFixed(GenomePlot.FLOAT_PRECISION); } )
;
divs.exit().remove();
}
var endTime = performance.now();
if( GenomePlot.debug ) console.info( sprintf( "%-20s duration: %.4f seconds", "drawVerticalDividers():", ((endTime-startTime)/1000) ) );
} // drawVerticalDividers
.done (function () {
GenomePlot.matepairDataStartTime = performance.now();
console.info( sprintf( "%-20s Started loading Mate Pair data file: %s at %.4fms", "initData():", GenomePlot.matepairDataFile, GenomePlot.matepairDataStartTime ) );
// load pipeline file, synchronously
GenomePlot.matepairData = $.ajaxJSONSync (GenomePlot.matepairDataFile);
var endTime = performance.now();
console.info( sprintf( "%-20s Finished loading Mate Pair data file: %s at %.4fms (duration: %.4f seconds)", "initData():", GenomePlot.matepairDataFile, endTime, ( ( endTime - GenomePlot.matepairDataStartTime ) / 1000 ) ) );
// initGUI should be initialized
if( GenomePlot.matepairData === undefined || GenomePlot.matepairData === null
|| GenomePlot.gui === undefined )
return;
// change the file paths to be relative to the directory the files were copied to
for( var record in GenomePlot.matepairData ) {
if( typeof GenomePlot.matepairData[record] !== "string" )
continue;
GenomePlot.matepairData[record] =
GenomePlot.prefixFile + "/" + GenomePlot.matepairData[record].basename();
}
GenomePlot.copyNumber30000DataFile = GenomePlot.matepairData["cnvBinned30KJson"];
.call( GenomePlot.axisY_R );
// fix the resulting text
yAxisNode_R.selectAll("text")
.style( {
"stroke": "none",
"fill": "black",
"cursor": "pointer",
} )
.each( vCenter( GenomePlot.scale * GenomePlot.pixelsPerLine ) )
.each( hCenter( GenomePlot.margin.right - 5, 1 ) )
;
}
var endTime = performance.now();
if( GenomePlot.debug ) console.info( sprintf( "%-20s duration: %.4f seconds", "drawAxis():", ((endTime-startTime)/1000) ) );
}; // drawAxis
console.error( sprintf( "%-20s Rejected loading Cytoband file: %s with %s at %.4fms (duration: %.4f seconds)", "initData():", GenomePlot.cytoBandFile, value, endTime, ( ( endTime - GenomePlot.cytoBandDataStartTime ) / 1000 ) ) );
},
function( error ) {
console.error( sprintf( "%-20s Failed to load Cytoband file: %s with %s", "initData():", GenomePlot.cytoBandFile, error ) );
}
);
} )
.fail (function () {
console.error( sprintf( "%-18s Failed to find Cytoband file: %s", "initData():", GenomePlot.cytoBandFile ) );
} );
}
// load alterations data
GenomePlot.alterationsData = undefined;
if( GenomePlot.alterationsDataFile === undefined ) {
console.error( sprintf( "%-18s Undefined Alterations file", "initData():" ) );
}
else {
$.ajaxFileExists (GenomePlot.alterationsDataFile)
.done (function () {
GenomePlot.alterationsDataStartTime = performance.now();
console.info( sprintf( "%-20s Started loading Alterations file: %s at %.4fms", "initData():", GenomePlot.alterationsDataFile, GenomePlot.alterationsDataStartTime ) );
GenomePlot.loadedResources++;
d3.text( GenomePlot.alterationsDataFile, "text/csv", function( data )
{
var endTime = performance.now();
console.info( sprintf( "%-20s Finished loading Alterations file: %s at %.4fms (duration: %.4f seconds)", "initData():", GenomePlot.alterationsDataFile, endTime, ( ( endTime - GenomePlot.alterationsDataStartTime ) / 1000 ) ) );
GenomePlot.loadedResources--;
GenomePlot.alterationsData = GenomePlot.processAlterationsData(data);
for( var j = 0; j < maskedIndicesRanges.length; j++ )
{
GenomePlot.copyNumber30000Data.toLegacy.wdnsMaskedPerChrom[ chrom_id ]
.push( GenomePlot.copyNumber30000Data.toLegacy.wdnsPerChrom[ chrom_id ][ maskedIndicesRanges[ j ] ] );
}
// do the same for the end of the chrom. if the last point does not match the expected value it is masked
// add it directly to the array
if( GenomePlot.copyNumber30000Data.toLegacy.wdnsPerChrom[ chrom_id ][ GenomePlot.copyNumber30000Data.toLegacy.wdnsPerChrom[ chrom_id ].length - 1 ] !== (chromosomeEnds - chromosomeStarts) * GenomePlot.copyNumber30000Data.windowSize ) {
GenomePlot.copyNumber30000Data.toLegacy.wdnsMaskedPerChrom[ chrom_id ]
.push( GenomePlot.copyNumber30000Data.toLegacy.wdnsPerChrom[ chrom_id ][ GenomePlot.copyNumber30000Data.toLegacy.wdnsPerChrom[ chrom_id ].length - 1 ],
GenomePlot.chromosomes[ (chrom_id+1).toString() ].genomicSize ); // instead of pushing (chromosomeEnds - chromosomeStarts) * GenomePlot.copyNumber30000Data.windowSize push the actual chrom end since we now we are at the end of the chromosome
}
}
console.info( sprintf( "%-20s Total CNV elements to draw: %s", "initData():", frqCnt.toLocaleString() ) );
// for the garbage collector
GenomePlot.copyNumber30000Data.cnv = null;
GenomePlot.copyNumber30000Data.normalCnv = null;
GenomePlot.copyNumber30000Data.toLegacy.wdns = null;
GenomePlot.copyNumber30000Data.toLegacy.frq = null;
frqGreaterTwoPerChrom = null;
maskedIndicesArray = null;
maskedIndicesRanges = null;
}; // processCopyNumber30000Data
GenomePlot.computeChromosomeStartPositions = function ()
{
if( GenomePlot.graphTypeParams.graphType === "U-Shape" )
{
// initialize it every time the function runs; garbage collection will take care of the memory
GenomePlot.chromPixelStarts = new Array( GenomePlot.NUM_CHROMS );
GenomePlot.linesPerGraph = 13;
// height in pixels of one line holding one chromosome (or two)
GenomePlot.pixelsPerLine = GenomePlot.innerHeight / GenomePlot.linesPerGraph;
if (GenomePlot.debug) console.log (sprintf ("%-20s pixels/line: %f", "computeChromosomeStartPositions():", GenomePlot.pixelsPerLine));
// create the start pixels positions of the left chromosomes
for (var i = 0; i < 13; i++)
{
var chrom_id = i+1;
var cx = 0;
var cy = (i + 0.5) * GenomePlot.pixelsPerLine; // computed in the un-padded space
// x: genomic value; y: pixel value
if (chrom_id === 13)
GenomePlot.chromPixelStarts[24-2] = { x: cx, y: cy, adjust: 0 };
else
GenomePlot.chromPixelStarts[chrom_id-1] = { x: cx, y: cy, adjust: 0 };
}
module.exports = function extract (arr, type, prefix) {
// From: http://locutusjs.org/php
// + original by: Brett Zamir (http://brett-zamir.me)
// % note 1: Only works by extracting into global context (whether called in the global scope or
// % note 1: within a function); also, the EXTR_REFS flag I believe can't be made to work
// * example 1: size = 'large';
// * example 1: var_array = {'color' : 'blue', 'size' : 'medium', 'shape' : 'sphere'};
// * example 1: extract(var_array, 'EXTR_PREFIX_SAME', 'wddx');
// * example 1: color+'-'+size+'-'+shape+'-'+wddx_size;
// * returns 1: 'blue-large-sphere-medium'
if (Object.prototype.toString.call(arr) === '[object Array]' &&
(type !== 'EXTR_PREFIX_ALL' && type !== 'EXTR_PREFIX_INVALID')) {
return 0;
}
var targetObj = this.window;
if (this.php_js && this.php_js.ini && this.php_js.ini['locutus.extractTargetObj'] && this.php_js.ini['locutus.extractTargetObj'].local_value) { // Allow designated object to be used instead of window
targetObj = this.php_js.ini['locutus.extractTargetObj'].local_value;
}
var chng = 0;
for (var i in arr) {
var validIdent = /^[_a-zA-Z$][\w|$]*$/; // TODO: Refine regexp to allow JS 1.5+ Unicode identifiers
var prefixed = prefix + '_' + i;
try {
switch (type) {
case 'EXTR_PREFIX_SAME' || 2:
if (targetObj[i] !== undefined) {
if (prefixed.match(validIdent) !== null) {
targetObj[prefixed] = arr[i];
++chng;
}
} else {
'IMAGETYPE_JP2': 10,
'IMAGETYPE_JPX': 11,
'IMAGETYPE_JB2': 12,
'IMAGETYPE_SWC': 13,
'IMAGETYPE_IFF': 14,
'IMAGETYPE_WBMP': 15,
'IMAGETYPE_JPEG2000': 9,
'IMAGETYPE_XBM': 16
}
};
if (this.php_js && this.php_js.ini && this.php_js.ini['locutus.get_defined_constants.setConstants'] && this.php_js.ini['locutus.get_defined_constants.setConstants'].local_value) {
// Allow us to set a configuration to let this function set global constants
if (this.php_js.ini['locutus.get_defined_constants.setConstants'].local_value === 'this') {
win = this;
} else if (this.php_js.ini['locutus.get_defined_constants.setConstants'].local_value === 'thisExt') {
win = this;
thisExt = true;
} else {
win = this.window;
}
for (ext in constObj) {
if (thisExt) { // Allows namespacing constants (e.g,. this.pcre.PREG_OFFSET_CAPTURE)
for (cnst in constObj[ext]) {
if (!win[ext]) {
win[ext] = {};
}
// These will not be real constants!
win[ext][cnst] = constObj[ext][cnst];
}
} else {
'IMAGETYPE_BMP': 6,
'IMAGETYPE_TIFF_II': 7,
'IMAGETYPE_TIFF_MM': 8,
'IMAGETYPE_JPC': 9,
'IMAGETYPE_JP2': 10,
'IMAGETYPE_JPX': 11,
'IMAGETYPE_JB2': 12,
'IMAGETYPE_SWC': 13,
'IMAGETYPE_IFF': 14,
'IMAGETYPE_WBMP': 15,
'IMAGETYPE_JPEG2000': 9,
'IMAGETYPE_XBM': 16
}
};
if (this.php_js && this.php_js.ini && this.php_js.ini['locutus.get_defined_constants.setConstants'] && this.php_js.ini['locutus.get_defined_constants.setConstants'].local_value) {
// Allow us to set a configuration to let this function set global constants
if (this.php_js.ini['locutus.get_defined_constants.setConstants'].local_value === 'this') {
win = this;
} else if (this.php_js.ini['locutus.get_defined_constants.setConstants'].local_value === 'thisExt') {
win = this;
thisExt = true;
} else {
win = this.window;
}
for (ext in constObj) {
if (thisExt) { // Allows namespacing constants (e.g,. this.pcre.PREG_OFFSET_CAPTURE)
for (cnst in constObj[ext]) {
if (!win[ext]) {
win[ext] = {};
}
~i ? Array[i] : Array[Stack.push(that) - 1] = {}
this.method(that)
.that = that
return this.method(that)
},
method: function (that) {
return Array[Stack.indexOf(that)]
}
}
}
return Relator()
}())
}
// END REDUNDANT
if (p && p.ini && p.ini['locutus.return_locutus_arrays'].local_value.toLowerCase() === 'on') {
if (!p.LOCUTUS_Array) {
// We keep this Relator outside the class in case adding prototype methods below
// Prototype methods added elsewhere can also use this ArrayRelator to share these "pseudo-global mostly-private" variables
__ = p.ArrayRelator = p.ArrayRelator || p.Relator.$()
// We could instead allow arguments of {key:XX, value:YY} but even more cumbersome to write
p.LOCUTUS_Array = function LOCUTUS_Array () {
var _ = __.constructor(this),
args = arguments,
i = 0,
argl, p
args = (args.length === 1 && args[0] && typeof args[0] === 'object' &&
// If first and only arg is an array, use that (Don't depend on this)
args[0].length && !args[0].propertyIsEnumerable('length')) ? args[0] : args
if (!_.objectChain) {
_.objectChain = args
_.object = {}