diff --git a/.travis.yml b/.travis.yml index ad4053c..7db9b6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,4 +13,6 @@ before_script: script: - cp ./.travis/matplotlibrc . - - ./test.sh + - python -m pip install . + - python -m pip install pymoose --pre --upgrade # till we relase 3.2.0 + - ./test.sh diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..9eca5ae --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +recursive-include . *.xml diff --git a/README.md b/README.md index 86df84a..14ab282 100644 --- a/README.md +++ b/README.md @@ -14,99 +14,185 @@ provides a score that reports how closely the two match. # LICENSE This file and the files in this repository are licensed under GPL v3 or later. -# Version +# Install -Latest release is 1.1.0, which can be downloadable at - https://github.com/BhallaLab/FindSim/archive/v1.1.0.zip - https://github.com/BhallaLab/FindSim/archive/v1.1.0.tar.gz +One can get `FindSim` using `python-pip`. + +To install last stable release (__NOTE__ This uses moose version 3.1.4 (outdated +with this release)) + + $ pip install FindSim + +Or, to install the nightly built, + + $ pip install FinSim --pre # recommended + +Alternatively, you can download the source code and install it yourself. + +1. Install MOOSE which can be found here https://moose.ncbs.res.in/readthedocs/install/install.html +2. Install FindSim + +``` +git clone https://github.com/BhallaLab/FindSim +cd FindSim +python setup.py install +``` + +After successful installation, two commands are available at your disposal +`findsim` and `findsim_parallel`. To see the help message, pass `-h` option to +either of these commands. For example, `findsim -h` will show you following +message. + +``` +usage: findsim [-h] [-m MODEL] [-d DUMP_SUBSET] [-p PARAM_FILE] [-t] [-hp] + [-hs] [-o] [-s SCALE_PARAM SCALE_PARAM SCALE_PARAM] + [-settle_time SETTLE_TIME] + script + +FindSim argument parser This program loads a kinetic model, and runs it with +the specified stimuli. The output is then compared with expected output +specified in the same file, to generate a model score. + +positional arguments: + script Required: filename of experiment spec, in tsv format. + +optional arguments: + -h, --help show this help message and exit + -m MODEL, --model MODEL + Optional: model filename, .g or .xml + -d DUMP_SUBSET, --dump_subset DUMP_SUBSET + Optional: dump selected subset of model into named + file + -p PARAM_FILE, --param_file PARAM_FILE + Optional: Generate file of tweakable params belonging + to selected subset of model + -t, --tabulate_output + Flag: Print table of plot values. Default is NOT to + print table + -hp, --hide_plot Hide plot output of simulation along with expected + values. Default is to show plot. + -hs, --hide_subplots Hide subplot output of simulation. By default the + graphs include dotted lines to indicate individual + quantities (e.g., states of a molecule) that are being + summed to give a total response. This flag turns off + just those dotted lines, while leaving the main plot + intact. + -o, --optimize_elec Optimize electrical computation. By default the + electrical computation runs for the entire duration of + the simulation. With this flag the system turns off + the electrical engine except during the times when + electrical stimuli are being given. This can be *much* + faster. + -s SCALE_PARAM SCALE_PARAM SCALE_PARAM, --scale_param SCALE_PARAM SCALE_PARAM SCALE_PARAM + Scale specified object.field by ratio. + -settle_time SETTLE_TIME, --settle_time SETTLE_TIME + Run model for specified settle time and return dict of + {path,conc}. + +``` +Command `findsim_parellel` is a helper utility: it runs multiple simulations +using `findsim` in parellel. -# Install - To run FindSim script one needs to - - Install MOOSE which can be found here - https://moose.ncbs.res.in/readthedocs/install/install.html - - Install FindSim: - Clone the entire repository using - >git clone https://github.com/BhallaLab/FindSim - or, clone specific branch such as "stable" using: - >git clone -b https://github.com/BhallaLab/FindSim - -============================================================================= -# File organization: - FindSim/ : project directory - FindSim/stable : Stable branch. Stable version of `develop` branch - FindSim/Curated : Folder contains FindSim worksheets to which the model is well fit. - FindSim/models : Model files - FindSim/findSim.py : Main findSim script - FindSim/runAllParallel.py : Batch/parallel wrapper script. - FindSim/FindSim-Exptworksheet.xlsx : Template worksheet with inline help and units, for Microsoft Excel. - FindSim/FindSim-Exptworksheet.ods : Template worksheet with inline help and units, for Libre Office. - FindSim/FindSim-Schema.xml : Schema for tsv files for worksheet. - FindSim/README.md : This file - -============================================================================= -# Quick start: -A. Run one of the example experiments on the default model, generating a graph to compare model to experiment: - To run the script, run the command in python and `synSynth7.g` is the latest model that is tested out the worksheets. - >python findSim.py Curated/FindSim-Jain2009-Fig2B.tsv --model synSynth7.g - or - >python findSim.py Curated/FindSim-Jain2009-Fig2B.tsv - -B. Batch run: - -runAllParallel.py script runs the findSim program on all tsv files in the specified directory, computes their scores, and prints out basic stats of the scores. It can do this in parallel using Python's multiprocessing library. +# Quick start + +To run one of the example experiments on the default model (`synSynth7.g`) and generate a graph +to compare model to experiment. + +``` +findsim Curated/FindSim-Jain2009-Fig2B.tsv +``` + +You can also pass the model explicitly, + +``` +findsim Curated/FindSim-Jain2009-Fig2B.tsv --model models/synSynth7.g +``` + + +## Batch run + +To findSim program on all tsv files in the specified directory, computes their +scores, and prints out basic stats of the scores, you should use +`findsim_parallel` command. - >python runAllParallel.py Curated -n 8 (run of the entire set of `Curated` experiments on 8 cores) - or - >python runAllParallel.py Directory (of tsv files) -n (Number of processes to spawn) --model (synSynth7.g) +``` +findsim_parellel Curated -n 8 +``` + +It will run the entire set of `Curated` experiments in parallel using 8 +independant processes (it will be effectively if your computer has at least 8 +cores). The value of `-n` should not be more than `N+1` where `N` is the number +of processors on your system (use system utility `nproc` to see this number). -C. Syntax help: - >python findSim.py -h - >python runAllParallel.py -h +More detailed invocation of this command looks like the following: +``` +findsim_parallel path/to/tsv/files -n 6 --model synSynth7.g +``` -============================================================================= +# Repository organization -Generating Figures for -"FindSim: a Framework for Integrating Neuronal Data and Signaling Models." -by -Nisha A. Viswan, G.V. HarshaRani, Melanie I. Stefan, Upinder S. Bhalla -Front Neuroinform. 2018 Jun 26;12:38. doi: 10.3389/fninf.2018.00038. eCollection 2018. + FindSim/ : project directory + FindSim/stable : Stable branch. Stable version of `develop` branch + FindSim/Curated : Folder contains FindSim worksheets to which the model is well fit. + FindSim/models : Model files + FindSim/findSim.py : Main findSim script + FindSim/runAllParallel.py : Batch/parallel wrapper script. + FindSim/FindSim-Exptworksheet.xlsx : Template worksheet with inline help and units, for Microsoft Excel. + FindSim/FindSim-Exptworksheet.ods : Template worksheet with inline help and units, for Libre Office. + FindSim/FindSim-Schema.xml : Schema for tsv files for worksheet. + FindSim/README.md : This file -All these are run using the development branch "stable" -Please change into the branch to run these. +# Extra + +Generating Figures for __FindSim: a Framework for Integrating Neuronal Data +and Signaling Models by Nisha A. Viswan, G.V. HarshaRani, Melanie I. Stefan, +Upinder S. Bhalla Front Neuroinform. 2018 Jun 26;12:38. doi: +10.3389/fninf.2018.00038. eCollection 2018.__ + +All these are run using the branch `release.1.1.0`. Please change into the +branch to run these. Figure 6: bottom -python findSim.py Curated/FindSim-Jain2009_Fig4F.tsv --model models/synSynth7.g + python findSim.py Curated/FindSim-Jain2009_Fig4F.tsv --model models/synSynth7.g Figure 7B: -python findSim.py Curated/FindSim-Bhalla1999_fig2B.tsv --model models/synSynth7.g -python findSim.py Curated/FindSim-Gu2004_Fig3.tsv --model models/synSynth7.g + python findSim.py Curated/FindSim-Bhalla1999_fig2B.tsv --model models/synSynth7.g + python findSim.py Curated/FindSim-Gu2004_Fig3.tsv --model models/synSynth7.g Figure 7C: -python findSim.py Curated/FindSim-Ji2010_fig1C_ERK_acute.tsv --model models/synSynth7.g + python findSim.py Curated/FindSim-Ji2010_fig1C_ERK_acute.tsv --model models/synSynth7.g Figure 7D: -python findSim.py Curated/FindSim-Bhalla1999_fig4C.tsv --model models/synSynth7.g + python findSim.py Curated/FindSim-Bhalla1999_fig4C.tsv --model models/synSynth7.g + -============================================================================= # Other resources -Project is hosted at https://github.com/BhallaLab/FindSim -The web template for experiment worksheet can be found here https://www.ncbs.res.in/faculty/bhalla-findsim/worksheet +- The web template for experiment worksheet can be found here +https://www.ncbs.res.in/faculty/bhalla-findsim/worksheet + +- The MOOSE site: http://moose.ncbs.res.in. MOOSE documentation: + http://moose.ncbs.res.in/readthedocs/install/index_install.html -The MOOSE site: http://moose.ncbs.res.in +- Two papers were used as the initial basis for the models, and which in turn + refer to a large number of experimental studies for their data: -MOOSE documentation: http://moose.ncbs.res.in/readthedocs/install/index_install.html + 1. Bhalla US., Iyengar R. Emergent properties of networks of biological signaling pathways. Science. 1999 Jan 15;283(5400):381-7. + 2. Jain P, and Bhalla, U.S. Signaling logic of activity-triggered dendritic protein synthesis: an mTOR gate but not a feedback switch. PLoS Comput Biol. 2009 Feb;5(2):e1000287. Epub 2009 Feb 13 -Two papers were used as the initial basis for the models, and which in turn -refer to a large number of experimental studies for their data: - - Bhalla US., Iyengar R. Emergent properties of networks of biological signaling pathways. Science. 1999 Jan 15;283(5400):381-7. - - Jain P, and Bhalla, U.S. Signaling logic of activity-triggered dendritic protein synthesis: an mTOR gate but not a feedback switch. PLoS Comput Biol. 2009 Feb;5(2):e1000287. Epub 2009 Feb 13 +- Two more papers were used for some of the experiments -Two further papers were used for some of the experiments: - - Gu J, et al. Beta1,4-N-Acetylglucosaminyltransferase III down-regulates neurite outgrowth induced by costimulation of epidermal growth factor and integrins through the Ras/ERK signaling pathway in PC12 cells. Glycobiology. 2004 Feb;14(2):177-86. Epub 2003 Oct 23 - - Ji Y, et al. Acute and gradual increases in BDNF concentration elicit distinct signaling and functions in neurons. Nat Neurosci. 2010 Mar;13(3):302-9. doi: 10.1038/nn.2505. Epub 2010 Feb 21. + 1. Gu J, et al. Beta1,4-N-Acetylglucosaminyltransferase III down-regulates + neurite outgrowth induced by costimulation of epidermal growth factor and + integrins through the Ras/ERK signaling pathway in PC12 cells. + Glycobiology. 2004 Feb;14(2):177-86. Epub 2003 Oct 23 + 2. Ji Y, et al. Acute and gradual increases in BDNF concentration elicit + distinct signaling and functions in neurons. Nat Neurosci. 2010 + Mar;13(3):302-9. doi: 10.1038/nn.2505. Epub 2010 Feb 21. -DOQCS database, from which models were derived: http://doqcs.ncbs.res.in - Sivakumaran S. et al. The Database of Quantitative Cellular Signaling: management and analysis of chemical kinetic models of signaling networks. -Bioinformatics. 2003. 19(3):408–415 +- DOQCS database, from which models were derived: http://doqcs.ncbs.res.in + __Sivakumaran S. et al. The Database of Quantitative Cellular Signaling: + management and analysis of chemical kinetic models of signaling networks. + Bioinformatics. 2003. 19(3):408–415__ diff --git a/TestTSV/fepsp.tsv b/TestTSV/fepsp.tsv new file mode 100644 index 0000000..ba9fcb1 --- /dev/null +++ b/TestTSV/fepsp.tsv @@ -0,0 +1,80 @@ +Experiment metadata +transcriber Upi +organization NCBS +emailId bhalla@ncbs.res.in +exptSource None +citationId None +authors None +journal None. This is a purely fictional _experiment_ for the purposes of testing findSim + + +Experiment context +exptType TimeSeries +species rat +cell-types hippocampal CA1 pyramidal neuron +temperature (Celsius) 30 +Include all +details +notes HFS, LTP + +Stimuli +compartment dend +timeUnits sec +quantityUnits Hz +entities synInput +field rate +Data +Time Value +0 0 +10 100 +11 0 + +Stimuli +compartment dend +timeUnits sec +quantityUnits ratio +entities synapse +field weight +Data +Time Value +0 1 +10 1 +11 0.4 + + +Readouts +timeUnits sec +quantityUnits mV +useXlog FALSE +useYlog FALSE +ratioReferenceTime 1 +ratioReferenceEntity soma +entities soma +field fEPSP_peak +useNormalization False +Data +Time Value stderr +6 0.15 0 +8 0.15 0 +15 0.4 0 +16 0.45 0 +17 0.5 0 +18 0.55 0 +20 0.6 0 + +Model mapping +modelSource internal +fileName models/plastic8.py +citationId +citation +authors +modelSubset all +modelLookup soma:elec/soma,synInput:elec/head0/glu/sh/synapse/synInput,synapse:elec/head0/glu/sh/synapse +scoringFormula abs((expt-sim)/(datarange+1e-9)) +solver none +notes +# Monitor response with a low stimulus amplitude/weight with initial +# test pulses 4 and 8 sec. Then give a 100Hz synaptic input at t = 10-11s. +# Then monitor response at 15, 20 s. + + diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/__main__.py b/__main__.py new file mode 100644 index 0000000..06bfcc5 --- /dev/null +++ b/__main__.py @@ -0,0 +1,23 @@ +"""__main__.py: + +Entry point for this package. +""" + +__author__ = "Dilawar Singh" +__copyright__ = "Copyright 2017-, Dilawar Singh" +__version__ = "1.0.0" +__maintainer__ = "Dilawar Singh" +__email__ = "dilawars@ncbs.res.in" +__status__ = "Development" + + +def run(): + from FindSim import findSim + findSim.main() + +def run_parallel(): + from FindSim import runAllParallel + runAllParallel.main() + +if __name__ == '__main__': + run() diff --git a/findSim.py b/findSim.py index 14a3b5a..da49ef5 100644 --- a/findSim.py +++ b/findSim.py @@ -33,9 +33,8 @@ **********************************************************************/ ''' -from __future__ import print_function +from __future__ import print_function, absolute_import import heapq -#import pylab import numpy as np import sys import argparse @@ -45,22 +44,24 @@ import ntpath import time import imp # This is apparently deprecated in Python 3.4 and up +import matplotlib.pyplot as pyplot -import matplotlib.pyplot as pyplot,mpld3 - -#mpld3 hack +# mpld3 hack # suggested: https://github.com/mpld3/mpld3/issues/434 import json + class NumpyEncoder(json.JSONEncoder): + # pylint: disable=method-hidden def default(self, obj): import numpy as np if isinstance(obj, np.ndarray): return obj.tolist() return json.JSONEncoder.default(self, obj) + +import mpld3 from mpld3 import _display _display.NumpyEncoder = NumpyEncoder - convertTimeUnits = {('sec','s') : 1.0, ('ms','millisec', 'msec') : 1e-3,('us','microsec') : 1e-6, ('ns','nanosec') : 1e-9, ('min','m') : 60.0, @@ -719,7 +720,7 @@ def isNotDescendant( elm, ancestorSet ): def getObjParam( elm, field ): if field == 'Kd': if not elm.isA['ReacBase']: - raise SimError( "getObjParam: can only get Kd on a Reac, was: '{}'".format( obj.className ) ) + raise SimError( "getObjParam: can only get Kd on a Reac, was: '{}'".format( elm.className ) ) return elm.Kb/elm.Kf elif field == 'tau': # This is a little dubious, because order 1 reac has 1/conc.time @@ -727,7 +728,7 @@ def getObjParam( elm, field ): # This latter is the Kf we want to use, assuming typical concs are # around 1 uM. if not elm.isA['ReacBase']: - raise SimError( "getObjParam: can only get tau on a Reac, was: '{}'".format( obj.className ) ) + raise SimError( "getObjParam: can only get tau on a Reac, was: '{}'".format( elm.className ) ) scaleKf = 0.001 ** (elm.numSubstrates-1) scaleKb = 0.001 ** (elm.numProducts-1) #print( "scaleKf={}; scaleKb={}, numsu ={}, numPrd={},Kb={},Kf={}".format( scaleKf, scaleKb, elm.numSubstrates, elm.numProducts, elm.Kb, elm.Kf ) ) @@ -1111,7 +1112,7 @@ def parseAndRunDoser( model, stims, readouts, modelId ): exactly one stimulus block, {} defined".format( len(stims)) ) if len( readouts ) != 1: raise SimError( "parseAndRunDoser: Dose response run needs \ - exactly one readout block, {} defined".format( len(readout) ) ) + exactly one readout block, {} defined".format( len(readouts) ) ) numLevels = len( readouts[0].data ) if numLevels == 0: @@ -1208,7 +1209,7 @@ def parseAndRunBarChart( model, stims, readouts, modelId ): one stimulus block, {} defined".format( len( stims ) ) ) if len( readouts ) != 1: raise SimError( "parseAndRunBarChart: BarChart run needs exactly \ - one readout block, {} defined".format( len( readout ) ) ) + one readout block, {} defined".format( len( readouts ) ) ) numLevels = len( readouts[0].data ) if numLevels == 0: diff --git a/models/loadhh.py b/models/loadhh.py index 6d786de..6eb80fa 100644 --- a/models/loadhh.py +++ b/models/loadhh.py @@ -2,11 +2,13 @@ import rdesigneur as rd def load(): rdes = rd.rdesigneur( - turnOffElec = True, + turnOffElec = False, chanProto = [['make_HH_Na()', 'Na'], ['make_HH_K()', 'K']], chanDistrib = [ ['Na', 'soma', 'Gbar', '1200' ], ['K', 'soma', 'Gbar', '360' ]], ) + return rdes + +def build( rdes ): rdes.buildModel() - return rdes.model diff --git a/models/plastic8.py b/models/plastic8.py index 4e47824..82756ca 100644 --- a/models/plastic8.py +++ b/models/plastic8.py @@ -19,7 +19,7 @@ def load(): chemDt = 0.002, diffDt = 0.002, chemPlotDt = 0.02, - turnOffElec = True, #FindSim needs to create Vclamp and then solver. + turnOffElec = False,#FindSim needs to create Vclamp and then solver. useGssa = False, # cellProto syntax: ['ballAndStick', 'name', somaDia, somaLength, dendDia, dendLength, numDendSegments ] cellProto = [['ballAndStick', 'soma', 12e-6, 12e-6, 4e-6, 100e-6, 1 ]], @@ -52,6 +52,11 @@ def load(): stimList = [['head#', '0.2','glu', 'periodicsyn', '0']], ) moose.seed(1234567) + + return rdes + + +def build( rdes ): rdes.buildModel() #moose.element( '/model/chem/dend/ksolve' ).numThreads = 4 #moose.showfield( '/model/chem/dend/ksolve' ) @@ -63,5 +68,3 @@ def load(): #moose.showmsg( '/model/elec/head0/glu/sh/synapse/synInput_rs' ) #import presettle_CaMKII_MAPK7_init moose.reinit() - - return rdes.model diff --git a/multi_param_minimization.py b/multi_param_minimization.py index 6434740..b9c8653 100644 --- a/multi_param_minimization.py +++ b/multi_param_minimization.py @@ -107,9 +107,10 @@ def doEval( self, x ): paramList.append( obj ) paramList.append( field ) paramList.append( j ) + #print( "{:6.3f}".format(j), end = "" ) for k in self.expts: - ret.append( self.pool.apply_async( findSim.innerMain, (k,), dict(modelFile = self.modelFile, hidePlot=True, silent=True, scaleParam=paramList), callback = reportReturn ) ) + ret.append( self.pool.apply_async( findSim.innerMain, (k,), dict(modelFile = self.modelFile, hidePlot=True, silent=True, scaleParam=paramList, tabulateOutput = False ), callback = reportReturn ) ) self.score = [ i.get() for i in ret ] sumScore = sum([ s*w for s,w in zip(self.score, self.weights) if s>=0.0]) sumWts = sum( [ w for s,w in zip(self.score, self.weights) if s>=0.0 ] ) @@ -166,6 +167,8 @@ def main(): results = optimize.minimize( ev.doEval, np.ones( len(params) ), method='L-BFGS-B', tol = args.tolerance, callback = optCallback, bounds = bounds ) print( "\n----------- Completed in {:.3f} sec ---------- ".format(time.time() - t0 ) ) print( "\n----- Score= {:.4f} ------ ".format(results.fun ) ) + + dumpData = False fp = "" if len( args.file ) > 0: @@ -208,12 +211,10 @@ def tweakParams( params, scaleFactors ): obj.Kb /= x else: obj.setField( field, obj.getField( field ) * x ) - #print( "Tweaked {}.{} by {}".format( obj.path, field, x ) ) def analyzeResults( fp, dumpData, results, params, evalObj, initScore ): - #assert( len(results.x) == len( results.fun ) ) assert( len(results.x) == len( params ) ) out = [] for p,x, in zip(params, results.x): @@ -224,12 +225,12 @@ def analyzeResults( fp, dumpData, results, params, evalObj, initScore ): numSum = 0.0 assert( len( evalObj.expts ) == len( initScore ) ) for e, i, f, w in zip( evalObj.expts, initScore, evalObj.score, evalObj.weights ): - out.append( "{:40s}{:12.3f}{:12.3f}{:12.3f}".format( e, i, f, w ) ) + out.append( "{:40s}{:12.5f}{:12.5f}{:12.3f}".format( e, i, f, w ) ) if i >= 0: initSum += i * w finalSum += f * w numSum += w - out.append( "\nInit score = {:.4f}, final = {:.4f}".format(initSum/numSum, finalSum / numSum) ) + out.append( "\nInit score = {:.4f}, final = {:.8f}".format(initSum/numSum, results.fun ) ) for i in out: print( i ) if dumpData: diff --git a/requirements.txt b/requirements.txt index b485fe7..4fe1a87 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,6 @@ numpy matplotlib networkx +pymoose +mpld3 +scipy diff --git a/runAllParallel.py b/runAllParallel.py index 4c8c4c9..73daa8e 100644 --- a/runAllParallel.py +++ b/runAllParallel.py @@ -1,5 +1,5 @@ +# -*- coding: utf-8 -*- -# # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 3, or @@ -35,17 +35,27 @@ directory, computes their scores, and prints out basic stats of the scores. It can do this in parallel using Python's multiprocessing library. ''' +from __future__ import print_function, division -from __future__ import print_function import numpy import argparse import os import sys import argparse import time -import findSim from multiprocessing import Pool +# Python 2/3 pain (import and scripts). See https://stackoverflow.com/a/49480246/1805129 +# This 'hack' is here to make sure that `python runAllParallel.py` also works +# and described in old documents. +if sys.version_info.major > 2: + if __package__ is None or __package__ == '': + import findSim + else: + from FindSim import findSim +else: + import findSim + resultCount = 0 def reportReturn( result ): global resultCount @@ -115,8 +125,8 @@ def main(): numGood += 1 sumScore += j * w sumWts += w - print( "Weighted Score out of {:.0f} good runs = {:.3f}. Runtime = {:.3f} sec".format( numGood, sumScore / sumWts, time.time() - t0 ) ) - #print( "{0} : {1:.2f}".format( i, j ) ) + print( "Weighted Score out of {:.0f} good runs = {:.3f}. Runtime = {:.3f} sec".format( + numGood, sumScore / sumWts, time.time() - t0 ) ) # Run the 'main' if this script is executed standalone. diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..db8224e --- /dev/null +++ b/setup.py @@ -0,0 +1,47 @@ +"""setup.py: + Packaging script for FindSim. +""" + +__author__ = "Dilawar Singh" +__copyright__ = "Copyright 2017-, Dilawar Singh" +__maintainer__ = "Dilawar Singh" +__email__ = "dilawars@ncbs.res.in" + +import os +import sys +import setuptools + +with open("README.md") as f: + readme = f.read() + +version_ = '1.0.2' +isPre_ = True +if isPre_: + import datetime + version_ += '.dev' + datetime.datetime.today().strftime('%Y%m%d') + print( "[INFO ] Building version %s" % version_ ) + + + +setuptools.setup( + name = "FindSim", + version = version_, + description = "A Framework for Integrating Neuronal Data and Singalling Model", + long_description = readme, + long_description_content_type = "text/markdown", + packages = [ "FindSim" ], + package_dir = { "FindSim" : "."}, + install_requires = [ 'pymoose', 'scipy', 'mpld3', 'networkx' ], + author = "Dilawar Singh", # author of packaging. See contributors for + # the list of authors + author_email = "dilawar@ncbs.res.in", + url = "http://github.com/BhallaLab/FindSime", + package_data = { "FindSim" : [ '*.csv', '*.xml' ] }, + license='GPLv3', + entry_points = { + 'console_scripts' : [ + 'findsim = FindSim.__main__:run', + 'findsim_parallel = FindSim.__main__:run_parallel' + ] + }, + ) diff --git a/test.sh b/test.sh index d868a58..8d954fc 100755 --- a/test.sh +++ b/test.sh @@ -1,7 +1,21 @@ #!/usr/bin/env bash - set -e +INVENV=$(python -c 'import sys; print ("1" if hasattr(sys, "real_prefix") else "")') + +echo "INVENV ${INVENV}" +if [ -z "$INVENV" ]; then + if [ -z "$TRAVIS" ]; then + echo "Not on travis. I'll set a virtualenv for you" + python -m pip install virtualenv --user --upgrade + virtualenv -p $(which python) /tmp/envPY + source /tmp/envPY/bin/activate + fi +else + echo "Already in virtualenv. How cool!" +fi + +# FROM NOW ON WE MUST BE IN A VIRTUALENV. # virtualenv does not require --user PYTHON=$(which python) @@ -14,17 +28,24 @@ if [ "$PYTHON_VERSION" -eq "27" ]; then else # $PYTHON -m pip uninstall matplotlib -y || echo "Failed to remove matplotlib" $PYTHON -m pip install matplotlib --upgrade - $PYTHON -m pip install --upgrade + $PYTHON -m pip install scipy --upgrade fi -$PYTHON -m pip install Jinja2 + +# travis.yml should install FindSim +$PYTHON -m pip install Jinja2 --upgrade +$PYTHON -m pip install pylint --upgrade $PYTHON -m pip install mpld3 $PYTHON -m pip install pymoose --pre --upgrade -$PYTHON -m pip install pylint numpy --upgrade +$PYTHON -m pip install . +echo "PYLINT START=======================================================" find . -type f -name "*.py" | xargs -I file $PYTHON -m pylint \ --disable=no-member \ - --exit-zero \ + --generated-members=moose \ -E file +echo "========================================================PYLINT DONE" +echo " " +echo " " # Run it in ./TestTSV directory. for _tsv in $(find ./TestTSV -name *.tsv -type f); do @@ -32,9 +53,17 @@ for _tsv in $(find ./TestTSV -name *.tsv -type f); do $PYTHON findSim.py ${_tsv} --model models/synSynth7.g done -$PYTHON findSim.py ./Curated/FindSim-Jain2009_Fig4F.tsv --model models/synSynth7.g -$PYTHON findSim.py ./Curated/FindSim-Bhalla1999_fig2B.tsv --model models/synSynth7.g +time findsim ./Curated/FindSim-Jain2009_Fig4F.tsv --model models/synSynth7.g +time findsim ./Curated/FindSim-Bhalla1999_fig2B.tsv --model models/synSynth7.g # Following takes a lot of time to run. -#$PYTHON findSim.py ./Curated/FindSim-Gu2004_fig3B.tsv --model models/synSynth7.g -$PYTHON findSim.py ./Curated/FindSim-Ji2010_fig1C_ERK_acute.tsv --model models/synSynth7.g -$PYTHON findSim.py ./Curated/FindSim-Bhalla1999_fig4C.tsv --model models/synSynth7.g +#findsim ./Curated/FindSim-Gu2004_fig3B.tsv --model models/synSynth7.g +time findsim ./Curated/FindSim-Ji2010_fig1C_ERK_acute.tsv --model models/synSynth7.g +time findsim ./Curated/FindSim-Bhalla1999_fig4C.tsv --model models/synSynth7.g +timeout 60 findsim_parallel Curated -n 4 || echo "Timedout. We call it success!" + +# deactivate venv if we are in it. +if [ ! -z "$INVENV" ]; then + if [ -z "$TRAVIS" ]; then + deactivate + fi +fi