如何在vs代码中使用sysargv模块?

2024-10-03 13:30:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在尝试根据分子与参考分子的结构相似性筛选分子数据库,但脚本不起作用,因为od警告“出现异常,请使用%tb查看完整的回溯。”我在vs代码中使用jupyter笔记本

问题是: 如果len(sys.argv)=5:
sys.exit(“用法:python-tethereminization.py-reference.sdf-output1.sdf-outputEthered.sdf-outputnontethered.sdf”)

import sys 
from rdkit import Chem 
from rdkit.Chem import AllChem 
from rdkit.Chem import rdFMCS 
from rdkit.Chem.rdMolAlign import AlignMol

if len(sys.argv)!=5 :
sys.exit("usage : python tetheredMinimization.py reference.sdf output1.sdf outputtethered.sdf outputnontethered.sdf")

ratioThreshold=0.20

reference = Chem.MolFromMolFile(sys.argv[1], removeHs=True)
ligands = Chem.SDMolSupplier(sys.argv[2],removeHs=True)

w=Chem.SDWriter(sys.argv[3]) wnt=Chem.SDWriter(sys.argv[4])


Tags: frompyimportlensysexit分子reference
1条回答
网友
1楼 · 发布于 2024-10-03 13:30:28

如果您使用的是Jupyter,您可能不想使用sys.argv,这通常用于检索command-line arguments。在Jupyter中使用时,您很可能会得到用于启动IPython的参数,而IPython也可能不满足len(sys.argv) == 5。不要使用它,只需在代码中定义参数,并用正确的变量替换所有使用sys.argv的地方

相关问题 更多 >