import os from chimera import openModels, Molecule from chimera import runCommand as rc # use 'rc' as shorthand for runCommand from chimera import replyobj # for emitting status messages from chimera import selection # change to folder with data files os.chdir("C:/Users/Navya Shilpa/Desktop/thesis/All_Proteins/nr-bilogicalunits/working") # gather the names of .pdb files in the folder file_names = [fn for fn in os.listdir(".") if fn.endswith(".pdb1")] # loop through the files, opening, processing, and closing each in turn for fn in file_names: replyobj.status("Processing " + fn) rc("open " + fn) rc("delete solvent") rc("select") rc("surf") # surface receptor outfn = open("testing.csv", "w") residues = selection.currentResidues() for m in openModels.list(modelTypes=[Molecule]): for r in m.residues: for a in r.atoms: try: sas=a.areaSAS bf=a.bfactor except AttributeError: continue print>>outfn, a, sas, bf outfn.close() rc("close all")