Remove unfold_protein.afm now that there is a configurable default AFM in pyafm.
[unfold-protein.git] / unfold.py
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2011 W. Trevor King <wking@drexel.edu>
4 #
5 # This file is part of unfold_protein.
6 #
7 # Unfold_protein is free software: you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation, either
10 # version 3 of the License, or (at your option) any later version.
11 #
12 # Unfold_protein is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU Lesser General Public License for more details.
16 #
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with unfold_protein.  If not, see
19 # <http://www.gnu.org/licenses/>.
20
21 """Run a mechanical protein unfolding experiment."""
22
23 import os
24 import os.path
25
26 from calibcant.config import Kelvin as _Kelvin
27 from unfold_protein import __version__ as version
28 from unfold_protein.afm import get_afm
29 from unfold_protein.unfolder import Unfolder
30 from unfold_protein.scan import UnfoldScanner
31 import unfold_protein.config as _config
32
33
34 if __name__ == '__main__':
35     from argparse import ArgumentParser
36
37     parser = ArgumentParser(
38         description='Play a pure tone', version=version)
39     parser.add_argument(
40         '-s', '--song',
41         help='Path to a song to play when the experiment is complete')
42
43     args = parser.parse_args()
44
45     unfold_config = _config.UnfoldCycleConfig()
46     unfold_config['temperature'] = _config.TemperatureConfig()
47     unfold_config['temperature']['units'] = _Kelvin
48     unfold_config['approach'] = _config.ApproachConfig()
49     unfold_config['unfold'] = _config.UnfoldConfig()
50     unfold_config['save'] = _config.SaveConfig()
51     scan_config = _config.ScanConfig()
52     scan_config['velocity'] = _config.VelocityScanConfig()
53     scan_config['position'] = _config.PositionScanConfig()
54
55     afm,comedi_device = get_afm(with_temperature=False)
56     unfolder = Unfolder(config=unfold_config, afm=afm)
57     scanner = UnfoldScanner(config=scan_config, unfolder=unfolder)
58     try:
59         scanner.run()
60     finally:
61         scanner.move_far_from_surface()
62         comedi_device.close()
63         if args.song:
64             song = os.path.abspath(os.path.expanduser(args.song))
65             os.system("aplay '%s'" % song)