新增脚本filename_regulation_generator.py,有命名规范需要修改时,只需要修改ConfigParams.py的Filename类里面的变量的值,之后直接运行脚本filename_regulation_generator.py即可获取最新版本的数据结构化输入和输出命名规范.html
This commit is contained in:
@ -11,8 +11,9 @@ from overrides import overrides
|
||||
from pandas import read_csv, DataFrame
|
||||
from yaml import dump, load, FullLoader
|
||||
|
||||
from func.utils.ConfigParams import Filename, Params
|
||||
from func.utils.PublicFunc import PublicFunc
|
||||
from func.utils.Constants import Constants, ConfigParams
|
||||
from func.utils.Constants import Constants
|
||||
from func.utils.Result import Result
|
||||
from func.utils.detect_Jpeak import preprocess, Jpeak_Detection
|
||||
|
||||
@ -59,20 +60,20 @@ class SettingWindow(QMainWindow):
|
||||
self.ui.pushButton_cancel.clicked.connect(self.close)
|
||||
|
||||
def __read_config__(self):
|
||||
if not Path(ConfigParams.DETECT_JPEAK_CONFIG_FILE_PATH).exists():
|
||||
with open(ConfigParams.DETECT_JPEAK_CONFIG_FILE_PATH, "w") as f:
|
||||
dump(ConfigParams.DETECT_JPEAK_CONFIG_NEW_CONTENT, f)
|
||||
if not Path(Params.DETECT_JPEAK_CONFIG_FILE_PATH).exists():
|
||||
with open(Params.DETECT_JPEAK_CONFIG_FILE_PATH, "w") as f:
|
||||
dump(Params.DETECT_JPEAK_CONFIG_NEW_CONTENT, f)
|
||||
|
||||
with open(ConfigParams.DETECT_JPEAK_CONFIG_FILE_PATH, "r") as f:
|
||||
with open(Params.DETECT_JPEAK_CONFIG_FILE_PATH, "r") as f:
|
||||
file_config = load(f.read(), Loader=FullLoader)
|
||||
Config.update(file_config)
|
||||
self.config = file_config
|
||||
|
||||
Config.update({
|
||||
"Path": {
|
||||
"Input": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_ORGBCG_TEXT /
|
||||
"Input": str((Path(self.root_path) / Filename.PATH_ORGBCG_TEXT /
|
||||
Path(str(self.sampID)))),
|
||||
"Save": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_ORGBCG_TEXT /
|
||||
"Save": str((Path(self.root_path) / Filename.PATH_ORGBCG_TEXT /
|
||||
Path(str(self.sampID))))
|
||||
}
|
||||
})
|
||||
@ -94,7 +95,7 @@ class SettingWindow(QMainWindow):
|
||||
self.config["InputConfig"]["Freq"] = self.ui.spinBox_input_freq.value()
|
||||
self.config["ModelFolderPath"] = self.ui.plainTextEdit_deepmodel_path.toPlainText()
|
||||
|
||||
with open(ConfigParams.DETECT_JPEAK_CONFIG_FILE_PATH, "w") as f:
|
||||
with open(Params.DETECT_JPEAK_CONFIG_FILE_PATH, "w") as f:
|
||||
dump(self.config, f)
|
||||
|
||||
self.close()
|
||||
@ -105,18 +106,18 @@ class SettingWindow(QMainWindow):
|
||||
def __update_ui__(self):
|
||||
self.ui.plainTextEdit_file_path_input.setPlainText(
|
||||
str((Path(self.root_path) /
|
||||
ConfigParams.PUBLIC_PATH_ORGBCG_TEXT /
|
||||
Filename.PATH_ORGBCG_TEXT /
|
||||
Path(str(self.sampID)) /
|
||||
Path(ConfigParams.BCG_FILTER +
|
||||
Path(Filename.BCG_FILTER +
|
||||
str(self.ui.spinBox_input_freq.value()) +
|
||||
ConfigParams.ENDSWITH_TXT))))
|
||||
Params.ENDSWITH_TXT))))
|
||||
self.ui.plainTextEdit_file_path_save.setPlainText(
|
||||
str((Path(self.root_path) /
|
||||
ConfigParams.PUBLIC_PATH_PSG_TEXT /
|
||||
Filename.PATH_PSG_TEXT /
|
||||
Path(str(self.sampID)) /
|
||||
Path(ConfigParams.JPEAK_REVISE +
|
||||
Path(Filename.JPEAK_REVISE +
|
||||
str(self.ui.spinBox_input_freq.value()) +
|
||||
ConfigParams.ENDSWITH_TXT))))
|
||||
Params.ENDSWITH_TXT))))
|
||||
|
||||
|
||||
class MainWindow_detect_Jpeak(QMainWindow):
|
||||
@ -169,7 +170,7 @@ class MainWindow_detect_Jpeak(QMainWindow):
|
||||
self.fig.subplots_adjust(top=0.98, bottom=0.05, right=0.98, left=0.1, hspace=0, wspace=0)
|
||||
self.ax0 = self.fig.add_subplot(self.gs[0])
|
||||
self.ax0.grid(True)
|
||||
self.ax0.xaxis.set_major_formatter(ConfigParams.FORMATTER)
|
||||
self.ax0.xaxis.set_major_formatter(Params.FORMATTER)
|
||||
|
||||
PublicFunc.__resetAllButton__(self, ButtonState)
|
||||
|
||||
@ -355,7 +356,7 @@ class MainWindow_detect_Jpeak(QMainWindow):
|
||||
PublicFunc.progressbar_update(self, 1, 1, Constants.SAVING_DATA, 0)
|
||||
|
||||
total_rows = len(DataFrame(self.data.peak.reshape(-1)))
|
||||
chunk_size = ConfigParams.DETECT_JPEAK_SAVE_CHUNK_SIZE
|
||||
chunk_size = Params.DETECT_JPEAK_SAVE_CHUNK_SIZE
|
||||
with open(Config["Path"]["Save"], 'w') as f:
|
||||
for start in range(0, total_rows, chunk_size):
|
||||
end = min(start + chunk_size, total_rows)
|
||||
@ -379,7 +380,7 @@ class MainWindow_detect_Jpeak(QMainWindow):
|
||||
def reset_axes(self):
|
||||
self.ax0.clear()
|
||||
self.ax0.grid(True)
|
||||
self.ax0.xaxis.set_major_formatter(ConfigParams.FORMATTER)
|
||||
self.ax0.xaxis.set_major_formatter(Params.FORMATTER)
|
||||
|
||||
def update_ui_comboBox_model(self, model_list):
|
||||
self.ui.comboBox_model.clear()
|
||||
@ -398,18 +399,18 @@ class Data:
|
||||
if Path(Config["Path"]["Input"]).is_file():
|
||||
Config["Path"]["Input"] = str(Path(Config["Path"]["Input"]).parent)
|
||||
|
||||
result = PublicFunc.examine_file(Config["Path"]["Input"], ConfigParams.BCG_FILTER, ConfigParams.ENDSWITH_TXT)
|
||||
result = PublicFunc.examine_file(Config["Path"]["Input"], Filename.BCG_FILTER, Params.ENDSWITH_TXT)
|
||||
if result.status:
|
||||
Config["Path"]["Input"] = result.data["path"]
|
||||
Config["InputConfig"]["Freq"] = result.data["freq"]
|
||||
Config["Path"]["Save"] = str(
|
||||
Path(Config["Path"]["Save"]) / Path(ConfigParams.JPEAK_REVISE + str(Config["InputConfig"]["Freq"]) + ConfigParams.ENDSWITH_TXT))
|
||||
Path(Config["Path"]["Save"]) / Path(Filename.JPEAK_REVISE + str(Config["InputConfig"]["Freq"]) + Params.ENDSWITH_TXT))
|
||||
else:
|
||||
return result
|
||||
|
||||
try:
|
||||
self.raw_data = read_csv(Config["Path"]["Input"],
|
||||
encoding=ConfigParams.UTF8_ENCODING,
|
||||
encoding=Params.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.INPUT_FAILURE +
|
||||
|
||||
Reference in New Issue
Block a user