3 # Copyright (C) 2009-2012 W. Trevor King <wking@tremily.us>
5 # This file is part of unfold_protein.
7 # unfold_protein is free software: you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the Free
9 # Software Foundation, either version 3 of the License, or (at your option) any
12 # unfold_protein is distributed in the hope that it will be useful, but WITHOUT
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 # You should have received a copy of the GNU General Public License along with
18 # unfold_protein. If not, see <http://www.gnu.org/licenses/>.
20 """Run a mechanical protein unfolding experiment."""
25 import numpy as _numpy
27 from pyafm.storage import load_afm as _load_afm
28 from pyafm.config import Kelvin as _Kelvin
29 from unfold_protein import __version__
30 from unfold_protein.unfolder import Unfolder
31 from unfold_protein.scan import UnfoldScanner
32 import unfold_protein.config as _config
35 if __name__ == '__main__':
36 from argparse import ArgumentParser
38 parser = ArgumentParser(
39 description=__doc__, version=__version__)
42 help='Path to a song to play when the experiment is complete')
44 '-S', '--no-stepper-tweaks', dest='stepper_tweaks',
45 action='store_const', const=False, default=True,
46 help=("Don't move the stepper except for the initial approach "
47 "and final retraction"))
49 args = parser.parse_args()
51 unfold_config = _config.UnfoldCycleConfig()
52 unfold_config['approach'] = _config.ApproachConfig()
53 unfold_config['unfold'] = _config.UnfoldConfig()
54 unfold_config['unfold']['distance'] = 900e-9
55 unfold_config['save'] = _config.SaveConfig()
56 scan_config = _config.ScanConfig()
57 scan_config['velocity'] = _config.VelocityScanConfig()
58 #scan_config['velocity']['unfolding velocities'] = _numpy.array([1e-6])
59 scan_config['velocity']['num loops'] = 500
60 scan_config['position'] = _config.PositionScanConfig()
65 afm.load_from_config(devices=devices)
67 unfolder = Unfolder(config=unfold_config, afm=afm)
68 scanner = UnfoldScanner(config=scan_config, unfolder=unfolder)
69 scanner.run(stepper_tweaks=args.stepper_tweaks)
71 afm.move_away_from_surface()
73 for device in devices:
76 song = os.path.abspath(os.path.expanduser(args.song))
77 os.system("aplay '%s'" % song)