def saveECD(LoggerList, FullPN):
    Data = LoggerList[0].getData()
    Data = np.matrix(Data)
    Data = Data[:, 0]
    Data = Data.tolist()
    rabelrows = ['time']
    for i in range(len(LoggerList)):
        Next_Data = LoggerList[i].getData()
        rabel = LoggerList[i].getName()
        if len(Next_Data) > 1:
            rabelrows.append(rabel)

        else:
            pass

        for j in range(len(Data)):
            if len(Next_Data) > RECORDING_TIME * 200:
                Data[j].append(Next_Data[2 * j][1])
            elif len(Next_Data) > RECORDING_TIME * 100:
                Data[j].append(Next_Data[j][1])

            else:
                pass

    Data.insert(0, rabelrows)
    Data = np.array(Data)
    ECDFile = ECDDataFile(Data)
    ECDFile.setDataName(VmLogger.getName())
    ECDFile.setNote(FullPN + 'is' + str(VALUE_OF_GX))
    FullPN = FullPN.replace(':', '_')
    FullPN = FullPN.replace('/', '_')
    filename = FullPN + str(VALUE_OF_GX) + '.ecd'
    ECDFile.save(filename)
Ejemplo n.º 2
0
def saveECD(LoggerList, FullPN):
    Data = LoggerList[0].getData()
    Data = np.matrix(Data)
    Data = Data[:, 0]
    Data = Data.tolist()
    rabelrows = ["time"]
    for i in range(len(LoggerList)):
        Next_Data = LoggerList[i].getData()
        rabel = LoggerList[i].getName()
        if len(Next_Data) > 1:
            rabelrows.append(rabel)

        else:
            pass

        for j in range(len(Data)):
            if len(Next_Data) > RECORDING_TIME * 200:
                Data[j].append(Next_Data[2 * j][1])
            elif len(Next_Data) > RECORDING_TIME * 100:
                Data[j].append(Next_Data[j][1])

            else:
                pass

    Data.insert(0, rabelrows)
    Data = np.array(Data)
    ECDFile = ECDDataFile(Data)
    ECDFile.setDataName(VmLogger.getName())
    ECDFile.setNote(FullPN + "is" + str(VALUE_OF_GX))
    FullPN = FullPN.replace(":", "_")
    FullPN = FullPN.replace("/", "_")
    filename = FullPN + str(VALUE_OF_GX) + ".ecd"
    ECDFile.save(filename)
run(RECORDING_TIME)

#save simulation log of membrane potential in files as csv and ecd.
pretimecourse = VmLogger.getData()
precsvfile = open('Vm' + '_' + FullPN_GX + '_' + str(VALUE_OF_GX) + '.csv',
                  'w')
writer = csv.writer(precsvfile)
pretimecourse_csv = np.matrix(pretimecourse)
pretimecourse_csv = pretimecourse_csv.tolist()
name = ['time', 'Vm']
pretimecourse_csv.insert(0, ['time', 'Vm'])
writer.writerows(pretimecourse_csv)
pretimecourse = ECDDataFile(pretimecourse)
pretimecourse.setDataName(VmLogger.getName())
pretimecourse.setNote(VmLogger.getName())
pretimecourse.save('Vm' + '_' + FullPN_GX + '_' + str(VALUE_OF_GX) + '.ecd')

#save simulation log of all variable except for membrane potential in a file as csv.
saveCSV(allLoggerList, FullPN_GX)

#
print currentnumber
if currentnumber == endnumber - 1:
    print "end"

else:
    print "continue"

print FullPN_GX + '_' + str(VALUE_OF_GX)
print endnumber
Ejemplo n.º 4
0
	aTimeCouse.load( _DATA_ + os.sep + TRAINING_DATA_FILE_LIST[i] )
	aTrainingTimeCourseList.append( aTimeCouse )

# --------------------------------------------------------
# (6) save predicted time-course
# --------------------------------------------------------
aPredictedTimeCouseList = []

for i in range( len(aLoggerList) ):
	
	aTimeCouse = ECDDataFile( aLoggerList[i].getData(START_TIME, \
							 DULATION + INTERVAL, \
							 INTERVAL) )
	aTimeCouse.setDataName( aLoggerList[i].getName() )
	aTimeCouse.setNote( 'Predicted %s' %VARIABLE_LIST_FOR_LOGGER[i] )
	aTimeCouse.save( PREFIX_OF_PREDICTED_TIMECOURSE + \
			 TRAINING_DATA_FILE_LIST[i] )

	aPredictedTimeCouseList.append( aTimeCouse )



# --------------------------------------------------------
# (7) calculate the difference between the training and 
#     the prediction simulated time-course.
# --------------------------------------------------------
aDifference = 0.0

for i in range(aTrainingTimeCourseList[0].getSize()[1]):

	for j in range(len(aTrainingTimeCourseList)):
Ejemplo n.º 5
0
VmLogger.setLoggerPolicy([1, 0.1, 1, 1000000])
run(RECORDING_TIME)

# save simulation log of membrane potential in files as csv and ecd.
pretimecourse = VmLogger.getData()
precsvfile = open("Vm" + "_" + FullPN_GX + "_" + str(VALUE_OF_GX) + ".csv", "w")
writer = csv.writer(precsvfile)
pretimecourse_csv = np.matrix(pretimecourse)
pretimecourse_csv = pretimecourse_csv.tolist()
name = ["time", "Vm"]
pretimecourse_csv.insert(0, ["time", "Vm"])
writer.writerows(pretimecourse_csv)
pretimecourse = ECDDataFile(pretimecourse)
pretimecourse.setDataName(VmLogger.getName())
pretimecourse.setNote(VmLogger.getName())
pretimecourse.save("Vm" + "_" + FullPN_GX + "_" + str(VALUE_OF_GX) + ".ecd")

# save simulation log of all variable except for membrane potential in a file as csv.
saveCSV(allLoggerList, FullPN_GX)

#
print currentnumber
if currentnumber == endnumber - 1:
    print "end"

else:
    print "continue"

print FullPN_GX + "_" + str(VALUE_OF_GX)
print endnumber
Ejemplo n.º 6
0
Archivo: run.py Proyecto: ecell/ecell3
# print some values
message( 't= \t%s' % getCurrentTime() )
message( 'S:Value= \t%s' % S.getProperty( 'Value' ) )
message( 'S:MolarConc= \t%s' % S.getProperty( 'MolarConc' ) )
# run
duration = 1000
message( '\n' )
message( 'run %s sec.\n' % duration )
run( duration )


# print results
message( 't= \t%s' % getCurrentTime() )
message( 'S:Value= \t%s' % S.getProperty( 'Value' ) )
message( 'S:MolarConc= \t%s' % S.getProperty( 'MolarConc' ) )

message( '\n' )

from ecell.ECDDataFile import *

message('saving S.ecd..')
aDataFile = ECDDataFile( S_Logger.getData(0,2000,.5) )
aDataFile.setDataName( S_Logger.getName() )
aDataFile.setNote( '' )
aDataFile.save( 'S.ecd' )

#message('loading')
#aNewFile = ECDDataFile()
#aNewFile.load( 'S.ecd' )
#print aNewFile.getData()[:10]
Ejemplo n.º 7
0
run(RECORDING_TIME)

saveCSV(allLoggerList,FullPN_GX)

pretimecourse     = VmLogger.getData()
precsvfile        = open('Vm' + '_' + FullPN_GX + '_' + str(VALUE_OF_GX) + '.csv','w')
writer            = csv.writer(precsvfile)
pretimecourse_csv = np.matrix(pretimecourse)
pretimecourse_csv = pretimecourse_csv.tolist()
name = ['time','Vm']
pretimecourse_csv.insert(0,['time','Vm'])
writer.writerows(pretimecourse_csv)

pretimecourse = ECDDataFile(pretimecourse)
pretimecourse.setDataName(VmLogger.getName()) 
pretimecourse.setNote(VmLogger.getName())
pretimecourse.save('Vm' + '_' + FullPN_GX + '_' +  str(VALUE_OF_GX) + '.ecd')


currentnumber += 1
print currentnumber
if currentnumber == endnumber:
    print "end" 

else:
    print "continue"

print GXList[currentnumber]
print FullPN_GX

Ejemplo n.º 8
0
run( DULATION + INTERVAL )
step( 1 )


# --------------------------------------------------------
# (6) save predicted time-course
# --------------------------------------------------------
predictedTimeCouseDict = {}

for FullPN in TRAINING_TIME_COURSE_DATA_DICT.keys():
    
    aTimeCouse = ECDDataFile( aLoggerDict[ FullPN ].getData(
                              START_TIME, DULATION + INTERVAL, INTERVAL) )
    aTimeCouse.setDataName( aLoggerDict[ FullPN ].getName() )
    aTimeCouse.setNote( 'Predicted {}'.format( FullPN ) )
    aTimeCouse.save( PREFIX_OF_PREDICTED_TIMECOURSE + \
             TRAINING_TIME_COURSE_DATA_DICT[ FullPN ]['ECDFileName'] )

    predictedTimeCouseDict[ FullPN ] = aTimeCouse


# --------------------------------------------------------
# (7) calculate the difference between the training and 
#     the prediction simulated time-course.
# --------------------------------------------------------
aDifference = 0.0
data_size = None

for FullPN in TRAINING_TIME_COURSE_DATA_DICT.keys():

    if data_size == None:
        data_size = TRAINING_TIME_COURSE_DATA_DICT[ FullPN ]['ECDData'].getSize()[ 1 ]
Ejemplo n.º 9
0
# print some values
message( 't= \t%s' % getCurrentTime() )
message( 'S:Value= \t%s' % S.getProperty( 'Value' ) )
message( 'S:MolarConc= \t%s' % S.getProperty( 'MolarConc' ) )
# run
duration = 1000
message( '\n' )
message( 'run %s sec.\n' % duration )
run( duration )


# print results
message( 't= \t%s' % getCurrentTime() )
message( 'S:Value= \t%s' % S.getProperty( 'Value' ) )
message( 'S:MolarConc= \t%s' % S.getProperty( 'MolarConc' ) )

message( '\n' )

from ecell.ECDDataFile import *

message('saving S.ecd..')
aDataFile = ECDDataFile( S_Logger.getData(0,2000,.5) )
aDataFile.setDataName( S_Logger.getName() )
aDataFile.setNote( '' )
aDataFile.save( 'S.ecd' )

#message('loading')
#aNewFile = ECDDataFile()
#aNewFile.load( 'S.ecd' )
#print aNewFile.getData()[:10]
Ejemplo n.º 10
0
# --------------------------------------------------------
# (3) create logger stubs
# --------------------------------------------------------
logger_dict = {}

for a_target_FullPN in TARGET:
    logger_dict[a_target_FullPN] = createLoggerStub(a_target_FullPN)
    logger_dict[a_target_FullPN].create()

# --------------------------------------------------------
# (4) run
# --------------------------------------------------------

run(11.0)
step(1)

# --------------------------------------------------------
# (6) save predicted time-course
# --------------------------------------------------------
aPredictedTimeCouseList = []

for a_FullPN, a_Logger in logger_dict.items():

    a_time_course = ECDDataFile(a_Logger.getData(0, 11, 0.01))
    a_time_course.setDataName(a_Logger.getName())
    a_time_course.setNote('Predicted {}'.format(a_FullPN))
    a_time_course.save('{}.ecd'.format(a_FullPN.split(':')[2]))

# end of this file