--- /dev/null
+#!/usr/bin/python
+
+import hooke.hooke
+
+hooke.hooke.main()
<?xml version="1.0" ?>\r
<!-- To comment something, put dashes and ! like here -->\r
<config>\r
-<!-- Internal variabls. -->\r
- <display ext="1" colour_ext="None" ret="1" colour_ret="None" correct="1" colour_correct="None" contact_point="0" medfilt="0" xaxes="0" yaxes="0" flatten="1" fit_function="wlc" temperature="301" auto_fit_points="50" auto_slope_span="20" auto_delta_force="10" auto_fit_nm="5" auto_min_p="0.005" auto_max_p="10" baseline_clicks="0" auto_left_baseline="20" auto_right_baseline="20" force_multiplier="1" fc_showphase="0" fc_showimposed="0" fc_interesting="0" tccd_threshold="0" tccd_coincident="0"/>\r
\r
-<!-- \r
-The following section defines your own work directory. Substitute your work directory.\r
- -->\r
-<workdir>\r
- insert directory\r
-</workdir>\r
+\r
+<!--\r
+This section defines the Hooke installation. confpath is hardcoded,\r
+since it's to find the config file(s) before your read them.\r
+ -->\r
+<install>\r
+ <docpath>\r
+ ./doc/\r
+ </docpath>\r
+</install>\r
+\r
+<!-- Internal variables. -->\r
+<display\r
+ ext="1"\r
+ colour_ext="None"\r
+ ret="1"\r
+ colour_ret="None"\r
+ correct="1"\r
+ colour_correct="None"\r
+ contact_point="0"\r
+ medfilt="0"\r
+ xaxes="0"\r
+ yaxes="0"\r
+ flatten="1"\r
+ fit_function="wlc"\r
+ temperature="301"\r
+ auto_fit_points="50"\r
+ auto_slope_span="20"\r
+ auto_delta_force="10"\r
+ auto_fit_nm="5"\r
+ auto_min_p="0.005"\r
+ auto_max_p="10"\r
+ baseline_clicks="0"\r
+ auto_left_baseline="20"\r
+ auto_right_baseline="20"\r
+ force_multiplier="1"\r
+ fc_showphase="0"\r
+ fc_showimposed="0"\r
+ fc_interesting="0"\r
+ tccd_threshold="0"\r
+ tccd_coincident="0"/>\r
\r
<!--\r
The following section defines the default playlist to load at startup.\r
--->\r
+ -->\r
<defaultlist>\r
- test.hkp\r
+ ./hooke/test/test.hkp\r
</defaultlist>\r
\r
<!--\r
This section defines which plugins have to be loaded by Hooke.\r
- -->\r
+ -->\r
<plugins>\r
<fit/>\r
<procplots/>\r
</plotmanips>\r
\r
</config>\r
-\r
--- /dev/null
+<?xml version="1.0" ?>
+<config>
+
+<!-- Set the location of your macros directory (for the macro plugin) -->
+<macrodir path="~/.hooke/macros" />
+</config>
==============
Open a terminal, go to the directory Hooke is installed and type
-python hooke/hooke.py (You may need to give the full path for Python
-on Windows systems). If everything is OK, Hooke displays a nice
-splashscreen and starts.
+ python bin/hooke
+(You may need to give the full path for Python on Windows systems).
+If everything is OK, Hooke displays a nice splashscreen and starts.
Once Hooke is launched from the terminal window, you see a text like
the following:
(c)Massimo Sandal, 2008
'''
-import libhookecurve as lhc
-import libhooke as lh
+from .. import libhookecurve as lhc
+from .. import libhooke as lh
import csv
class csvdriverDriver(lhc.Driver):
2007_02_07: Initial implementation
'''
import string
-import libhookecurve as lhc
+from .. import libhookecurve as lhc
class DataChunk(list):
'''Dummy class to provide ext and ret methods to the data list.
import string
-import libhookecurve as lhc
+from .. import libhookecurve as lhc
class DataChunk(list):
#Dummy class to provide ext and ret methods to the data list.
Massimo Sandal, Allen Chen (c) 2009
'''
-import libhookecurve as lhc
-import libhooke as lh
+from .. import libhookecurve as lhc
+from .. import libhooke as lh
import struct
class mcsDriver(lhc.Driver):
Massimo Sandal (c) 2009
'''
-import libhookecurve as lhc
-import libhooke as lh
+from .. import libhookecurve as lhc
+from .. import libhooke as lh
class mfp1dexportDriver(lhc.Driver):
import re, struct
from scipy import arange
-import libhookecurve as lhc
+from .. import libhookecurve as lhc
__version__='0.0.0.20080404'
import re, struct
from scipy import arange
-import libhookecurve as lhc
+from .. import libhookecurve as lhc
__version__='0.0.0.20081706'
that is, two plots with two datasets each.
'''
-import libhookecurve as lhc #We need to import this library to define some essential data types
+from .. import libhookecurve as lhc #We need to import this library to define some essential data types
class tutorialdriverDriver(lhc.Driver):
'''
This program is released under the GNU General Public License version 2.\r
'''\r
\r
-from libhooke import HOOKE_VERSION\r
-from libhooke import WX_GOOD\r
+from .libhooke import HOOKE_VERSION, WX_GOOD\r
\r
import os\r
\r
import matplotlib.numerix as nx\r
import scipy as sp\r
\r
-from threading import *\r
+from threading import Thread\r
import Queue\r
\r
-from hooke_cli import HookeCli\r
-from libhooke import *\r
-import libhookecurve as lhc\r
+from .hooke_cli import HookeCli\r
+from .libhooke import HookeConfig, ClickedPoint\r
+from . import libhookecurve as lhc\r
\r
#import file versions, just to know with what we're working...\r
from hooke_cli import __version__ as hookecli_version\r
plugin_gui_namespaces=[]\r
for plugin_name in config['plugins']:\r
try:\r
- plugin=__import__(plugin_name)\r
+ hooke_module=__import__('hooke.plugin.'+plugin_name)\r
+ plugin = getattr(hooke_module.plugin, plugin_name)\r
try:\r
- eval('CLI_PLUGINS.append(plugin.'+plugin_name+'Commands)') #take Command plugin classes\r
- plugin_commands_namespaces.append(dir(eval('plugin.'+plugin_name+'Commands')))\r
+ #take Command plugin classes\r
+ commands = getattr(plugin, plugin_name+'Commands')\r
+ CLI_PLUGINS.append(commands)\r
+ plugin_commands_namespaces.append(dir(commands))\r
except:\r
pass\r
try:\r
- eval('GUI_PLUGINS.append(plugin.'+plugin_name+'Gui)') #take Gui plugin classes\r
- plugin_gui_namespaces.append(dir(eval('plugin.'+plugin_name+'Gui')))\r
+ #take Gui plugin classes\r
+ gui = getattr(plugin, plugin_name+'Gui')\r
+ GUI_PLUGINS.append(gui)\r
+ plugin_gui_namespaces.append(dir(gui))\r
except:\r
pass\r
except ImportError:\r
print 'Imported plugin ',plugin_name\r
\r
#eliminate names common to all namespaces\r
-for i in range(len(plugin_commands_namespaces)):\r
- plugin_commands_namespaces[i]=[item for item in plugin_commands_namespaces[i] if (item != '__doc__' and item != '__module__' and item != '_plug_init')]\r
+for i,namespace in enumerate(plugin_commands_namespaces):\r
+ plugin_commands_namespaces[i] = \\r
+ filter(lambda item : not (item.startswith('__')\r
+ or item == '_plug_init'),\r
+ namespace)\r
#check for conflicts in namespaces between plugins\r
#FIXME: only in commands now, because I don't have Gui plugins to check\r
#FIXME: how to check for plugin-defined variables (self.stuff) ??\r
for item in namespace:\r
if item in plugin_commands_names:\r
i=plugin_commands_names.index(item) #we exploit the fact index gives the *first* occurrence of a name...\r
- print 'Error. Plugin ',plugin_name,' defines a function already defined by ',whatplugin_defines[i],'!'\r
+ print 'Error. Plugin %s defines a function %s already defined by %s!' \\r
+ % (plugin_name, item, whatplugin_defines[i])\r
print 'This should not happen. Please disable one or both plugins and contact the plugin authors to solve the conflict.'\r
print 'Hooke cannot continue.'\r
exit()\r
LOADED_DRIVERS=[]\r
for driver_name in config['drivers']:\r
try:\r
- driver=__import__(driver_name)\r
+ hooke_module=__import__('hooke.driver.'+driver_name)\r
+ driver = getattr(hooke_module.driver, driver_name)\r
try:\r
- eval('FILE_DRIVERS.append(driver.'+driver_name+'Driver)')\r
+ FILE_DRIVERS.append(getattr(driver, driver_name+'Driver'))\r
except:\r
pass\r
except ImportError:\r
#make sure we execute _plug_init() for every command line plugin we import\r
for plugin_name in config['plugins']:\r
try:\r
- plugin=__import__(plugin_name)\r
+ hooke_module=__import__('hooke.plugin.'+plugin_name)\r
+ plugin = getattr(hooke_module.plugin, plugin_name)\r
try:\r
eval('plugin.'+plugin_name+'Gui._plug_init(self)')\r
pass\r
# This is a recipe to a the screen.\r
# Modify the following variables as necessary.\r
#aBitmap = wx.Image(name = "wxPyWiki.jpg").ConvertToBitmap()\r
- aBitmap=wx.Image(name='hooke.jpg').ConvertToBitmap()\r
+ aBitmap=wx.Image(name=os.path.join(\r
+ config['install']['docpath'],\r
+ 'hooke.jpg')).ConvertToBitmap()\r
splashStyle = wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT\r
splashDuration = 2000 # milliseconds\r
splashCallback = None\r
#------------------------------------------------------------------------------\r
\r
def main():\r
-\r
- #save the directory where Hooke is located\r
- config['hookedir']=os.getcwd()\r
-\r
- #now change to the working directory.\r
- try:\r
- os.chdir(config['workdir'])\r
- except OSError:\r
- print "Warning: Invalid work directory."\r
-\r
app=wx.PySimpleApp()\r
\r
def make_gui_class(*bases):\r
my_cmdline=CliThread(main_frame, list_of_events)\r
my_cmdline.start()\r
\r
-\r
app.MainLoop()\r
\r
if __name__ == '__main__':\r
This program is released under the GNU General Public License version 2.
'''
-from libhooke import * #FIXME
-import libhookecurve as lhc
-
-import libinput as linp
-import liboutlet as lout
-
-from libhooke import WX_GOOD
-from libhooke import HOOKE_VERSION
+from .libhooke import HOOKE_VERSION, WX_GOOD
import wxversion
wxversion.select(WX_GOOD)
from sys import version as python_version
import platform
+from .libhooke import PlaylistXML
+from . import libhookecurve as lhc
+from . import libinput as linp
+from . import liboutlet as lout
+
-class HookeCli(cmd.Cmd):
+class HookeCli(cmd.Cmd, object):
def __init__(self,frame,list_of_events,events_from_gui,config,drivers):
cmd.Cmd.__init__(self)
self.prompt = 'hooke: '
-
-
self.current_list=[] #the playlist we're using
-
self.current=None #the current curve under analysis.
self.plots=None
'''
then undergoes modifications by the plotmanip
modifier functions. The modified plot is saved in self.plots and used if needed by other functions.
'''
-
-
self.pointer=0 #a pointer to navigate the current list
#Things that come from outside
self.current_list, self.playlist_generics=playxml.load(play_to_load)
self.current_playxml=playxml
except IOError:
- print 'File not found.'
+ print 'File not found.', play_to_load
return
- print 'Loaded %s curves' %len(self.current_list)
+ print 'Loaded %s curves from %s' \
+ % (len(self.current_list), play_to_load)
if 'pointer' in self.playlist_generics.keys():
self.pointer=int(self.playlist_generics['pointer'])
Syntax: plot
'''
def do_plot(self,args):
-
- self.current.identify(self.drivers)
+ if self.current.identify(self.drivers) == False:
+ return
self.plots=self.current.curve.default_plots()
try:
self.plots=self.current.curve.default_plots()
This program is released under the GNU General Public License version 2.
'''
-import libhookecurve as lhc
-
import scipy
import numpy
import xml.dom.minidom
import string
import csv
+from . import libhookecurve as lhc
+
HOOKE_VERSION=['0.8.3_devel', 'Seinei', '2008-04-16']
WX_GOOD=['2.6','2.8']
new_playlist=[]
for myfile in list_of_files:
#rebuild a data structure from the xml attributes
- the_curve=lhc.HookeCurve(myfile.getAttribute('path'))
- for attribute in myfile.attributes.keys(): #extract attributes for the single curve
+ the_curve=lhc.HookeCurve(
+ os.path.join(os.path.dirname(self.playpath),
+ myfile.getAttribute('path')))
+ for attribute in myfile.attributes.keys():
+ #extract attributes for the single curve
+ if attribute == 'path':
+ continue # we already added this attribute
the_curve.__dict__[attribute]=myfile.getAttribute(attribute)
new_playlist.append(the_curve)
self.playlist.writexml(outfile,indent='\n')
outfile.close()
+def config_file_path(filename, config_dir=None):
+ if config_dir == None:
+ config_dir = os.path.abspath(
+ os.path.join(os.path.dirname(os.path.dirname(__file__)), 'conf'))
+ return os.path.join(config_dir, filename)
class HookeConfig(object):
'''
def __init__(self, config_dir=None):
self.config={}
+ self.config['install']={}
self.config['plugins']=[]
self.config['drivers']=[]
self.config['plotmanips']=[]
self.config_dir = config_dir
- if self.config_dir == None:
- self.config_dir = os.path.abspath(
- os.path.join(os.path.dirname(os.path.dirname(__file__)),
- 'conf'))
def load_config(self, filename):
- print 'loading config file', os.path.join(self.config_dir, filename)
- myconfig=file(os.path.join(self.config_dir, filename))
+ myconfig=file(config_file_path(filename, config_dir=self.config_dir))
#the following 3 lines are needed to strip newlines. otherwise, since newlines
#are XML elements too, the parser would read them (and re-save them, multiplying
return rc
def handleConfig(config):
+ install_elements=config.getElementsByTagName("install")
display_elements=config.getElementsByTagName("display")
plugins_elements=config.getElementsByTagName("plugins")
drivers_elements=config.getElementsByTagName("drivers")
- workdir_elements=config.getElementsByTagName("workdir")
defaultlist_elements=config.getElementsByTagName("defaultlist")
plotmanip_elements=config.getElementsByTagName("plotmanips")
+ handleInstall(install_elements)
handleDisplay(display_elements)
handlePlugins(plugins_elements)
handleDrivers(drivers_elements)
- handleWorkdir(workdir_elements)
handleDefaultlist(defaultlist_elements)
handlePlotmanip(plotmanip_elements)
+ def handleInstall(install_elements):
+ for install in install_elements:
+ for node in install.childNodes:
+ if node.nodeType == node.TEXT_NODE:
+ continue
+ path = os.path.abspath(getText(node.childNodes).strip())
+ self.config['install'][str(node.tagName)] = path
+
def handleDisplay(display_elements):
for element in display_elements:
for attribute in element.attributes.keys():
except: #if we allow fancy formatting of xml, there is a text node, so tagName fails for it...
pass
- def handleWorkdir(workdir):
- '''
- default working directory
- '''
- wdir=getText(workdir[0].childNodes)
- self.config['workdir']=wdir.strip()
-
def handleDefaultlist(defaultlist):
'''
default playlist
#bring on all the driver, with his load of methods etc.
#so we can access the whole of it.
self.curve=tempcurve
- del tempcurve
return True
-
- print 'Not a recognizable curve format.'
+ print 'Not a recognizable curve format: ', self.path
return False
viewer.
'''
-import liboutlet as lout
-import libinput as linput
+from . import liboutlet as lout
+from . import libinput as linput
class Viewer(object):
# -*- coding: utf-8 -*-
-from libhooke import WX_GOOD, ClickedPoint
+from hooke.libhooke import WX_GOOD, ClickedPoint
+
import wxversion
wxversion.select(WX_GOOD)
from wx import PostEvent
Non-standard Dependencies:
procplots.py (plot processing plugin)
'''
-from libhooke import WX_GOOD, ClickedPoint
+from hooke.libhooke import WX_GOOD, ClickedPoint
+
import wxversion
wxversion.select(WX_GOOD)
#from wx import PostEvent
#from wx.lib.newevent import NewEvent
import scipy
import scipy.odr
+import scipy.stats
import numpy as np
import copy
import Queue
Other plugin dependencies:
procplots.py (plot processing plugin)
'''
-from libhooke import WX_GOOD
+
+from hooke.libhooke import WX_GOOD
+
import wxversion
wxversion.select(WX_GOOD)
-
import xml.dom.minidom
-
import wx
import scipy
import numpy
from numpy import diff
-
#import pickle
-import libpeakspot as lps
-import libhookecurve as lhc
+from .. import libpeakspot as lps
+from .. import libhookecurve as lhc
class flatfiltsCommands(object):
def _plug_init(self):
#configurate convfilt variables
convfilt_configurator=ConvfiltConfig()
-
- #different OSes have different path conventions
- if self.config['hookedir'][0]=='/':
- slash='/' #a Unix or Unix-like system
- else:
- slash='\\' #it's a drive letter, we assume it's Windows
-
- self.convfilt_config=convfilt_configurator.load_config(self.config['hookedir']+slash+'convfilt.conf')
+ self.convfilt_config=convfilt_configurator.load_config('convfilt.conf')
def do_flatfilt(self,args):
'''
Plugin regarding general force clamp measurements
'''
-from libhooke import WX_GOOD, ClickedPoint
+from hooke.libhooke import WX_GOOD, ClickedPoint
+
import wxversion
-import libhookecurve as lhc
wxversion.select(WX_GOOD)
from wx import PostEvent
+from .. import libhookecurve as lhc
+
+
class generalclampCommands(object):
def plotmanip_clamp(self, plot, current, customvalue=False):
Plugin regarding general velocity clamp measurements
'''
-from libhooke import WX_GOOD, ClickedPoint
+from hooke.libhooke import WX_GOOD, ClickedPoint
import wxversion
wxversion.select(WX_GOOD)
from wx import PostEvent
(c)Alberto Gomez-Casado 2008
'''
-import libhookecurve as lhc
-import libinput as linput
import os.path
import string
+from .. import libhookecurve as lhc
+from .. import libinput as linput
+
class macroCommands(object):
currentmacro=[]
pause=0
auxprompt=[]
- macrodir=[]
+ macrodir=None
def _plug_init(self):
flatfilts.py
'''
-
-import libpeakspot as lps
-import libhookecurve as lhc
-import libhooke as lh
import numpy as np
-
import csv
+from .. import libpeakspot as lps
+from .. import libhookecurve as lhc
+from .. import libhooke as lh
+
class massanalysisCommands(object):
def _plug_init(self):
# -*- coding: utf-8 -*-
-from libhooke import WX_GOOD, ClickedPoint
+from hooke.libhooke import WX_GOOD, ClickedPoint
+
import wxversion
wxversion.select(WX_GOOD)
from wx import PostEvent
+from ..libhooke import WX_GOOD, ClickedPoint, config_file_path
+
from mdp import pca
-from libhooke import WX_GOOD, ClickedPoint
import wxversion
wxversion.select(WX_GOOD)
from wx import PostEvent
import copy
import os.path
import time
-import libhookecurve as lhc
import pylab as pyl
+from .. import libhookecurve as lhc
+
+
import warnings
warnings.simplefilter('ignore',np.RankWarning)
Automatically measures peaks and extracts informations for further clustering
(c)Paolo Pancaldi, Massimo Sandal 2009
'''
- if self.config['hookedir'][0]=='/':
- slash='/' #a Unix or Unix-like system
- else:
- slash='\\'
blindw = str(self.convfilt_config['blindwindow'])
pclus_dir = "pCluster_blind"+blindw+"_"+time.strftime("%Y%m%d_%H%M")
- self.my_work_dir = os.getcwd()+slash+pclus_dir+slash
+ self.my_work_dir = os.path.join(os.getcwd(), pclus_dir)
self.my_curr_dir = os.path.basename(os.getcwd())
os.mkdir(self.my_work_dir)
'''
# reads the columns of pca
- if self.config['hookedir'][0]=='/':
- slash='/' #a Unix or Unix-like system
- else:
- slash='\\'
- self.my_hooke_dir = self.config['hookedir']+slash
- #self.my_work_dir = os.getcwd()+slash+"pCluster_"+time.strftime("%Y%m%d_%H%M")+slash
- #self.my_curr_dir = os.path.basename(os.getcwd())
- conf=open(self.my_hooke_dir+"pca_config.txt")
+ conf=open(config_file_path("pca_config.txt"), 'r')
config = conf.readlines()
conf.close()
Licensed under the GNU GPL version 2
'''
-from libhooke import WX_GOOD
+from ..libhooke import WX_GOOD
import wxversion
wxversion.select(WX_GOOD)
import wx
-import libhookecurve as lhc
import numpy as np
import scipy as sp
import scipy.signal
import copy
+from .. import libhookecurve as lhc
+
+
class procplotsCommands(object):
def _plug_init(self):
-from libhooke import WX_GOOD
+from ..libhooke import WX_GOOD
import wxversion
wxversion.select(WX_GOOD)
from wx import PostEvent
-
-import libhookecurve as lhc
from numpy import arange, mean
+from .. import libhookecurve as lhc
+
class superimposeCommands(object):
def _plug_init(self):
(c)Massimo Sandal 2007
'''
-import libhookecurve as lhc
-
import numpy as np
+from .. import libhookecurve as lhc
+
'''
SYNTAX OF DATA TYPE DECLARATION:
type = type of object
'''
-import libviewer as lview
-import libinput as linput
+from .. import libviewer as lview
+from .. import libinput as linput
class viewerCommands(object):
<playlist>
<generics pointer="0"/>
<element notes="" path="default.000"/>
-</playlist>
\ No newline at end of file
+</playlist>