91902037af89e6b1766550163d5f81f835db8cc7
[unfold-protein.git] / unfold_protein / config.py
1 # Copyright (C) 2011 W. Trevor King <wking@drexel.edu>
2 #
3 # This file is part of unfold_protein.
4 #
5 # Unfold_protein is free software: you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation, either
8 # version 3 of the License, or (at your option) any later version.
9 #
10 # Unfold_protein is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with unfold_protein.  If not, see
17 # <http://www.gnu.org/licenses/>.
18
19 """Define some variables to configure the package for a particular lab
20 and workflow."""
21
22 import os.path as _os_path
23 import sys as _sys
24
25 from FFT_tools import window_hann as _window_hann
26 import h5config.config as _config
27 import h5config.tools as _h5config_tools
28 import numpy as _numpy
29 from calibcant.config import TemperatureConfig
30
31
32 class PackageConfig (_h5config_tools.PackageConfig):
33     "Configure `unfold_protein` module operation"
34     settings = _h5config_tools.PackageConfig.settings + [
35         _config.BooleanSetting(
36             name='matplotlib',
37             help='Plot piezo motion using `matplotlib`.',
38             default=False),
39         _config.FloatSetting(
40             name='temperature',
41             help=('Default temperature for unfolding in degrees '
42                   'Celsius.'),
43             default=22),
44         ]
45
46 class ApproachConfig (_config.Config):
47     "Configure `unfold_protein` approach operation"
48     settings = [
49         _config.FloatSetting(
50             name='relative setpoint',
51             help=('Maximum relative deflection in volts to achieve the bind '
52                   'position.'),
53             default=2.0),
54         _config.FloatSetting(
55             name='velocity',
56             help='Approach velocity in meters/second.',
57             default=1e-6),
58         _config.FloatSetting(
59             name='step',
60             help='Step size in meters.',
61             default=5e-9),
62         _config.IntegerSetting(
63             name='far',
64             help=('Approximate distance in meters to move away to get "far" '
65                   'from the surface.  For possible stepper adjustments while '
66                   'initially locating the surface.'),
67             default=1e-5),
68         ]
69
70 class UnfoldConfig (_config.Config):
71     "Configure `unfold_protein` unfold operation"
72     settings = [
73         _config.FloatSetting(
74             name='distance',
75             help='Unfolding distance in meters.',
76             default=800e-9),
77         _config.FloatSetting(
78             name='velocity',
79             help='Unfolding velocity in meters/second.',
80             default=1e-6),
81         _config.FloatSetting(
82             name='frequency',
83             help='Sampling frequency in Hz.',
84             default=50e3),
85         ]
86
87 class SaveConfig (_config.Config):
88     "Configure `unfold_protein` unfold operation"
89     settings = [
90         _config.Setting(
91             name='base directory',
92             help='Root directory for saving data.',
93             default=_os_path.expanduser('~/rsrch/data/unfold/')),
94         ]
95
96 class UnfoldCycleConfig (_config.Config):
97     "Configure a full `unfold_protein` approach-bind-unfold cycle"
98     settings = [
99         _config.ConfigSetting(
100             name='temperature',
101             help='Configure the temperature measurements',
102             config_class=TemperatureConfig),
103         _config.ConfigSetting(
104             name='approach',
105             help=('Configure the approach for an approach-bind-unfold '
106                   'sequence.'),
107             config_class=ApproachConfig),
108         _config.FloatSetting(
109             name='bind time',
110             help=('Binding time in seconds for an approach-bind-unfold '
111                   'sequence.'),
112             default=3),
113         _config.ConfigSetting(
114             name='unfold',
115             help=('Configure the unfolding for an approach-bind-unfold '
116                   'sequence.'),
117             config_class=UnfoldConfig),
118         _config.ConfigSetting(
119             name='save',
120             help='Configure saving.',
121             config_class=SaveConfig),
122         ]
123
124 class VelocityScanConfig (_config.Config):
125     "Configure `unfold_config` unfolding velocity scan"
126     settings = [
127         _config.FloatListSetting(
128             name='unfolding velocities',
129             help='Unfolding velocities in meters per second.',
130             default=_numpy.exp(_numpy.linspace(
131                     _numpy.log(20e-9), _numpy.log(2e-6), 10))),
132         _config.IntegerSetting(
133             name='num loops',
134             help='Number of loops through the scanned velocities.',
135             default=10),
136         ]
137
138 class PositionScanConfig (_config.Config):
139     "Configure `unfold_config` contact position scan"
140     settings = [
141         _config.FloatSetting(
142             name='x step',
143             help=('Distance in meters along the x axis between successive '
144                   'onfoldings.'),
145             default=5e-9),
146         _config.FloatSetting(
147             name='x max',
148             help='Maximum sampled x position in meters.',
149             default=1e-6),
150         _config.FloatSetting(
151             name='x min',
152             help='Minimum sampled x position in meters.',
153             default=-1e-6),
154         ]
155
156 class ScanConfig (_config.Config):
157     "Configure a full `unfold_protein` approach-bind-unfold cycle"
158     settings = [
159         _config.ConfigSetting(
160             name='velocity',
161             help='Configure unfolding velocity scan pattern.',
162             config_class=VelocityScanConfig),
163         _config.ConfigSetting(
164             name='position',
165             help='Configure unfolding position scan pattern.',
166             config_class=PositionScanConfig),
167         ]