#!/usr/bin/python
# -*- coding: latin-1 -*-
import os, sys

# importar de Chimera
import os
from chimera import runCommand as rc # use 'rc' as shorthand for runCommand
from chimera import replyobj # for emitting status messages

# change to folder with data files
os.chdir("C:\Users\Marķa Laura\Desktop\VariabilidadEstructuralProteica\VariabilidadEstructuralProteica\OUT\out_subset_CM_ANM")

# gather the names of .pdb files in the folder
file_names = [fn for fn in os.listdir(".") if fn.endswith(".pdb")]

# loop through the files, opening, processing, and closing each in turn
for fn in file_names:
	replyobj.status("Processing " + fn) # show what file we're working on
	rc("open " + fn)
	rc("preset apply publication 1") # make everything look nice
	rc("focus")
	rc("rangecolor bfactor key min cyan mid white max maroon")
        rc("preset apply pub 1")
	# save image to a file that ends in .png rather than .pdb
	png_name = fn[:-3] + "png"
	rc("copy file " + png_name + " supersample 3")
	rc("close all")
# uncommenting the line below will cause Chimera to exit when the script is done
# rc("stop now")
# note that indentation is significant in Python; the fact that
# the above command is exdented means that it is executed after
# the loop completes, whereas the indented commands that 
# preceded it are executed as part of the loop.

