[chimera-dev] Freeing chimera memory after combining two molecules
Daniel VH
dviladrich95 at gmail.com
Thu Oct 4 06:51:43 PDT 2018
Hi, In my python script I'm using the combine() function to merge a protein
and a molecule into one model and since I'm doing this multiple times and
only use the combined result to save it with pdbWrite I want to free the
memory of the object combination right after that, but after the
instructions chimera.openModels.close(combination), del combination,
chimera.update.checkForChanges(), gc.collect(), chimera.closeSession() the
memory is not freed. This is the code that reproduces the problem, it uses
the molecules in the zipfile I have attatched.
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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-dev/attachments/20181004/1fb29472/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testing.py
Type: text/x-python
Size: 1151 bytes
Desc: not available
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-dev/attachments/20181004/1fb29472/attachment-0001.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test1_000.zip
Type: application/zip
Size: 228436 bytes
Desc: not available
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-dev/attachments/20181004/1fb29472/attachment-0001.zip>
More information about the Chimera-dev
mailing list