模块未在scrip中执行

2024-04-26 06:57:31 发布

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

我正在尝试编写一个程序,它以.pdb格式遍历一堆文件,并使用名为prepare_ligand4.py的模块将它们转换为.pdbqt格式。我很确定调用prepare_ligan4.py是正确的,但一旦调用到这一点,就会弹出包含prepare_ligand4.py代码的写字板文件。它应该改为修改指定目录中的文件。有人对我该做什么有什么建议吗?有什么特别的方法可以叫prepare\u ligand4.py吗?你知道吗

#convert pdb files to pdbqt
import os
import sys

#change directory to directory containing pdb files
os.chdir('C:\\Users\\Collin\\Documents\\fragments.pdb')

#path to pdb files
path = 'C:\\Users\\Collin\\Documents\\fragments.pdb'
dirs = os.listdir(path)

#finding number of pdb files in the directory
x = len(dirs)

#loop through all files in directory and convert to pdbqt
for i in range(x):
y = dirs[i]

os.system('C:\\Python27\\MGLTools-1.5.6\\Lib\\site-packages\\AutoDockTools\\Utilities24\\prepare_ligand4.py -l y -v')
ligand_pdbqt = y[:-4]+".pdbqt"

#os.rename(os.path.join ('C:\\Users\\Collin\\Documents\\fragments_under_150.pdb',y), os.path.join('C:\\Users\\Documents\\pdbqt', ligand_pdbqt)

Tags: 文件topathpyosfilesprepareusers