Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
T
TooBBA
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stelios Karozis
TooBBA
Commits
236a9cf9
Commit
236a9cf9
authored
May 05, 2020
by
Stelios Karozis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decomposition+Assign atoms to subdomains
parent
c700a0a7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
128 additions
and
30 deletions
+128
-30
CHANGELOG
CHANGELOG
+5
-4
main.py
main.py
+11
-3
tooba_f.py
tooba_f.py
+112
-23
No files found.
CHANGELOG
View file @
236a9cf9
...
@@ -6,13 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
...
@@ -6,13 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [Unreleased]
## [0.0.2] - 2020-05-0
4
## [0.0.2] - 2020-05-0
5
### Added
### Added
- debug trr frames export
- code for domain decomposition function
- initial code fro domain decomposition function
- code for identify desired atoms
- code for assigning desired atoms to subdomains
### Changed
### Changed
-
None
-
debug trr frames export
### Removed
### Removed
- None
- None
...
...
main.py
View file @
236a9cf9
...
@@ -4,7 +4,15 @@ import tooba_f as tbf
...
@@ -4,7 +4,15 @@ import tooba_f as tbf
#P2=(1,1,0)
#P2=(1,1,0)
#print(tbf.angle_between3D(P1,P2))
#print(tbf.angle_between3D(P1,P2))
#Read .trr file
data_all
=
tbf
.
fr_export
(
trajfile
=
'traj.trr'
,
num_frames
=
1
)
#Read .gro file
_
,
data_num
,
_
,
res_num
,
res_type
,
atom_type
,
atom_num
,
_
=
tbf
.
read_gro
(
'initial.gro'
)
#Create subdomains coordinates
box_p
=
tbf
.
domain_decomposition
(
data
=
data_all
,
dx
=
2
,
dy
=
2
,
dz
=
2
)
#Find atom type index in lists created above
group_ndx
=
tbf
.
resid_data
(
atom_type
,
group
=
[
'C1'
])
#Assign desired atoms (from above function) to subdomains
box_res
=
tbf
.
res2grid
(
data_all
,
atom_num
,
box_p
,
group_ndx
)
data_all
=
tbf
.
fr_export
(
trajfile
=
'traj.trr'
,
num_frames
=
10
)
#system,data_num,box_size,res_num,res_type,atom_type,atom_num,rest_dt = tbf.read_gro('initial.gro')
tbf
.
domain_decomposition
(
data
=
data_all
,
dx
=-
1
,
dy
=-
1
,
dz
=-
1
)
\ No newline at end of file
tooba_f.py
View file @
236a9cf9
import
numpy
as
np
import
numpy
as
np
import
scipy.optimize
import
scipy.optimize
from
mpl_toolkits.mplot3d
import
Axes3D
#
from mpl_toolkits.mplot3d import Axes3D
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
from
pytrr
import
(
from
pytrr
import
(
...
@@ -106,11 +106,8 @@ def fr_export(trajfile='traj.trr', num_frames=1):
...
@@ -106,11 +106,8 @@ def fr_export(trajfile='traj.trr', num_frames=1):
skip_trr_data
(
inputfile
,
header
)
skip_trr_data
(
inputfile
,
header
)
for
i
in
range
(
cnt_fr
-
num_frames
,
cnt_fr
):
for
i
in
range
(
cnt_fr
-
num_frames
,
cnt_fr
):
header
=
read_trr_header
(
inputfile
)
header
=
read_trr_header
(
inputfile
)
print
(
'Step: {step}, time: {time}'
.
format
(
**
header
))
#
print('Step: {step}, time: {time}'.format(**header))
data
=
read_trr_data
(
inputfile
,
header
)
data
=
read_trr_data
(
inputfile
,
header
)
#print(data.keys())
#print(data['box'])
#print(data['x'][0])
step
=
'{step}'
.
format
(
**
header
)
step
=
'{step}'
.
format
(
**
header
)
data_all
[
step
]
=
data
data_all
[
step
]
=
data
return
data_all
return
data_all
...
@@ -139,8 +136,8 @@ def read_gro(gro):
...
@@ -139,8 +136,8 @@ def read_gro(gro):
with
open
(
gro
,
'r'
)
as
F
:
with
open
(
gro
,
'r'
)
as
F
:
for
line
in
F
:
for
line
in
F
:
cnt
=
cnt
+
1
cnt
=
cnt
+
1
print
(
cnt
)
#
print(cnt)
if
cnt
>
2
:
if
cnt
>
2
and
cnt
<=
data_num
+
2
:
res_num
.
append
(
line
[:
5
])
res_num
.
append
(
line
[:
5
])
res_type
.
append
(
line
[
5
:
10
])
res_type
.
append
(
line
[
5
:
10
])
atom_type
.
append
(
line
[
10
:
15
])
atom_type
.
append
(
line
[
10
:
15
])
...
@@ -150,28 +147,120 @@ def read_gro(gro):
...
@@ -150,28 +147,120 @@ def read_gro(gro):
system
=
line
[:
10
]
system
=
line
[:
10
]
elif
cnt
==
2
:
elif
cnt
==
2
:
data_num
=
int
(
line
[:
7
])
data_num
=
int
(
line
[:
7
])
if
cnt
>
data_num
:
elif
cnt
>
data_num
+
2
:
box_size
=
line
[:
50
]
box_size
=
line
[:
50
]
#print(system,data_num,box_size)
#print(system,data_num,box_size)
return
system
,
data_num
,
box_size
,
res_num
,
res_type
,
atom_type
,
atom_num
,
rest_dt
return
system
,
data_num
,
box_size
,
res_num
,
res_type
,
atom_type
,
atom_num
,
rest_dt
def
domain_decomposition
(
data
,
dx
,
dy
,
dz
):
def
domain_decomposition
(
data
,
dx
,
dy
,
dz
):
"""
"""
Identify residues that rely inside a subdomain
Identify subdomain for each frame of
of a rectangular box
of .trr frame
parameters: data = {dictionary input from 'def fr_export'}
dx = desired size X of subdomain {units of input}
dy = desired size Y of subdomain {units of input}
dz = desired size Z of subdomain {units of input}
output: dictionary of x,y,z grid points per step (frame)
"""
box_p
=
{}
for
step
in
data
.
keys
():
box_p
[
step
]
=
{}
xs
=
int
(
round
(
data
[
step
][
'box'
][
0
][
0
]
+
0.1
))
#to round always to bigger number
ys
=
int
(
round
(
data
[
step
][
'box'
][
1
][
1
]
+
0.1
))
zs
=
int
(
round
(
data
[
step
][
'box'
][
2
][
2
]
+
0.1
))
box_x
=
int
(
xs
/
dx
)
box_y
=
int
(
ys
/
dy
)
box_z
=
int
(
zs
/
dz
)
xx
=
[]
for
i
in
range
(
0
,
xs
+
1
,
box_x
):
xx
.
append
(
i
)
box_p
[
step
][
'x'
]
=
xx
yy
=
[]
for
i
in
range
(
0
,
ys
+
1
,
box_y
):
yy
.
append
(
i
)
box_p
[
step
][
'y'
]
=
yy
zz
=
[]
for
i
in
range
(
0
,
zs
+
1
,
box_z
):
zz
.
append
(
i
)
box_p
[
step
][
'z'
]
=
zz
xyz
=
[]
for
ix
in
range
(
0
,
xs
+
1
,
box_x
):
for
iy
in
range
(
0
,
ys
+
1
,
box_y
):
for
iz
in
range
(
0
,
zs
+
1
,
box_z
):
xyz
.
append
([
ix
,
iy
,
iz
])
box_p
[
step
][
'xyz'
]
=
xyz
return
box_p
def
resid_data
(
atom_type
,
group
=
[]):
"""
Finds the index in list that 'def read_gro' returns,
and correspond to the atom types in group list
parameters: atom_type=[]
group=[]
output: dictionary
"""
ndx
=
{}
for
element
in
group
:
ndx
[
element
]
=
[
i
for
i
,
e
in
enumerate
(
atom_type
)
if
e
.
strip
()
==
element
.
strip
()]
#print(element,ndx)
return
ndx
def
res2grid
(
data
,
atom_num
,
box_p
,
ndx
):
"""
"""
print
(
'xs ys zs x y z'
)
Assign residue that corresponds to ndx (see 'def resid_data')
to sudomains created from 'def domain_decomposition'. The output
is a the box location (non zero based) in xyz-space for each atom number.
parameters: data = {dictionary input from 'def fr_export'}
atom_num = [list from 'def read_gro']
box_p = {dictionary input from 'def domain_decomposition'}
ndx = {dictionary input from 'def resid_data'}
output: dictionary
"""
box_res
=
{}
for
step
in
data
.
keys
():
for
step
in
data
.
keys
():
#print(data[step]['box'])
box_res
[
step
]
=
{}
#data[step]['box'][row][element]
for
key
in
ndx
.
keys
():
xs
=
data
[
step
][
'box'
][
0
][
0
]
for
i
in
ndx
[
key
]:
ys
=
data
[
step
][
'box'
][
1
][
1
]
#data[step]['x'][atom_num][x(0),y(1),z(2)]
zs
=
data
[
step
][
'box'
][
2
][
2
]
#data[step]['x'][atom_num][x(0),y(1),z(3)]
xx
=
data
[
step
][
'x'
][
i
][
0
]
x
=
data
[
step
][
'x'
][
0
][
0
]
cnt_x
=-
1
y
=
data
[
step
][
'x'
][
0
][
1
]
prev
=-
1
z
=
data
[
step
][
'x'
][
0
][
2
]
for
ix
in
box_p
[
step
][
'x'
]:
print
(
xs
,
ys
,
zs
,
x
,
y
,
z
)
cnt_x
=
cnt_x
+
1
#Todo: identify points inside box that belong to same residue
if
xx
<
ix
and
xx
>
prev
:
#return
prev
=
ix
\ No newline at end of file
break
yy
=
data
[
step
][
'x'
][
i
][
1
]
cnt_y
=-
1
prev
=-
1
for
iy
in
box_p
[
step
][
'y'
]:
cnt_y
=
cnt_y
+
1
if
yy
<
iy
and
yy
>
prev
:
prev
=
iy
break
zz
=
data
[
step
][
'x'
][
i
][
2
]
cnt_z
=-
1
prev
=-
1
for
iz
in
box_p
[
step
][
'z'
]:
cnt_z
=
cnt_z
+
1
if
zz
<
iz
and
zz
>
prev
:
prev
=
iz
break
box_res
[
step
][
atom_num
[
i
]]
=
[
cnt_x
,
cnt_y
,
cnt_z
]
return
box_res
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment