#!/usr/bin/python
import os
path=os.getcwd()
print path
list_of_filenames=os.listdir(path+'//newfiles')
print list_of_filenames
residue=[]
for f in list_of_filenames:
f1=open(path+'//newfiles//'+f).readlines()
for line in f1:
if line.startswith('HETATM'):
res_number=line[22:26]
if res_number not in residue and line[17:20]=='HOH':
residue.append(res_number)
else:
continue
else:
continue
print(len(residue))
上記のスクリプトを使用して、すべてのファイルで 'HOH'分子の合計数を1つの値として得ました。しかし、私はどれくらいの量の 'HOH'分子が各ファイルにあるのかを知る必要があります。Pythonを使用して各ファイルの 'HOH'分子の総数を数える方法
このスクリプトは私の要求に応じてどのように変更する必要があるか教えてください。
ありがとうございます。大きな助けを – IKW