Skip to content
Snippets Groups Projects
Commit b90dbc20 authored by Skander Hatira's avatar Skander Hatira
Browse files

made jbrowse cli work on vanilla

parent 33fdc84e
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@ const path = require("path");
module.exports = {
postStart: async (forgeConfig, options) => {
const resources = path.join(__dirname, ".webpack/main/resources");
// const jbrowse = path.join(__dirname, ".webpack/main/backend/node_modules/");
const jbrowse = path.join(__dirname, ".webpack/main/backend/node_modules/");
chmodr(resources, 0o777, (err) => {
if (err) {
......@@ -15,13 +15,13 @@ module.exports = {
console.log("Successful");
}
});
// chmodr(jbrowse, 0o777, (err) => {
// if (err) {
// console.log("Failed to execute chmod", err);
// } else {
// console.log("Successful");
// }
// });
chmodr(jbrowse, 0o777, (err) => {
if (err) {
console.log("Failed to execute chmod", err);
} else {
console.log("Successful");
}
});
},
postPackage: async (forgeConfig, options) => {
......@@ -29,10 +29,10 @@ module.exports = {
options.outputPaths[0],
"resources/app/.webpack/main/resources"
);
// const jbrowse = path.join(
// options.outputPaths[0],
// "resources/app/.webpack/main/backend/node_modules/"
// );
const jbrowse = path.join(
options.outputPaths[0],
"resources/app/.webpack/main/backend/node_modules/"
);
chmodr(resources, 0o777, (err) => {
if (err) {
......@@ -41,12 +41,12 @@ module.exports = {
console.log("Successful");
}
});
// chmodr(jbrowse, 0o777, (err) => {
// if (err) {
// console.log("Failed to execute chmod", err);
// } else {
// console.log("Successful");
// }
// });
chmodr(jbrowse, 0o777, (err) => {
if (err) {
console.log("Failed to execute chmod", err);
} else {
console.log("Successful");
}
});
},
};
......@@ -4,13 +4,14 @@ const spawnChild = (body) => {
const http = require("http");
const path = require("path");
console.log("hereeeeee");
const jbrowse = require("@jbrowse/cli");
const jbrowse = "../node_modules/.bin/jbrowse";
const script = path.join(__dirname, "../../resources/jbrowse.sh");
const workflow = path.join(__dirname, "../../resources/jbrowse2");
const bams = "";
const bams = path.join(__dirname, "../node_modules/.bin/jbrowse");
const options = {
slient: false,
detached: false,
cwd: __dirname,
};
// const child = execFileSync(
......@@ -20,25 +21,35 @@ const spawnChild = (body) => {
// );
body.genomes.map(async (genome) => {
console.log(path.extname(genome));
// const child = fork(
// jbrowse,
// ["add-assembly", genome, "--load", "copy", "--out", body.jbPath],
// options
// );
exec(
`jbrowse add-assembly ${genome} --load copy --out ${body.jbPath}`,
(error, stdout, stderr) => {
if (error) {
console.log("bigerror");
console.log(`Current directory: ${process.cwd()} | ${__dirname}`);
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.error(`stderr: ${stderr}`);
console.log("success");
}
const child = spawn(
path.join(__dirname, "../node_modules/@jbrowse/cli/bin/run"),
["add-assembly", genome, "--load", "copy", "--out", body.jbPath],
options
);
// child = fork(path.join(__dirname, "./node_modules/.bin/jbrowse"), [
// "add-assembly",
// genome,
// "--load",
// "copy",
// "--out",
// body.jbPath,
// ]);
// exec(
// `jbrowse add-assembly ${genome} --load copy --out ${body.jbPath}`,
// (error, stdout, stderr) => {
// if (error) {
// console.log("bigerror");
// console.error(`exec error: ${error}`);
// return;
// }
// console.log(`stdout: ${stdout}`);
// console.error(`stderr: ${stderr}`);
// console.log("success");
// }
// );
// const arrAss = [];
// console.log("before", arrAss);
......@@ -49,25 +60,25 @@ const spawnChild = (body) => {
// console.log(assemblies);
// --assemblyNames \'${assemblies}\' in exec command
// no need for npx , node modules available in exec commands directly
// let data = "";
// for await (const chunk of child.stdout) {
// console.log("stdout chunk: " + chunk);
// data += chunk;
// }
let data = "";
for await (const chunk of child.stdout) {
console.log("stdout chunk: " + chunk);
data += chunk;
}
// let error = "";
// for await (const chunk of child.stderr) {
// console.error("stderr chunk: " + chunk);
// error += chunk;
// }
// const exitCode = await new Promise((resolve, reject) => {
// child.on("close", resolve);
// });
let error = "";
for await (const chunk of child.stderr) {
console.error("stderr chunk: " + chunk);
error += chunk;
}
const exitCode = await new Promise((resolve, reject) => {
child.on("close", resolve);
});
// if (exitCode) {
// throw new Error(`subprocess error exit ${exitCode}, ${error}`);
// }
// return data;
if (exitCode) {
throw new Error(`subprocess error exit ${exitCode}, ${error}`);
}
return data;
});
body.tracks.map((track) => {
exec(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment