X-Git-Url: http://git.tremily.us/?p=hooke.git;a=blobdiff_plain;f=hooke%2Fdriver%2Fmcs.py;h=d96e2f6a6e33694dcc2c0d7fdd0086f324c02165;hp=2d7c4198f3afa0d129b744bd49e8fb5278a7de3f;hb=23bcfd05915a61e3a41d01babd291fd3089ba329;hpb=ba4daa53462d81c9302a91d959612d534efc6be7 diff --git a/hooke/driver/mcs.py b/hooke/driver/mcs.py index 2d7c419..d96e2f6 100644 --- a/hooke/driver/mcs.py +++ b/hooke/driver/mcs.py @@ -1,16 +1,33 @@ -''' -mcs.py - -driver for mcs fluorescence files - -Massimo Sandal, Allen Chen (c) 2009 -''' - -from .. import curve as lhc -from .. import libhooke as lh +# Copyright (C) 2009-2012 Allen Chen +# Massimo Sandal +# W. Trevor King +# +# 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 . + +"""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=[]