PeptidesFunctionalDataset(helpers.dataset_classes文件中的lrgb.py)

devtools/2024/10/22 15:22:09/

任务类型:多任务二分类任务
用途:`PeptidesFunctionalDataset` 处理肽的分子图,并为肽的功能类别进行10种多任务二分类,任务目标是根据肽的分子图预测它们是否属于特定的功能类别(如抗癌、抗病毒等)。

from helpers.dataset_classes.lrgb import PeptidesFunctionalDataset

'''
Adapted from https://github.com/vijaydwivedi75/lrgb.git
https://github.com/HySonLab/Multires-Graph-Transformer.git
https://github.com/hamed1375/Exphormer.git
'''
import hashlib
import os.path as osp
import pickle
import shutilimport pandas as pd
import torch
from ogb.utils import smiles2graph
from ogb.utils.torch_util import replace_numpy_with_torchtensor
from ogb.utils.url import decide_download
from torch_geometric.data import (InMemoryDataset, Data, download_url,extract_zip)
from tqdm import tqdm
import osclass PeptidesFunctionalDataset(InMemoryDataset):def __init__(self, root='data', smiles2graph=smiles2graph,transform=None, pre_transform=None):"""PyG dataset of 15,535 peptides represented as their molecular graph(SMILES) with 10-way multi-task binary classification of theirfunctional classes.The goal is use the molecular representation of peptides insteadof amino acid sequence representation ('peptide_seq' field in the file,provided for possible baseline benchmarking but not used here) to testGNNs' representation capability.The 10 classes represent the following functional classes (in order):['antifungal', 'cell_cell_communication', 'anticancer','drug_delivery_vehicle', 'antimicrobial', 'antiviral','antihypertensive', 'antibacterial', 'antiparasitic', 'toxic']Args:root (string): Root directory where the dataset should be saved.smiles2graph (callable): A callable function that converts a SMILESstring into a graph object. We use the OGB featurization.* The default smiles2graph requires rdkit to be installed *"""self.original_root = rootself.smiles2graph = smiles2graphself.folder = osp.join(root, 'peptides-functional')self.url = 'https://www.dropbox.com/s/ol2v01usvaxbsr8/peptide_multi_class_dataset.csv.gz?dl=1'self.version = '701eb743e899f4d793f0e13c8fa5a1b4'  # MD5 hash of the intended dataset fileself.url_stratified_split = 'https://www.dropbox.com/s/j4zcnx2eipuo0xz/splits_random_stratified_peptide.pickle?dl=1'self.md5sum_stratified_split = '5a0114bdadc80b94fc7ae974f13ef061'# Check version and update if necessary.release_tag = osp.join(self.folder, self.version)if osp.isdir(self.folder) and (not osp.exists(release_tag)):print(f"{self.__class__.__name__} has been updated.")if input("Will you update the dataset now? (y/N)\n").lower() == 'y':shutil.rmtree(self.folder)super().__init__(self.folder, transform, pre_transform)self.data, self.slices = torch.load(self.processed_paths[0])@propertydef raw_file_names(self):return 'peptide_multi_class_dataset.csv.gz'@propertydef processed_file_names(self):return 'geometric_data_processed.pt'def _md5sum(self, path):hash_md5 = hashlib.md5()with open(path, 'rb') as f:buffer = f.read()hash_md5.update(buffer)return hash_md5.hexdigest()def download(self):if decide_download(self.url):path = download_url(self.url, self.raw_dir)# Save to disk the MD5 hash of the downloaded file.hash = self._md5sum(path)if hash != self.version:

http://www.ppmy.cn/devtools/127868.html

相关文章

Spring AI 整体介绍_关键组件快速入门_prompt_embedding等

Spring AI:Java开发者的AI集成新利器 在过去,Java开发者在构建AI应用时面临着缺乏统一框架的问题,导致不同AI服务的集成过程复杂且耗时。Spring AI应运而生,旨在为基于Java的应用程序提供一个标准化、高效且易于使用的AI开发平台…

域控制器计算机如何使用Active Directory用户添加管理域帐户

本地用户和组Error: 计算机 xxxx.xxx.com 是域控制器。在域控制器上不能使用该管理单元。管理域帐户可以用Active Directory 用户和计算机管理单元。 解决方法: 域控制器计算机不同于平常电脑那样添加管理本地用户帐户和计算机管理单元,需要…

如何移除JavaScript数组的最后一个元素

这篇文章的标题是《如何移除JavaScript数组的最后一个元素》。以下是文章的翻译内容: 我们在数组上执行的最频繁操作之一就是移除最后一个元素。有几种不同的方法可以做到这一点,但最常见的一种就是使用pop()方法。假设你有以下数组: let myArr = [ "🍎", &qu…

刷题训练之多源 BFS

> 作者:დ旧言~ > 座右铭:松树千年终是朽,槿花一日自为荣。 > 目标:熟练掌握多源 BFS算法。 > 毒鸡汤:学习,学习,再学习 ! 学,然后知不足。 > 专栏选自:刷…

机器人学 目录

目录 【机器人学】1-1.六自由度机器人运动学正解 【附MATLAB代码】 【机器人学】1-2. MATLAB机器人工具箱的安装与问题处理 【机器人学】1-3.六自由度机器人工作空间 【附MATLAB代码】 【机器人学】2-1.六自由度机器人运动学逆解【附MATLAB机器人逆解代码】 【机器人学】3…

【命令操作】信创终端系统上timedatectl命令详解 _ 统信 _ 麒麟 _ 方德

原文链接:【命令操作】信创终端系统上timedatectl命令详解 | 统信 | 麒麟 | 方德 Hello,大家好啊!今天给大家带来一篇关于如何在信创终端系统上使用timedatectl命令的详细介绍。timedatectl 是Linux系统中非常实用的时间管理工具,…

Spring Boot技术栈的电影评论网站构建

4系统概要设计 4.1概述 本系统采用B/S结构(Browser/Server,浏览器/服务器结构)和基于Web服务两种模式,是一个适用于Internet环境下的模型结构。只要用户能连上Internet,便可以在任何时间、任何地点使用。系统工作原理图如图4-1所示: 图4-1系统工作原理…

学DCGAN对抗网络之前--转置卷积(附代码解读)

了解DCGAN需要学习一下转置卷积 转置卷积和之前学的卷积的区别是转置卷积是上采样,普通的卷积是下采样 上采样和下采样: 下采样:池化操作就是经典的下采样,将一张图片缩小,采用不同的方法将像素点合并从而获得更小分辨率的照片就叫做下采…