CircosHeatmap-aardio/main.aardio

109 lines
4.2 KiB
Plaintext
Raw Normal View History

2025-01-12 22:35:14 +08:00
import fonts.fontAwesome;
2025-01-12 00:52:51 +08:00
import win.ui;
/*DSG{{*/
2025-01-13 23:42:55 +08:00
mainForm = win.form(text="CircosHeatmap-aardio";right=1000;bottom=700;bgcolor=16777215)
2025-01-12 00:52:51 +08:00
mainForm.add(
2025-01-14 00:19:12 +08:00
btnRun={cls="plus";text="生成pdf";left=891;top=661;right=991;bottom=691;align="left";border={color=-16777216;width=1};db=1;dr=1;font=LOGFONT(h=-16;name='微软雅黑');iconStyle={align="left";font=LOGFONT(h=-13;name='FontAwesome');padding={left=12}};iconText='\uF08B';textPadding={left=26};z=3};
2025-01-13 23:42:55 +08:00
btnSelectFile={cls="plus";text="数据源";left=786;top=661;right=886;bottom=691;align="left";border={top=1;right=1;bottom=1;color=-16777216};db=1;dr=1;font=LOGFONT(h=-16;name='微软雅黑');iconStyle={align="left";font=LOGFONT(h=-13;name='FontAwesome');padding={left=18}};iconText='\uF15C';textPadding={left=35};z=2};
editConsole={cls="richedit";left=10;top=510;right=990;bottom=650;bgcolor=4274224;color=15326936;db=1;dl=1;dr=1;hscroll=1;multiline=1;readonly=1;vscroll=1;z=5};
2025-01-14 00:05:21 +08:00
editRScript={cls="edit";left=10;top=10;right=990;bottom=500;border=1;color=4473924;db=1;dl=1;dr=1;dt=1;font=LOGFONT(h=-16);hscroll=1;multiline=1;vscroll=1;z=4};
2025-01-13 23:42:55 +08:00
inputFile={cls="plus";left=10;top=661;right=786;bottom=691;align="right";border={left=1;top=1;bottom=1;color=-16736064};db=1;dl=1;dr=1;editable="edit";font=LOGFONT(h=-13);textPadding={left=5;top=8;right=5;bottom=2};z=1}
2025-01-12 00:52:51 +08:00
)
/*}}*/
2025-01-12 22:35:14 +08:00
mainForm.btnSelectFile.skin({
2025-01-12 04:16:59 +08:00
background={
2025-01-12 22:35:14 +08:00
active=0xFF5AAEC4;
default=0xFF71D9F5;
disabled=0xFFCCCCCC;
};
color={
active=0xFFFFFFFF;
default=0xFF000000;
disabled=0xFF6D6D6D
2025-01-12 04:16:59 +08:00
}
2025-01-12 22:35:14 +08:00
});
mainForm.btnRun.skin({
background={
active=0xFF30BE3F;
default=0xFF7DED7B;
disabled=0xFFCCCCCC;
};
color={
active=0xFFFFFFFF;
default=0xFF000000;
disabled=0xFF6D6D6D
}
});
2025-01-12 04:16:59 +08:00
2025-01-12 00:52:51 +08:00
import console;
import fsys.dlg;
2025-01-14 00:05:21 +08:00
import process.r;
2025-01-12 00:52:51 +08:00
mainForm.editRScript.print($"\script\heatmap_script.R");
2025-01-12 04:16:59 +08:00
2025-01-13 23:34:41 +08:00
var initEditConsole = function(){
mainForm.editConsole.text = null;
mainForm.editConsole.appendText( textColor = 0xF5D971, point = 10, "当前仅支持 csv 格式的数据源。如果您的数据是其他格式(如 xls、xlsx可以将其转换为 csv 格式后再使用。" );
}
initEditConsole();
2025-01-12 00:52:51 +08:00
// 选择文件按钮点击事件
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) {
2025-01-14 00:15:08 +08:00
mainForm.editConsole.appendLink('\r\n');
mainForm.editConsole.appendText( textColor = 0xC7C7FF, point = 10, "请先选择输入文件!");
2025-01-12 00:52:51 +08:00
return;
}
// 弹出保存文件对话框选择PDF保存路径
var outputFilePath = fsys.dlg.save("PDF 文件|*.pdf||",, "选择保存路径");
if (!outputFilePath) {
2025-01-14 00:15:08 +08:00
mainForm.editConsole.appendLink('\r\n');
mainForm.editConsole.appendText( textColor = 0xC7C7FF, point = 10, "请选择PDF文件的保存路径");
2025-01-12 00:52:51 +08:00
return;
}
2025-01-13 23:34:41 +08:00
initEditConsole();
2025-01-13 23:42:55 +08:00
mainForm.editConsole.appendLink('\r\n');
mainForm.editConsole.appendText("处理中......");
2025-01-13 23:34:41 +08:00
2025-01-12 00:52:51 +08:00
// 执行 R 脚本
2025-01-12 04:16:59 +08:00
var out = process.r.exec(mainForm.editRScript.text, inputFilePath, outputFilePath);
2025-01-13 23:34:41 +08:00
mainForm.editConsole.appendLink('\r\n');
mainForm.editConsole.appendText(out);
2025-01-14 00:05:21 +08:00
// 结果检查
out_lines = string.split(out, '\r\n');
if (!io.exist(outputFilePath) or out_lines[#out_lines] == "Execution halted") {
mainForm.editConsole.appendLink('\r\n');
mainForm.editConsole.appendText( textColor = 0xC7C7FF, point = 10, "出错了!检查日志是否有错误说明");
}
else {
mainForm.editConsole.appendLink('\r\n');
mainForm.editConsole.appendText( textColor = 0x37D437, point = 10, "热图已成功保存至(注意检查是否符合预期):");
mainForm.editConsole.appendLink('\r\n');
mainForm.editConsole.appendText( textColor = 0x37D437, point = 12, outputFilePath);
2025-01-13 23:34:41 +08:00
}
2025-01-14 00:05:21 +08:00
2025-01-13 23:34:41 +08:00
// 滚动到最后一行
mainForm.editConsole.vScroll();
2025-01-12 00:52:51 +08:00
}
//显示版本号
import fsys.version;
var version = fsys.version.getInfo(io._exepath).productVersion;
mainForm.text += " " ++ tostring(version);
2025-01-12 00:52:51 +08:00
// 显示主窗口
mainForm.show();
return win.loopMessage();