Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 24, 2023
1 parent 019f49d commit d7792b4
Show file tree
Hide file tree
Showing 46 changed files with 190 additions and 190 deletions.
26 changes: 13 additions & 13 deletions taxonium_backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ program
.option("--data_url <data url>", "data url")
.option(
"--data_file <data file>",
"local data file, as alternative to data url"
"local data file, as alternative to data url",
);

program.parse();
Expand Down Expand Up @@ -153,7 +153,7 @@ app.get("/search", function (req, res) {
result.data.length +
" results in " +
(Date.now() - start_time) +
"ms"
"ms",
);
console.log("Result type was " + result.type);
});
Expand Down Expand Up @@ -255,7 +255,7 @@ app.get("/nodes/", function (req, res) {
max_y,
min_x,
max_x,
req.query.xType
req.query.xType,
);
}
console.log("Ready to send after " + (Date.now() - start_time) + "ms.");
Expand All @@ -267,19 +267,19 @@ app.get("/nodes/", function (req, res) {
(Date.now() - start_time) +
"ms, and output " +
result.length +
" nodes."
" nodes.",
);
});

function startListening() {
if (command_options.ssl) {
options = {
key: fs.readFileSync(
"/etc/letsencrypt/live/api.taxonium.org/privkey.pem"
"/etc/letsencrypt/live/api.taxonium.org/privkey.pem",
),
ca: fs.readFileSync("/etc/letsencrypt/live/api.taxonium.org/chain.pem"),
cert: fs.readFileSync(
"/etc/letsencrypt/live/api.taxonium.org/fullchain.pem"
"/etc/letsencrypt/live/api.taxonium.org/fullchain.pem",
),
};
https.createServer(options, app).listen(command_options.port, "0.0.0.0");
Expand Down Expand Up @@ -451,7 +451,7 @@ app.get("/node_details/", async (req, res) => {
}
validateSIDandSend(detailed_node, req.query.sid, res);
console.log(
"Request took " + (Date.now() - start_time) + "ms, and output " + node
"Request took " + (Date.now() - start_time) + "ms, and output " + node,
);
});

Expand All @@ -462,7 +462,7 @@ app.get("/tip_atts", async (req, res) => {
const atts = filtering.getTipAtts(processedData.nodes, node_id, att);
validateSIDandSend(atts, req.query.sid, res);
console.log(
"Request took " + (Date.now() - start_time) + "ms, and output " + atts
"Request took " + (Date.now() - start_time) + "ms, and output " + atts,
);
});

Expand All @@ -473,11 +473,11 @@ app.get("/nextstrain_json/:root_id", async (req, res) => {
root_id,
processedData.nodes,
config,
processedData.mutations
processedData.mutations,
);
res.setHeader(
"Content-Disposition",
"attachment; " + "filename=" + root_id + ".nextstrain.json"
"attachment; " + "filename=" + root_id + ".nextstrain.json",
);
res.send(json);
});
Expand All @@ -503,7 +503,7 @@ const loadData = async () => {

processedData = await importing.processJsonl(
supplied_object,
logStatusMessage
logStatusMessage,
);

logStatusMessage({
Expand All @@ -515,7 +515,7 @@ const loadData = async () => {
}

processedData.genes = new Set(
processedData.mutations.map((mutation) => mutation.gene)
processedData.mutations.map((mutation) => mutation.gene),
);
// as array
processedData.genes = Array.from(processedData.genes);
Expand All @@ -528,7 +528,7 @@ const loadData = async () => {
processedData.overallMaxY,
processedData.overallMinX,
processedData.overallMaxX,
"x_dist"
"x_dist",
);

cached_starting_values = result;
Expand Down
8 changes: 4 additions & 4 deletions taxonium_data_handling/exporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const addAAmuts = (aaMuts, node) => {
aaMuts.forEach((m) => {
if (alreadyIn.includes(m.gene)) {
node.branch_attrs.mutations[m.gene].push(
`${m.previous_residue}${m.residue_pos}${m.new_residue}`
`${m.previous_residue}${m.residue_pos}${m.new_residue}`,
);
} else {
node.branch_attrs.mutations[m.gene] = [
Expand All @@ -16,7 +16,7 @@ const addAAmuts = (aaMuts, node) => {

const addNucMuts = (nucMuts, node) => {
node.branch_attrs.mutations["nuc"] = nucMuts.map(
(m) => `${m.previous_residue}${m.residue_pos}${m.new_residue}`
(m) => `${m.previous_residue}${m.residue_pos}${m.new_residue}`,
);
};

Expand All @@ -25,7 +25,7 @@ export const getNextstrainSubtreeJson = async (
subtree_root_id,
nodes,
config,
mutations
mutations,
) => {
const subtree_root = nodes.find((node) => node.node_id === subtree_root_id);

Expand Down Expand Up @@ -81,7 +81,7 @@ export const getNextstrainSubtreeJson = async (
const aaMuts = muts.filter((m) => m.type === "aa");

const nucMutsNoAmb = nucMuts.filter(
(m) => m.new_residue != "-" && m.previous_residue != "-"
(m) => m.new_residue != "-" && m.previous_residue != "-",
);
// TODO: Above discards ambiguities from distance calculation.
// Do we want to do this? In mpx e.g. there are nodes with
Expand Down
42 changes: 21 additions & 21 deletions taxonium_data_handling/filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const getRevertantMutationsSet = (all_data, node_to_mut, mutations) => {
(m) =>
m.gene in gene_sequence &&
gene_sequence[m.gene][m.residue_pos] === m.new_residue &&
m.new_residue !== m.previous_residue
m.new_residue !== m.previous_residue,
);
return new Set(revertant_mutations.map((m) => m.mutation_id));
};
Expand All @@ -53,7 +53,7 @@ const reduceOverPlotting = (input, precisionX, precisionY, xType) => {
"precisionX:",
precisionX,
"precisionY:",
precisionY
precisionY,
);

const filtered = input.filter((node) => {
Expand Down Expand Up @@ -126,7 +126,7 @@ const addParents = (data, filtered) => {
}
}
const with_parents = data.filter((node) =>
selected_node_ids_set.has(node.node_id)
selected_node_ids_set.has(node.node_id),
);
const final_size = with_parents.length;
console.log("Adding parents took " + (Date.now() - start_time) + "ms.");
Expand Down Expand Up @@ -154,7 +154,7 @@ function getNodes(data, y_positions, min_y, max_y, min_x, max_x, xType) {
filtered.filter((node) => node.num_tips == 1),
getPrecision(min_x, max_x),
getPrecision(min_y, max_y),
xType
xType,
);
const time3 = Date.now();
console.log("Reducing took " + (time3 - time2) + "ms.");
Expand Down Expand Up @@ -197,7 +197,7 @@ function searchFiltering({
if (cache_helper && cache_helper.store_in_cache) {
cache_helper.store_in_cache(
hash_spec,
result.map((node) => node.node_id)
result.map((node) => node.node_id),
);
}
return result;
Expand Down Expand Up @@ -226,7 +226,7 @@ function searchFilteringIfUncached({
node_to_mut: node_to_mut,
all_data: all_data,
cache_helper: cache_helper,
})
}),
);
workingData = workingData.filter((n) => new_results.has(n));
});
Expand Down Expand Up @@ -280,14 +280,14 @@ function searchFilteringIfUncached({
spec.text = spec.text.toLowerCase();
filtered = data.filter(
(node) =>
node[spec.type] && node[spec.type].toLowerCase().includes(spec.text)
node[spec.type] && node[spec.type].toLowerCase().includes(spec.text),
);
return filtered;
} else if (spec.method === "text_exact") {
// case insensitive
spec.text = spec.text.toLowerCase();
filtered = data.filter(
(node) => node[spec.type] && node[spec.type].toLowerCase() === spec.text
(node) => node[spec.type] && node[spec.type].toLowerCase() === spec.text,
);
return filtered;
} else if (spec.method === "text_per_line") {
Expand All @@ -299,7 +299,7 @@ function searchFilteringIfUncached({
.map((line) => {
return line.trim();
})
.filter((line) => line !== "")
.filter((line) => line !== ""),
);

filtered = data.filter((node) => {
Expand Down Expand Up @@ -333,8 +333,8 @@ function searchFilteringIfUncached({
filtered = data.filter(
(node) =>
node_to_mut[node.node_id].some((mutation_id) =>
relevant_mutations_set.has(mutation_id)
) && node.num_tips > spec.min_tips
relevant_mutations_set.has(mutation_id),
) && node.num_tips > spec.min_tips,
);
//console.log("filtered:", filtered);
return filtered;
Expand All @@ -346,16 +346,16 @@ function searchFilteringIfUncached({
revertant_mutations_set = getRevertantMutationsSet(
all_data,
node_to_mut,
mutations
mutations,
);
}

filtered = data.filter(
(node) =>
node.num_tips > spec.min_tips &&
node_to_mut[node.node_id].some((mutation_id) =>
revertant_mutations_set.has(mutation_id)
)
revertant_mutations_set.has(mutation_id),
),
);
//console.log("filtered:", filtered);
return filtered;
Expand All @@ -374,7 +374,7 @@ function searchFilteringIfUncached({
const number_value = parseFloat(spec.number);
const filterFunc = getNumericFilterFunction(
spec.number_method,
number_value
number_value,
);

filtered = data.filter((node) => filterFunc(node[spec.type]));
Expand Down Expand Up @@ -430,7 +430,7 @@ function singleSearch({

// TODO if we ensured all searches maintained order we could use binary search here
const filtered_cut = filtered.filter(
(node) => node.y < max_y && node.y > min_y
(node) => node.y < max_y && node.y > min_y,
);

console.log("length of filtered_cut:", filtered_cut.length);
Expand All @@ -442,7 +442,7 @@ function singleSearch({
filtered_cut,
getPrecision(min_x, max_x),
getPrecision(min_y, max_y),
xType
xType,
);
result = {
type: "filtered",
Expand Down Expand Up @@ -530,7 +530,7 @@ const filterByGenotype = (data, genotype, mutations, node_to_mut, all_data) => {
const positive_mutations = new Set(
relevant_mutations
.filter((mutation) => mutation.new_residue === new_residue)
.map((m) => m.mutation_id)
.map((m) => m.mutation_id),
);

// if no positive mutations then return empty array
Expand All @@ -541,7 +541,7 @@ const filterByGenotype = (data, genotype, mutations, node_to_mut, all_data) => {
const negative_mutations = new Set(
relevant_mutations
.filter((mutation) => mutation.new_residue !== new_residue)
.map((m) => m.mutation_id)
.map((m) => m.mutation_id),
);
const output = data.filter((node) => {
// console.log("node:",node);
Expand All @@ -556,7 +556,7 @@ const filterByGenotype = (data, genotype, mutations, node_to_mut, all_data) => {
const is_positive =
cache_value === true ||
node_to_mut[cur_node.node_id].some((mutation_id) =>
positive_mutations.has(mutation_id)
positive_mutations.has(mutation_id),
);
if (is_positive) {
// console.log("positive");
Expand All @@ -568,7 +568,7 @@ const filterByGenotype = (data, genotype, mutations, node_to_mut, all_data) => {
const is_negative =
cache_value === false ||
node_to_mut[cur_node.node_id].some((mutation_id) =>
negative_mutations.has(mutation_id)
negative_mutations.has(mutation_id),
);
if (is_negative) {
// console.log("negative");
Expand Down
12 changes: 6 additions & 6 deletions taxonium_data_handling/importing.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ function reduceMaxOrMin(array, accessFunction, maxOrMin) {
return accessFunction(
array.reduce(function (max, item) {
return accessFunction(item) > accessFunction(max) ? item : max;
})
}),
);
} else if (maxOrMin === "min") {
return accessFunction(
array.reduce(function (min, item) {
return accessFunction(item) < accessFunction(min) ? item : min;
})
}),
);
}
}
Expand Down Expand Up @@ -84,7 +84,7 @@ export const setUpStream = (the_stream, data, sendStatusMessage) => {

export const processJsonl = async (jsonl, sendStatusMessage) => {
console.log(
"Worker processJsonl" //, jsonl
"Worker processJsonl", //, jsonl
);
const data = jsonl.data;
const status = jsonl.status;
Expand Down Expand Up @@ -164,12 +164,12 @@ export const processJsonl = async (jsonl, sendStatusMessage) => {
const overallMaxX = reduceMaxOrMin(
new_data.nodes,
(node) => node.x_dist,
"max"
"max",
);
const overallMinX = reduceMaxOrMin(
new_data.nodes,
(node) => node.x_dist,
"min"
"min",
);

const root = new_data.nodes.find((node) => node.parent_id === node.node_id);
Expand Down Expand Up @@ -242,7 +242,7 @@ export const generateConfig = (config, processedUploadedData) => {
: ["x_time"];

config.keys_to_display = Object.keys(processedUploadedData.nodes[0]).filter(
(x) => !to_remove.includes(x)
(x) => !to_remove.includes(x),
);

/*config.search_types = [
Expand Down
2 changes: 1 addition & 1 deletion taxonium_electron/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion taxonium_electron/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const setup = (mainWindow, args) => {
binaryPath = path.join(binaryDirectory, binaryFilename);
scriptPath = path.join(
__dirname,
"../node_modules/taxonium_backend/server.js"
"../node_modules/taxonium_backend/server.js",
);

max_old_space_arg = "--max-old-space-size=" + bytesToMb(maxMemory);
Expand Down
2 changes: 1 addition & 1 deletion taxonium_web_client/public/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
Expand Down
Loading

0 comments on commit d7792b4

Please sign in to comment.