/
lasso_minimal_surface.py
96 lines (77 loc) · 4.03 KB
/
lasso_minimal_surface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from topoly import lasso_type, make_surface
from topoly.params import PrecisionSurface, DensitySurface, SurfacePlotFormat, test
"""
Here are described method for lasso topology identification and minimal
surface generation. Topology type is based on number and direction of
tail crossings through minimal surface of lasso loop.
"""
lasso_type = test(lasso_type)
make_surface = test(make_surface)
polymer_lasso = 'data/lasso.xyz'
protein_lasso = 'data/1ax8.pdb'
#===========================
# LASSO TYPE IDENTIFICATION
#===========================
print('== Lasso type identification ==')
# If you want to check lasso topology type use „lasso_type" function.
# It requires a structure and its first and last indices:
polymer_lasso_type = lasso_type(polymer_lasso, [1,12])
print('.xyz structure lasso type:', polymer_lasso_type)
# If pdb file is passed without the indices, they will be imported
# from SSBOND records in pdb file:
protein_lasso_type = lasso_type(protein_lasso)
print('.pdb structure lasso type:', protein_lasso_type)
# If you check how „polymer_lasso" ('newdata/lasso.xyz') looks like
# (i.e. using xyz2pdb function) you'll realize that lasso loop is
# crossed three times. But output is L1, which corresponds to lasso
# crossed once. It's because of reduction of crossings. Crossing
# reduction happens in one of three situations:
# * Two neighbouring crossings cross the minimal surface from different
# sides. Defaultly it happens if crossings are in proximity of less
# than 10 atoms (aminoacids in case of proteins).
# * Crossing is close to tail beginning. Defaultly if the distance is
# less than 3 atoms (aminoacids).
# * Crossing is close to tail ending. Defaultly if distance is less
# than 3 atoms (aminoacids).
# You can change these parameters using „min_dist". Defaultly
# min_dist = [10,3,3], which refer to distance between: two crossings,
# crossing and tail beginning, crossing and tail ending. If you do not
# want any reduction, then use min_dist=[1,1,1]:
no_reduction = lasso_type(polymer_lasso, [1,12], min_dist=[1,1,1])
print('.xyz structure lasso type without reduction:', no_reduction)
# You can get more precise output using parameter „more_info" with
# „True" value.
no_reduction = lasso_type(polymer_lasso, [1,12], min_dist=[1,1,1],
more_info=True)
print('.xyz structure lasso type without reduction -- more info:', no_reduction)
#================
# OUTPUT QUALITY
#================
print('== Output quality ==')
# Your output depends on quality of calculated minimal surface. You can
# control its quality using „precision", „density" and „smooth"
# parameters. Higher precision and density gives better results but
# calculations are more time consuming. Smooth further increases
# quality of surface. Default values: precision=PrecisionSurface.HIGH,
# density=DensitySurface.MEDIUM, smooth=0.
quality = lasso_type(polymer_lasso, [1,12], min_dist=[1,1,1], smooth=1,
more_info=True, precision=PrecisionSurface.HIGH,
density=DensitySurface.MEDIUM)
print('.xyz structure -- higher quality:', quality)
#=========================
# SHOWING MINIMAL SURFACE
#=========================
print('== Showing minimal surface ==')
# You can check the shape of minimal surface using „pic_files" parameter.
lasso_type(polymer_lasso, [1,12], min_dist=[1,1,1], pic_files=SurfacePlotFormat.VMD)
# Also you can just find minimal surface of chosen loop using
# „make_surface" function.
triangles = make_surface(polymer_lasso, [1,12], precision = PrecisionSurface.LOW,
density=DensitySurface.LOW)
print('Minimal surface mesh coordinates:', triangles)
# Output has three levels: it is a list of dictionaries of dictionaries.
# It is a list of triangles which build a mesh of minimal surface. Each
# triangle is represented by a dictionary. This dictionary has triangle
# vertices as keys (with names „A", ”B", „C") and values as another dictionary.
# This last dictionary is a dictionary of space coordinates with keys „x", „y",
# „z".