Ran update-copyright.py
[hooke.git] / hooke / driver / mcs.py
index 48836f2fb4b558506d89279b5342623957e7db3c..d96e2f6a6e33694dcc2c0d7fdd0086f324c02165 100644 (file)
@@ -1,16 +1,33 @@
-'''
-mcs.py
-
-driver for mcs fluorescence files
-
-Massimo Sandal, Allen Chen (c) 2009
-'''
-
-import libhookecurve as lhc
-import libhooke as lh
+# Copyright (C) 2009-2012 Allen Chen
+#                         Massimo Sandal <devicerandom@gmail.com>
+#                         W. Trevor King <wking@tremily.us>
+#
+# This file is part of Hooke.
+#
+# Hooke is free software: you can redistribute it and/or modify it under the
+# terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
+#
+# Hooke is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with Hooke.  If not, see <http://www.gnu.org/licenses/>.
+
+"""Driver for mcs fluorescence files.
+"""
+
+import os.path
+
+import lib.curve
+import lib.driver
+import lib.plot
 import struct
 
-class mcsDriver(lhc.Driver):
+class mcsDriver(lib.driver.Driver):
 
     def __init__(self, filename):
         '''
@@ -35,35 +52,55 @@ class mcsDriver(lhc.Driver):
         self.bluedata=self.filebluedata.read()
         self.filebluedata.close()
 
-        self.filetype = 'mcs'
-        self.experiment = 'smfluo'
-
-    def is_me(self):
-        if self.filename[-3:].lower()=='mcs':
-            return True
-        else:
-            return False
-
     def close_all(self):
         self.filedata.close()
         self.filebluedata.close()
 
-
     def default_plots(self):
+        #TODO: rename blue and red data to something more appropriate if possible
         red_data=self.read_file(self.reddata)
         blue_data=self.read_file(self.bluedata)
         blue_data=[-1*float(item) for item in blue_data] #visualize blue as "mirror" of red
 
-        main_plot=lhc.PlotObject()
-        main_plot.add_set(range(len(red_data)),red_data)
-        main_plot.add_set(range(len(blue_data)),blue_data)
-        main_plot.normalize_vectors()
-        main_plot.units=['time','count']  #FIXME: if there's an header saying something about the time count, should be used
-        main_plot.destination=0
-        main_plot.title=self.filename
-        main_plot.colors=['red','blue']
+        extension = lib.curve.Curve()
+        retraction = lib.curve.Curve()
+
+        extension.color = 'red'
+        extension.label = 'extension'
+        extension.style = 'plot'
+        extension.title = 'Force curve'
+        #FIXME: if there's an header saying something about the time count, should be used
+        #TODO: time is not really a unit
+        extension.units.x = 'time'
+        extension.units.y = 'count'
+        extension.x = range(len(red_data))
+        extension.y = red_data
+        retraction.color = 'blue'
+        retraction.label = 'retraction'
+        retraction.style = 'plot'
+        retraction.title = 'Force curve'
+        #FIXME: if there's an header saying something about the time count, should be used
+        #TODO: time is not really a unit
+        retraction.units.x = 'time'
+        retraction.units.y = 'count'
+        retraction.x = range(len(blue_data))
+        retraction.y = blue_data
+
+        plot = lib.plot.Plot()
+        plot.title = os.path.basename(self.filename)
+        plot.curves.append(extension)
+        plot.curves.append(retraction)
+
+        plot.normalize()
+        return plot
 
-        return [main_plot]
+    def is_me(self):
+        if os.path.isdir(path):
+            return False
+        if self.filename[-3:].lower()=='mcs':
+            return True
+        else:
+            return False
 
     def read_file(self, raw_data):
         real_data=[]