-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathoptions.py
executable file
·127 lines (109 loc) · 5.43 KB
/
options.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Very simple option class
class Option:
def __init__(self,func=str,num=1,default=None,description=""):
self.func = func
self.num = num
self.value = default
self.description = description
def __nonzero__(self):
return self.value != None
def __str__(self):
return self.value and str(self.value) or ""
def setvalue(self,v):
if len(v) == 1:
self.value = self.func(v[0])
else:
self.value = [ self.func(i) for i in v ]
tm = []
lipL = []
lipU = []
sol = []
usrmols = []
usrheads = []
usrtails = []
usrlinks = []
# Description
desc = ""
# Option list
options = [
# option type number default description
# HII edit - lipid definition (last options are for additional lipid specification)
"""
Input/output related options
""",
("-f", Option(tm.append, 1, None, "Input GRO or PDB file 1: Protein")),
("-o", Option(str, 1, None, "Output GRO file: Membrane with Protein")),
("-p", Option(str, 1, None, "Optional rudimentary topology file")),
"""
Periodic boundary conditions
If -d is given, set up PBC according to -pbc such that no periodic
images are closer than the value given. This will make the numbers
provided for lipids be interpreted as relative numbers. If -d is
omitted, those numbers are interpreted as absolute numbers, and the
PBC are set to fit the given number of lipids in.
""",
("-pbc", Option(str, 1, "hexagonal", "PBC type: hexagonal, rectangular, square, cubic, optimal or keep")),
("-d", Option(float, 1, 0, "Distance between periodic images (nm)")),
("-dz", Option(float, 1, 0, "Z distance between periodic images (nm)")),
("-n", Option(str, 1, None, "Index file --- TO BE IMPLEMENTED")),
"""
Membrane/lipid related options.
The options -l and -u can be given multiple times. Option -u can be
used to set the lipid type and abundance for the upper leaflet. Option
-l sets the type and abundance for the lower leaflet if option -u is
also given, or for both leaflets if option -u is not given. The
meaning of the number depends on whether option -d is used to set up
PBC
""",
("-l", Option(lipL.append, 1, None, "Lipid type and relative abundance (NAME[:#])")),
("-u", Option(lipU.append, 1, None, "Lipid type and relative abundance (NAME[:#])")),
("-a", Option(float, 1, 0.60, "Area per lipid (nm*nm)")),
("-asym", Option(int, 1, None, "Membrane asymmetry (number of lipids)")),
("-hole", Option(float, 1, None, "Make a hole in the membrane with specified radius")),
("-rand", Option(float, 1, 0.1, "Random kick size (maximum atom displacement)")),
("-bd", Option(float, 1, 0.3, "Bead distance unit for scaling z-coordinates (nm)")),
"""
Protein related options.
""",
("-center", Option(bool, 0, None, "Center the protein on z")),
("-orient", Option(bool, 0, None, "Orient protein in membrane")),
("-rotate", Option(str, 0, None, "Rotate protein (random|princ|angle(float))")),
("-od", Option(float, 1, 1.0, "Grid spacing for determining orientation")),
("-op", Option(float, 1, 4.0, "Hydrophobic ratio power for determining orientation")),
("-fudge", Option(float, 1, 0.1, "Fudge factor for allowing lipid-protein overlap")),
("-ring", Option(bool, 0, None, "Put lipids inside the protein")),
("-dm", Option(float, 1, None, "Shift protein with respect to membrane")),
"""
Solvent related options.
""",
("-sol", Option(solv.append, 1, None, "Solvent type and relative abundance (NAME[:#])")),
("-sold", Option(float, 1, 0.5, "Solvent diameter")),
("-solr", Option(float, 1, 0.1, "Solvent random kick")),
("-excl", Option(float, 1, 1.5, "Exclusion range (nm) for solvent addition relative to membrane center")),
"""
Salt related options.
""",
("-salt", Option(str, 1, None, "Salt concentration")),
("-charge", Option(str, 1, "auto", "Charge of system. Set to auto to infer from residue names")),
"""
Define additional lipid types (same format as in lipid-martini-itp-v01.py)
""",
("-alname", Option(usrmols.append, 1, None, "Additional lipid name, x4 letter")),
("-alhead", Option(usrheads.append, 1, None, "Additional lipid head specification string")),
("-allink", Option(usrlinks.append, 1, None, "Additional lipid linker specification string")),
("-altail", Option(usrtails.append, 1, None, "Additional lipid tail specification string")),
]
args = sys.argv[1:]
if '-h' in args or '--help' in args:
print "\n",__file__
print desc or "\nSomeone ought to write a description for this script...\n"
for thing in options:
print type(thing) != str and "%10s %s"%(thing[0],thing[1].description) or thing
print
sys.exit()
# Convert the option list to a dictionary, discarding all comments
options = dict([i for i in options if not type(i) == str])
# Process the command line
while args:
ar = args.pop(0)
options[ar].setvalue([args.pop(0) for i in range(options[ar].num)])