#!/usr/bin/python
import os
path=os.getcwd( )
print path
list_of_filenam es=os.listdir(p ath+'//newfiles')
print list_of_filenam es
residue=[]
for f in list_of_filenam es:
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(resid ue))
As the output of this script I got only one value which is the total number of 'HOH' molecules in all the files in that directory. But I need to count total number of 'HOH' molecules in each file one by one.
So please can you help me to find out how this script should be changed according to my requirement?
import os
path=os.getcwd( )
print path
list_of_filenam es=os.listdir(p ath+'//newfiles')
print list_of_filenam es
residue=[]
for f in list_of_filenam es:
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(resid ue))
As the output of this script I got only one value which is the total number of 'HOH' molecules in all the files in that directory. But I need to count total number of 'HOH' molecules in each file one by one.
So please can you help me to find out how this script should be changed according to my requirement?
Comment