Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
14081e8
update readme for CCP Biosim
DonaldChung-HK Jul 1, 2022
e638263
testing CI and remove method 3 and 4
DonaldChung-HK Jul 1, 2022
de42f07
Merge pull request #1 from DonaldChung-HK/main
DonaldChung-HK Jul 1, 2022
8795f3a
Fast forwarded
DonaldChung-HK Jul 1, 2022
56ef539
See if new line make list show in Readthedocs
DonaldChung-HK Jul 4, 2022
1aa9f1b
testing setup.py changes
DonaldChung-HK Jul 5, 2022
725e2c2
testing setup.py changes
DonaldChung-HK Jul 5, 2022
22bbfda
Merge branch 'main' of https://github.com/CCPBioSim/CodeEntropy into …
DonaldChung-HK Jul 5, 2022
cb4f950
fixed classifier
DonaldChung-HK Jul 5, 2022
4c89151
exclude full lysozyme trajectory in build
DonaldChung-HK Jul 5, 2022
fae055f
add github action to test build and upload to pypi if tagged
DonaldChung-HK Jul 6, 2022
609fc94
update docs to us pypi
DonaldChung-HK Jul 6, 2022
ddcdb92
change publish to run only if passed test
DonaldChung-HK Jul 6, 2022
74a7903
removed artifact
DonaldChung-HK Jul 6, 2022
944441c
0.3.6 test
DonaldChung-HK Jul 6, 2022
29fe032
remove publish github action
DonaldChung-HK Jul 6, 2022
9a123b8
fixed readme.md and updated topog method
DonaldChung-HK Jul 13, 2022
a9183b5
added build action, excluded test trajectory from build and freeze de…
DonaldChung-HK Jul 19, 2022
0f4b52f
added paper
DonaldChung-HK Jul 21, 2022
003b32d
removed auto paper build
DonaldChung-HK Jul 21, 2022
aae7841
added draft of paper
DonaldChung-HK Jul 22, 2022
eaf094a
added multi processing but not officially supported due to low perfor…
DonaldChung-HK Jul 27, 2022
bcfd4e6
Removed dask implementation see jupyter notebook for exploration work
DonaldChung-HK Jul 27, 2022
62f5976
add pathos to requirement and removed dask from core implementation
DonaldChung-HK Jul 27, 2022
79c44ef
fixed docs and added community guidelines
DonaldChung-HK Jul 27, 2022
bd4ea8c
added developer guide
DonaldChung-HK Jul 27, 2022
6962489
remove pdf and added trial dask implementation
DonaldChung-HK Jul 29, 2022
b4d723b
fixed documentation on need to output both force and coordinate to th…
DonaldChung-HK Aug 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ jobs:
shell: bash
if: runner.os == 'Linux'
run: |
CodeEntropyPoseidon -f "CodeEntropy/tests/data/1AKI_prod_60.tpr" "CodeEntropy/tests/data/1AKI_prod_60.trr" -l "protein" -b 2 -e 12 -d 2 -t 2 --wm --res --uatom --topog 5 --solwm --solres --soluatom --solContact
CodeEntropyPoseidon -f "CodeEntropy/tests/data/1AKI_prod_60.tpr" "CodeEntropy/tests/data/1AKI_prod_60.trr" -l "protein" -b 2 -e 12 -d 2 -t 2 --wm --res --uatom --topog 3 --solwm --solres --soluatom --solContact
21 changes: 21 additions & 0 deletions .github/workflows/publish-on-pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Publish on PyPI

on:
push:
tags:
# After vMajor.Minor.Patch _anything_ is allowed (without "/") !
- '*'

jobs:
publish:
name: Publish to pypi if tagged
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: casperdcl/deploy-pypi@v2
with:
password: ${{ secrets.PYPI_API_TOKEN }}
pip: wheel -w dist/ --no-deps .
# only upload if a tag is pushed (otherwise just build & check)
upload: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') }}
183 changes: 48 additions & 135 deletions CodeEntropy/ClassCollection/PoseidonClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from collections import Counter
from datetime import datetime

from joblib import delayed

from CodeEntropy.poseidon.extractData.readFiles import populateTopology, getCoordsForces, getDistArray
# # Energy is not needed
# from CodeEntropy.poseidon.extractData.readFiles import populateEnergy, UAEnergyGroup
Expand All @@ -19,9 +21,15 @@
from CodeEntropy.poseidon.analysis.EECalculation import processEE
from CodeEntropy.poseidon.analysis.helper import memoryInfo, weightingPopulation

from CodeEntropy.FunctionCollection.PoseidonHelper import frame_iteration

from functools import partial
from multiprocessing import Pool

from pathos.pools import ProcessPool

import numpy as nmp

class Poseidon():
"""
Container to host data from MDAnalysis.Universe and run Poseidon Analysis
Expand Down Expand Up @@ -413,21 +421,37 @@ def __init__(self ,container, start=0, end=-1,
step=1, pureAtomNum=1, cutShell=None,
excludedResnames=None,
water='WAT', verbose=False, thread=4):
"""This is a initialization function to collect information from a MDanalysis universe into a data container for analysis using POSEIDON
Pending Work
- rewrite this into a class initalization for easier understanding
- rewrite the energy part to be compulsory

Args:
container (MDAnalysis.Universe): A MDAnalysis object with coordinates, forces and energy (loaded to velocity field with the value [Potential Energy(index 0), Kinetic Energy(1) and dummy(2)] respectively)
start (int): Starting Frame ID. Defaults to 0.
end (int): Ending Frame ID, this frame is not included. Defaults to -1.
step (int, optional): Steps between frame. Defaults to 1.
pureAtomNum (int, optional): Reference molecule resid for pure liquid. Defaults to 1.
cutShell (float, optional): Explicit cut off shell (might be buggy since part of it is not defined). Default to None which uses the relative angular distance (RAD) algorithm. See Jonathan Higham and Richard H. Henchman , "Locally adaptive method to define coordination shell", J. Chem. Phys. 145, 084108 (2016)
excludedResnames (list, optional): List of resnames to exclude from nearest non alike analysis. Defaults to None.
water (str, optional): Resname for water molecules. Defaults to 'WAT'.
verbose (bool, optional): print out progress of each analysis step. Defaults to False.
"""

This is a initialization function to collect information from a MDanalysis universe into a data container for analysis using POSEIDON.

.. Warning ::

This requires a lot of memory to run with very little performance gain.

Parameters
----------
container : MDAnalyse.Universe
A Universe object will all topology, dihedrals,coordinates and force information Check ``Example/create_new_universe.py`` on how to create a universe from existing data.
start : int or None, Optional, default: 0
Frame id to start analysis.
end : int or None, Optional, default: -1
Frame id to end analysis.
step : int, Optional, default: 1
Steps between frame.
pureAtomNum : int, Optional, default: 1
Reference molecule resid for pure liquid.
cutShell : float or None, Optional, default: 1
Explicit cut off shell. Default to None which uses the relative angular distance (RAD) algorithm. See Jonathan Higham and Richard H. Henchman , "Locally adaptive method to define coordination shell", J. Chem. Phys. 145, 084108 (2016)
excludedResnames : list of str or None, Optional, default: None
List of resnames to exclude from nearest non alike analysis.
water : list of str, Optional, default: "WAT"
Resname for water molecules.
verbose : bool, Optional, default: False
Print out progress of each step.
thread : int, Optional, default: 4
How many multiprocess thread to spawn

"""
startTime = datetime.now()
print(startTime)
Expand Down Expand Up @@ -463,9 +487,15 @@ def __init__(self ,container, start=0, end=-1,
if end == -1:
end = len(container.trajectory)
sys.setrecursionlimit(3000000)
p = Pool(processes=thread)
fi_partial = partial(self.frame_iteration, container, all_data, dimensions, startTime, verbosePrint, waterTuple, cutShell, excludedResnames)
data = p.map(fi_partial, [frame for frame in range(int(start), int(end), int(step))])
#p = Pool(processes=thread)
p = ProcessPool(nodes=thread)
fi_partial = partial(frame_iteration, container, all_data, dimensions, startTime, verbosePrint, waterTuple, cutShell, excludedResnames)
range = nmp.arange(int(start), int(end), int(step))
data = p.map(fi_partial, range)
p.close()

print("Done Threading Work")
print(len(data))
# data = []
# for frame in range(int(start), int(end), int(step)):
# data.append(fi_partial(frame))
Expand All @@ -480,120 +510,3 @@ def __init__(self ,container, start=0, end=-1,
print(datetime.now() - startTime)

self.allMoleculeList = allMoleculeList

def frame_iteration(self, container, all_data, dimensions, startTime, verbosePrint, waterTuple, cutShell, excludedResnames, frame):
clearClass(all_data)
print(f"frame = {frame}")

all_data, dimensions = getCoordsForces(container,
all_data, dimensions, frame, startTime,
verbosePrint)
# # Energy is not needed
# populateEnergy(container, all_data,
# dimensions, frame, startTime, verbosePrint)
# UAEnergyGroup(all_data)


calculateDihedrals(all_data, dimensions)
verbosePrint('DIH')
verbosePrint(datetime.now() - startTime)
sys.stdout.flush()

#'''
traj = container.trajectory[frame]
neighbour_coords = None
neighbour_coords = traj.positions

max_cutoff = 10
for x in range(0, len(all_data)):
atom = all_data[x]
#start nearest array from solutes
if atom.resname not in waterTuple:
getDistArray(atom, all_data, traj, max_cutoff,
dimensions, neighbour_coords,
startTime, verbosePrint)
#find nearest array for solute neighbours that are solvent
for nearDist in atom.nearest_all_atom_array[0:20]:
neighbour = all_data[nearDist[0]]
if neighbour.resname in waterTuple and \
neighbour.nearest_all_atom_array == None:
getDistArray(neighbour, all_data, traj, max_cutoff,
dimensions, neighbour_coords,
startTime, verbosePrint)
#find solvent neighbours neighbours nearest array
if neighbour.nearest_all_atom_array != None:
for nearDist2 in neighbour.nearest_all_atom_array[0:20]:
neighbour2 = all_data[nearDist2[0]]
if neighbour2.resname in waterTuple and \
neighbour2.nearest_all_atom_array == None:
getDistArray(neighbour2, all_data,
traj, max_cutoff,
dimensions,
neighbour_coords,
startTime, verbosePrint)
else:
continue
else:
continue
else:
continue
verbosePrint('NEAREST ARRAYS')
verbosePrint(datetime.now() - startTime)
sys.stdout.flush()
#'''



if cutShell != None:
#Used for fixed cut-off coordination shells
try:
cutoff_dist = float(cutShell)
distCutoffNc(all_data, dimensions, cutoff_dist)
# #don't know what this is it is not defined anywhere
# NcPairs(all_data, dimensions)
verbosePrint('distCutoffNc')
verbosePrint(datetime.now() - startTime)
sys.stdout.flush()
except ValueError:
logging.error('Cutoff distance needs to be a float')


if cutShell == None:
UALevelRAD(all_data, dimensions)
verbosePrint('RAD')
verbosePrint(datetime.now() - startTime)


#if inputType != 'pdb':
HBCalc(all_data, waterTuple, dimensions)
verbosePrint('HB')
verbosePrint(datetime.now() - startTime)
sys.stdout.flush()


getShellAssignment(all_data, excludedResnames, dimensions,
startTime, verbosePrint)
verbosePrint('PROX')
verbosePrint(datetime.now() - startTime)
sys.stdout.flush()


#if (force != None):
calculateFTMatrix(all_data, dimensions)
verbosePrint('FTMATRIX')
verbosePrint(datetime.now() - startTime)
sys.stdout.flush()


moleculePositionRankingRAD(all_data, waterTuple, dimensions)
verbosePrint('ORIENTS')
verbosePrint(datetime.now() - startTime)
sys.stdout.flush()

'''
if iterations == 1:
verbosePrint('Generating .pdb file for frame %s' % (frame+1))
pdbGenerate(all_data, ('frame_%s' % (frame+1)), dimensions)
'''

return (all_data, frame, dimensions)
135 changes: 135 additions & 0 deletions CodeEntropy/FunctionCollection/PoseidonHelper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import sys
import logging

from CodeEntropy.poseidon.extractData.readFiles import populateTopology, getCoordsForces, getDistArray
# # Energy is not needed
# from CodeEntropy.poseidon.extractData.readFiles import populateEnergy, UAEnergyGroup
from CodeEntropy.poseidon.extractData.HBRAD import distCutoffNc, UALevelRAD, HBCalc
from CodeEntropy.poseidon.extractData.forceTorques import calculateFTMatrix
from CodeEntropy.poseidon.extractData.dihedrals import calculateDihedrals
from CodeEntropy.poseidon.extractData.nearestNonlike2 import getShellAssignment, moleculePositionRankingRAD
from CodeEntropy.poseidon.extractData.outputFiles import moleculeObjectPopulation
from CodeEntropy.poseidon.extractData.mainClass import clearClass

from CodeEntropy.poseidon.analysis.populateClasses import classPopulation
from CodeEntropy.poseidon.analysis.EECalculation import processEE
from CodeEntropy.poseidon.analysis.helper import memoryInfo, weightingPopulation

from datetime import datetime

def frame_iteration(container, all_data, dimensions, startTime, verbosePrint, waterTuple, cutShell, excludedResnames, frame):
clearClass(all_data)
print(f"frame = {frame}")

all_data, dimensions = getCoordsForces(container,
all_data, dimensions, frame, startTime,
verbosePrint)
# # Energy is not needed
# populateEnergy(container, all_data,
# dimensions, frame, startTime, verbosePrint)
# UAEnergyGroup(all_data)


calculateDihedrals(all_data, dimensions)
verbosePrint('DIH')
verbosePrint(datetime.now() - startTime)
sys.stdout.flush()

#'''
traj = container.trajectory[frame]
neighbour_coords = None
neighbour_coords = traj.positions

max_cutoff = 10
for x in range(0, len(all_data)):
atom = all_data[x]
#start nearest array from solutes
if atom.resname not in waterTuple:
getDistArray(atom, all_data, traj, max_cutoff,
dimensions, neighbour_coords,
startTime, verbosePrint)
#find nearest array for solute neighbours that are solvent
for nearDist in atom.nearest_all_atom_array[0:20]:
neighbour = all_data[nearDist[0]]
if neighbour.resname in waterTuple and \
neighbour.nearest_all_atom_array == None:
getDistArray(neighbour, all_data, traj, max_cutoff,
dimensions, neighbour_coords,
startTime, verbosePrint)
#find solvent neighbours neighbours nearest array
if neighbour.nearest_all_atom_array != None:
for nearDist2 in neighbour.nearest_all_atom_array[0:20]:
neighbour2 = all_data[nearDist2[0]]
if neighbour2.resname in waterTuple and \
neighbour2.nearest_all_atom_array == None:
getDistArray(neighbour2, all_data,
traj, max_cutoff,
dimensions,
neighbour_coords,
startTime, verbosePrint)
else:
continue
else:
continue
else:
continue
verbosePrint('NEAREST ARRAYS')
verbosePrint(datetime.now() - startTime)
sys.stdout.flush()
#'''



if cutShell != None:
#Used for fixed cut-off coordination shells
try:
cutoff_dist = float(cutShell)
distCutoffNc(all_data, dimensions, cutoff_dist)
# #don't know what this is it is not defined anywhere
# NcPairs(all_data, dimensions)
verbosePrint('distCutoffNc')
verbosePrint(datetime.now() - startTime)
sys.stdout.flush()
except ValueError:
logging.error('Cutoff distance needs to be a float')


if cutShell == None:
UALevelRAD(all_data, dimensions)
verbosePrint('RAD')
verbosePrint(datetime.now() - startTime)


#if inputType != 'pdb':
HBCalc(all_data, waterTuple, dimensions)
verbosePrint('HB')
verbosePrint(datetime.now() - startTime)
sys.stdout.flush()


getShellAssignment(all_data, excludedResnames, dimensions,
startTime, verbosePrint)
verbosePrint('PROX')
verbosePrint(datetime.now() - startTime)
sys.stdout.flush()


#if (force != None):
calculateFTMatrix(all_data, dimensions)
verbosePrint('FTMATRIX')
verbosePrint(datetime.now() - startTime)
sys.stdout.flush()


moleculePositionRankingRAD(all_data, waterTuple, dimensions)
verbosePrint('ORIENTS')
verbosePrint(datetime.now() - startTime)
sys.stdout.flush()

'''
if iterations == 1:
verbosePrint('Generating .pdb file for frame %s' % (frame+1))
pdbGenerate(all_data, ('frame_%s' % (frame+1)), dimensions)
'''
#print(all_data, frame, dimensions)
return (all_data, frame, dimensions)
Loading