CircosHeatmap-aardio/main.aardio
2025-01-12 03:27:50 +08:00

49 lines
1.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import win.ui;
/*DSG{{*/
mainForm = win.form(text="CircosHeatmap-aardio";right=800;bottom=600)
mainForm.add(
btnRun={cls="button";text="运行";left=740;top=10;right=780;bottom=40;z=4};
btnSelectFile={cls="button";text="选择输入文件";left=607;top=11;right=727;bottom=41;z=3};
editConsole={cls="edit";left=10;top=120;right=780;bottom=580;db=1;dl=1;dr=1;dt=1;edge=1;multiline=1;z=1};
inputFile={cls="edit";left=10;top=10;right=600;bottom=40;edge=1;z=2}
)
/*}}*/
import console;
import process.r;
import fsys.dlg;
// 选择文件按钮点击事件
mainForm.btnSelectFile.oncommand = function(id, event) {
var filePath = fsys.dlg.open("CSV 文件|*.csv||",, "选择输入文件");
if (filePath) {
mainForm.inputFile.text = filePath; // 将选择的文件路径显示在输入框中
}
}
// 运行按钮点击事件
mainForm.btnRun.oncommand = function(id, event) {
var inputFilePath = mainForm.inputFile.text;
if (!inputFilePath) {
console.log("请先选择输入文件!");
return;
}
// 弹出保存文件对话框选择PDF保存路径
var outputFilePath = fsys.dlg.save("PDF 文件|*.pdf||",, "选择保存路径");
if (!outputFilePath) {
console.log("请选择PDF文件的保存路径");
return;
}
// 执行 R 脚本
var out = process.r.exec($"\res\heatmap_script.R", inputFilePath, outputFilePath);
// 将 R 脚本的输出显示在控制台中
mainForm.editConsole.print(out);
mainForm.editConsole.print("Circos热图已成功保存至: " + outputFilePath);
}
// 显示主窗口
mainForm.show();
return win.loopMessage();