## Run via scan task because this gives only best values in function
    ## evaluations, rather than the periodic function evaluations as well
    print '\n\n'
    print report_name
    print '\n'
    PyCoTools.pycopi.Scan(copasi_file,
                          ScanType='repeat',
                          Run=mode,
                          NumberOfSteps=1,
                          ReportName=report,
                          ReportType='parameter_estimation')


#data.shape[0]*0.01)
if __name__ == '__main__':
    C = FilePaths.Celliere2011Example()

    if os.path.isdir(C.PEData_dir):
        PEData_path = C.PEData_dir
    elif os.path.isdir(C.PEData_dir) != True:
        if os.path.isfile(C.PEData_file):
            PEData_path = C.PEData_file

    if os.path.isdir(PEData_path) != True:
        raise TypeError

    data = PyCoTools.PEAnalysis.ParsePEData(PEData_path).data
    print data

#    if sys.platform=='win32':
#        '''
Beispiel #2
0
Author: 
    Ciaran Welsh
Date:
    12/03/2017

"""
import PyCoTools
import os
import pandas
import numpy
from shutil import copy
import FilePaths

## Instantiate class contianing file paths for Kholodenko example
K = FilePaths.KholodenkoExample()

## Set up a parameter estimation
'''
First instantiate ParameterEstimation class
with chosen keyword arguments. define the method variables within the PE class using the key word arguments
'''

PE = PyCoTools.pycopi.ParameterEstimation(
    K.kholodenko_model,  #model
    K.noisy_timecourse_report,  #experimental data
    Method='GeneticAlgorithm',  #use a quick global algorithm 
    NumberOfGenerations=300,  #set Generation Number and population size
    PopulationSize=150,
    SwarmSize=200,
    IterationLimit=3000,
#               senseval-3 : /home/kanghj/ims_0.9.2/EnglishLS.train/EnglishLS.train.xml
#                           /home/kanghj/ims_0.9.2/EnglishLS.train/EnglishLS.train.key       


# todo : add directory mode for xml file and key file
_config = {
        'xml_file': FilePaths.SENSEVAL_3_XML,
        'key_file': FilePaths.SENSEVAL_3_KEY,
        'dtd' : '/home/kanghj/ims_0.9.2/corpora/english-lex-sample/train/lexical-sample.dtd',
        'feature_extractor': context_common_words,
        'output_directory': 'common_words/'

        }

if __name__ == '__main__':
    FilePaths.make_dir(_config['output_directory'] )
    
    
    word_to_common_contexual_words = _config['feature_extractor']((_config['xml_file'], _config['dtd']), _config['key_file'])

    # make a file for each word
    for word, context_common_words in word_to_common_contexual_words.iteritems():
        with codecs.open(_config['output_directory'] + word, 'w+') as feature_file:

            for context_word in context_common_words:
                try:
                    feature_file.write(context_word.decode('utf8') + '\n')
                except UnicodeEncodeError as e:
                    pass # ignore because it probably doesn't matter
    
    print 'All completed for '