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