diff --git a/Juse_toolkit.py b/Juse_toolkit.py index 00435d9..84c5e06 100644 --- a/Juse_toolkit.py +++ b/Juse_toolkit.py @@ -991,11 +991,11 @@ def setupUi(self, Dialog): self.enrich_xlab.addItem("") self.horizontalLayout_38.addWidget(self.enrich_xlab) self.gtl_dl = QtWidgets.QPushButton(self.groupBox_31) - self.gtl_dl.setEnabled(False) + self.gtl_dl.setEnabled(True) self.gtl_dl.setObjectName("gtl_dl") self.horizontalLayout_38.addWidget(self.gtl_dl) self.gef_c = QtWidgets.QPushButton(self.groupBox_31) - self.gef_c.setEnabled(False) + self.gef_c.setEnabled(True) self.gef_c.setObjectName("gef_c") self.horizontalLayout_38.addWidget(self.gef_c) self.groupBox_32 = QtWidgets.QGroupBox(self.tab_8) diff --git a/Juse_toolkit.ui b/Juse_toolkit.ui index 6df18fb..d260496 100644 --- a/Juse_toolkit.ui +++ b/Juse_toolkit.ui @@ -3044,7 +3044,7 @@ p, li { white-space: pre-wrap; } - false + true 下载 GO term list 文件 @@ -3054,7 +3054,7 @@ p, li { white-space: pre-wrap; } - false + true 对 GO 富集文件进行分类 diff --git a/README.md b/README.md index 6b577bc..976c013 100644 --- a/README.md +++ b/README.md @@ -17,3 +17,20 @@ 教程可见:[Juse's blog](https://jusetiz.github.io/) 若存在报错 Bug 可以联系 Juse 修复。 + +目前已经实现的功能: + +- 提取最长转录本。*(已实现)* +- 根据 id 提取序列。*(已实现)* +- 对序列的 id 进行各种处理。*(已实现)* +- 串联序列并得到分区信息。*(已实现)* +- 批量进行序列格式转换。*(已实现)* +- 批量提取 Orthofinder 的 orthogroup 对应的 CDS 序列。*(已实现)* +- 批量进行序列的物种数和长度过滤。*(已实现)* +- 火山图绘制。*(已实现)* +- 气泡图绘制。*(已实现)* + +目前已有的小功能: + +- 学习计时器。 +- 批量改后缀。 diff --git a/__pycache__/Juse_toolkit.cpython-310.pyc b/__pycache__/Juse_toolkit.cpython-310.pyc index 71db309..de29fc3 100644 Binary files a/__pycache__/Juse_toolkit.cpython-310.pyc and b/__pycache__/Juse_toolkit.cpython-310.pyc differ diff --git a/__pycache__/plot.cpython-310.pyc b/__pycache__/plot.cpython-310.pyc index 8c91067..7e5c8e6 100644 Binary files a/__pycache__/plot.cpython-310.pyc and b/__pycache__/plot.cpython-310.pyc differ diff --git a/__pycache__/ui_1.cpython-310.pyc b/__pycache__/ui_1.cpython-310.pyc index c0ac64f..1f05cbd 100644 Binary files a/__pycache__/ui_1.cpython-310.pyc and b/__pycache__/ui_1.cpython-310.pyc differ diff --git a/__pycache__/wz_ui.cpython-310.pyc b/__pycache__/wz_ui.cpython-310.pyc index 5bf2326..60ddfd8 100644 Binary files a/__pycache__/wz_ui.cpython-310.pyc and b/__pycache__/wz_ui.cpython-310.pyc differ diff --git a/plot.py b/plot.py index b436465..42f3e40 100644 --- a/plot.py +++ b/plot.py @@ -148,4 +148,32 @@ def plot_GOem(file_path, num = 20, xlab = 'GeneRatio', ylab = 'Description'): plt.ylabel('GO Description', fontsize=12) plt.tight_layout() - plt.show() \ No newline at end of file + plt.show() + + +def read_golist(filepath): + + golist = {} + with open(filepath, 'r') as f: + + for line in f: + if line.startswith('id:'): + GOid = line.lstrip('id:').strip() + golist[GOid] = {} + if line.startswith('name:'): + GOname = line.lstrip('name:').strip() + golist[GOid]['description'] = GOname + if line.startswith('namespace:'): + GOonto = line.lstrip('namespace:').strip() + golist[GOid]['ontology'] = GOonto + + return golist + + +def assign_go(file_path, golist): + + data = pd.read_csv(file_path) + data['Description'] = data['ID'].apply(lambda x: golist.get(x, {}).get('description', 'NA(Obsolete)')) + data['Ontology'] = data['ID'].apply(lambda x: golist.get(x, {}).get('ontology', 'NA(Obsolete)')) + dirpath = os.path.dirname(file_path) + data.to_csv(f'{dirpath}/GOanno.csv', index=False) \ No newline at end of file diff --git a/ui_1.py b/ui_1.py index fa79704..65b5933 100644 --- a/ui_1.py +++ b/ui_1.py @@ -171,7 +171,7 @@ def eventFilter(self, source, event): source.setText(file_path) return True - if source in [self.cds_input_text, self.vol_file, self.enrich_file]: + elif source in [self.cds_input_text, self.vol_file, self.enrich_file]: if event.type() == QEvent.DragEnter: if event.mimeData().hasUrls(): event.acceptProposedAction() diff --git a/ui_2.py b/ui_2.py index 6ad5a0f..dad1c18 100644 --- a/ui_2.py +++ b/ui_2.py @@ -9,7 +9,7 @@ from PyQt5.QtCore import QUrl, QEvent, QTimer from PyQt5.QtGui import QDesktopServices, QIcon from ui_1 import MyApp -from plot import plot_GOem, plot_GOem_classify +from plot import plot_GOem, plot_GOem_classify, read_golist, assign_go import sys import os import urllib.request @@ -22,12 +22,14 @@ def __init__(self): self.enrich_file.installEventFilter(self) self.gtl_dl.clicked.connect(self.gtlfile_dl) self.plot_bu_2.clicked.connect(self.GOem_plot) + self.gef_c.clicked.connect(self.GOem_anno) + def gtlfile_dl(self): gtl_url = 'http://current.geneontology.org/ontology/go-basic.obo' gtl_fn = 'go_term.list' - if os.path.exists(gtl_fn): + if os.path.exists(gtl_fn) or os.path.exists('go-basic.obo'): self.show_message_dialog("文件已存在,下载终止") return try: @@ -58,6 +60,28 @@ def GOem_plot(self): except Exception as e: self.show_message_dialog(f"发生错误:{e}\n请检查文件") + def GOem_anno(self): + + fp = self.enrich_file.toPlainText() + if fp == '': + self.show_message_dialog("请输入文件路径。") + return + + if os.path.exists('go_term.list'): + glfile = 'go_term.list' + elif os.path.exists('go-basic.obo'): + glfile = 'go-basic.obo' + else: + self.show_message_dialog("不存在 GO list 文件,请下载。") + return + + golist = read_golist(glfile) + if golist == {}: + self.show_message_dialog("GO list 文件存在错误,请检查。") + return + + assign_go(fp, golist) + self.show_message_dialog("请完成注释,请见 GOanno.csv。") if __name__ == "__main__": app = QApplication(sys.argv)