CaviTracer - Optimization#2241
Conversation
…on of np.sum(generator)
…iple unrelated atomgroups
…ressing Poolsuch as _ag_worker and _frame_worker
…culated for all relevant tetrahedra in the vector, rather than a for loop
| from prody import LOGGER, SETTINGS, PY3K | ||
| from prody.atomic import AtomGroup, Atom, Atomic, Selection, Select | ||
| from prody.atomic import flags, sliceAtomicData | ||
| from prody.dynamics.nma import NMA |
|
|
||
|
|
||
| def calcChannels(atoms, output_path=None, separate=False, start_point=None, r1=3, r2=1.25, min_depth=10, bottleneck=1, sparsity=15): | ||
| def calcChannels(atoms, r1=3, r2=1.25, min_depth=10, bottleneck=1, sparsity=15, start_point=None, **kwargs): |
There was a problem hiding this comment.
make sure these changes don't conflict with #2240
| checkCoords(coords) | ||
| except TypeError: | ||
| raise TypeError('coords must be an object with `getCoords` method') | ||
| raise TypeError('coords must be an object with `getCoords` method') |
There was a problem hiding this comment.
this error seems wrong. The getCoords function is being used instead of the objects method so numpy arrays should be supported too
|
|
||
| filenames = kwargs.pop('filenames',[None]*len(traj)) | ||
| if max_proc == 1: | ||
| results = [_frame_worker((atoms,frame.getCoords(),kwargs,i,filenames[i])) for i, frame in enumerate(traj)] |
There was a problem hiding this comment.
make lines shorter so more readable. Break it across lines e.g. at for
| if max_proc == 1: | ||
| results = [_frame_worker((atoms,frame.getCoords(),kwargs,i,filenames[i])) for i, frame in enumerate(traj)] | ||
| else: | ||
| tasks = ((atoms,frame.getCoords(),kwargs,i,filenames[i]) for i, frame in enumerate(traj)) |
| results = _run_with_pool(_frame_worker,tasks,max_proc,chunksize,'fork') | ||
| except (OSError, EOFError): | ||
| try: | ||
| results = _run_with_pool(_frame_worker,tasks,max_proc,chunksize,'spawn') |
There was a problem hiding this comment.
break line after ( and again before ) is a standard way that could help here
jamesmkrieger
left a comment
There was a problem hiding this comment.
This looks generally reasonable to me but I don't know enough about what's supposed to happen to comment on details
|
@MatthewLicht Can we close this pull request since @briza81 included (your; I guess) speed improvements in #2249? Or should we keep it and include several more things? |
I modified the sphere_fit, delete_simplices3d ,delete_section, surface_layer, and dijkstra functions in the ChannelCalculator Class for faster processing. Additionally, calcChannelsMultipleFrames uses multiprocessing Pool for parallel processing.
to test the code
from prody import *
Tests:
(1) Single PDB:
from prody import *
p = parsePDB('1tqn').select('protein')
calcChannels(p, output_path='test1.pdb')
(2) Multi-PDB:
from prody import *
p = parsePDB('multi.pdb').select('protein') (e.g. '2L6X')
calcChannelsMultipleFrames(p, output_path='mm_test_1', max_proc=2)
(3) DCD file:
from prody import *
PDBfile = 'structure.pdb'
DCDfile = 'trajectory.dcd'
atoms = parsePDB(PDBfile)
dcd = Trajectory(DCDfile)
dcd.link(atoms)
dcd.setCoords(atoms)
calcChannelsMultipleFrames(atoms, dcd, output_path='mm_test_2',max_proc=2)
(4) Multiple AtomGroups:
from prody import *
pdbs = [list of pdb files]
ags = [parsePDB(pdb) for pdb in pdbs ]
calcChannelsMultipleAtomGroups(ags)