Comparing version
{ | ||
"name": "hic-straw", | ||
"version": "0.9.3", | ||
"version": "0.9.4", | ||
"description": "Utilities for reading .files (contact matrix files)", | ||
@@ -28,3 +28,3 @@ "main": "src/index.js", | ||
"scripts": { | ||
"build": "webpack; webpack --config webpack.config.var.js; node wrapper/build.js", | ||
"build": "webpack; webpack --config webpack.config.es.js; node wrapper/build.js", | ||
"test": "mocha -u tdd" | ||
@@ -31,0 +31,0 @@ }, |
@@ -105,3 +105,3 @@ # hic-straw | ||
<script src="https://cdn.jsdelivr.net/npm/hic-straw@0.9.3/dist/hic-straw.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/hic-straw@0.9.4/dist/hic-straw.js"></script> | ||
@@ -108,0 +108,0 @@ ... |
@@ -53,3 +53,3 @@ const zlib = require('zlib') | ||
const remoteFile = new RemoteFile(args) | ||
if(isGoogle(this.url)) { | ||
if(isGoogleDrive(this.url)) { | ||
this.file = new ThrottledFile(remoteFile, googleRateLimiter) | ||
@@ -780,4 +780,4 @@ } else { | ||
function isGoogle(url) { | ||
return url.indexOf("drive.google.com") >= 0 || url.indexOf("www.googleapis.com") > 0 | ||
function isGoogleDrive(url) { | ||
return url.indexOf("drive.google.com") >= 0 || url.indexOf("www.googleapis.com/drive") > 0 | ||
} | ||
@@ -784,0 +784,0 @@ |
@@ -20,6 +20,6 @@ const fetch = require('cross-fetch') | ||
let url = this.url.slice() // slice => copy | ||
if(jsEnv.isNode) { | ||
if (jsEnv.isNode) { | ||
headers['User-Agent'] = 'straw' | ||
} else { | ||
if(this.config.oauthToken) { | ||
if (this.config.oauthToken) { | ||
const token = resolveToken(this.config.oauthToken) | ||
@@ -37,3 +37,3 @@ headers['Authorization'] = `Bearer ${token}` | ||
if(this.config.apiKey) { | ||
if (this.config.apiKey) { | ||
url = addParameter(url, "key", this.config.apiKey) | ||
@@ -56,4 +56,3 @@ } | ||
throw err | ||
} | ||
else { | ||
} else { | ||
return response.arrayBuffer(); | ||
@@ -68,3 +67,3 @@ } | ||
async function resolveToken(token) { | ||
if(typeof token === 'function') { | ||
if (typeof token === 'function') { | ||
return await Promise.resolve(token()) // Normalize the result to a promise, since we don't know what the function returns | ||
@@ -84,2 +83,4 @@ } else { | ||
return url.replace("//www.dropbox.com", "//dl.dropboxusercontent.com"); | ||
} else if (url.startsWith("ftp://ftp.ncbi.nlm.nih.gov")) { | ||
return url.replace("ftp://", "https://") | ||
} else { | ||
@@ -92,3 +93,3 @@ return url | ||
function addParameter(url, name, value) { | ||
const paramSeparator = url.includes("?") ? "&" : "?"; | ||
const paramSeparator = url.includes("?") ? "&" : "?"; | ||
return url + paramSeparator + name + "=" + value; | ||
@@ -95,0 +96,0 @@ } |
@@ -25,2 +25,12 @@ const HicFile = require("./hicFile") | ||
const idx2 = this.hicFile.chromosomeIndexMap[chr2] | ||
if(idx1 === undefined) { | ||
console.log("No chromosome named: " + region1.chr) | ||
return [] | ||
} | ||
if(idx2 === undefined) { | ||
console.log("No chromosome named: " + region2.chr) | ||
return [] | ||
} | ||
const x1 = (region1.start === undefined) ? undefined : region1.start / binsize | ||
@@ -32,2 +42,6 @@ const x2 = (region1.end === undefined) ? undefined : region1.end / binsize | ||
const matrix = await this.hicFile.readMatrix(idx1, idx2) | ||
if(!matrix) { | ||
console.log("No matrix for " + region1.chr + "-" + region2.chr) | ||
return [] | ||
} | ||
@@ -70,2 +84,6 @@ // Find the requested resolution | ||
if(!blocks || blocks.length === 0) { | ||
return [] | ||
} | ||
const chr1 = this.hicFile.getFileChrName(region1.chr) | ||
@@ -72,0 +90,0 @@ const chr2 = this.hicFile.getFileChrName(region2.chr) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
369952
2.64%2261
1.8%