import chimera
from Combine import combine
import zipfile
import time
import gc
import os
#from memory_profiler import profile
for itemnum in range(3):
#@profile
def pathmaker(itemnum):
dirpath = os.path.dirname(os.path.realpath(__file__))
zippath=dirpath+'/'+'test1_000.zip'
torsionpath=zipfile.ZipFile(zippath).extract('Pathway_000_Pathway.txt')
proteinpath=zipfile.ZipFile(zippath).extract('Protein_000_Protein.mol2')
ligandpath=zipfile.ZipFile(zippath).extract('Ligand_000_Ligand.mol2')
opened = chimera.openModels.open(proteinpath)
protein = opened[0]
opened1 = chimera.openModels.open(ligandpath)
mol=opened1[0]
combination=combine([mol,protein],protein)
totalnum=str(itemnum).zfill(3)+'_'+str(i).zfill(3)
chimera.pdbWrite([combination], chimera.Xform(), 'testpdb%s.pdb' %totalnum)
print('writing testpdb%s.pdb' %totalnum)
chimera.openModels.close(combination)
del combination
chimera.update.checkForChanges()
gc.collect()
chimera.closeSession()
for i in range(20):
pathmaker(itemnum)
#this stops the code and shows memory increase for each iteration
print('pause 6 seconds...')
time.sleep(6)