f = open('cluster_residues.txt', 'w')
# Make a list to count number of models
resi_models = []
for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
# Write models to file
f.write( str(spin_id) + " ; " + str(spin.model) + " ; " + str(spin._res_name) + "\n" )
# Append models to list
resi_models.append(spin.model)
# Count resi_models
c_resi_models = dict((i,resi_models.count(i)) for i in resi_models)
print c_resi_models
# Write count resultto file
for key, val in c_resi_models.items():
f.write( "# ; " + str(key) + " ; " + str(val) + "\n" )
# Write models to file
for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
f.write( str(spin_id) + " ; " + str(spin.model) + "\n" )
f.close()