-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
48 lines (40 loc) · 1.2 KB
/
example.py
File metadata and controls
48 lines (40 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Import libraries
import h5py
import numpy as np
import matplotlib.pyplot as plt
from fret_analyzer import FRETAnalyzer
from fret_analyzer_HMM import FRETAnalyzerHMM
# Set parameters
print("Setting parameters")
num_data = 1000 # Number of data points
parameters = {
'dt': 1e6, # Time step in nanoseconds
'kT': 4.114, # Temperature in kT
'R0': 5, # Characteristic FRET distance in nanometers
}
# Load data
print("Loading data")
file = 'data/exampledata.h5'
h5 = h5py.File(file, 'r')
data = h5['data'][()]
h5.close()
data = data[:, :num_data]
# Run analysis using Skipper-FRET
print("Running analysis using Skipper-FRET")
MAP = FRETAnalyzer.learn_potential(
data, parameters=parameters, num_iter=10,
)
# Plot variables
print("Plotting variables")
FRETAnalyzer.plot_variables(data, MAP)
# # Uncomment this code block to run the HMM analysis
# # Run analysis using HMM
# print("Running analysis using HMM")
# MAP_HMM = FRETAnalyzerHMM.learn_potential(
# data, parameters=parameters, num_iter=100,
# )
# energies = FRETAnalyzerHMM.calculate_energy(MAP_HMM) # Get energies
# print("Energies:", energies)
# FRETAnalyzerHMM.plot_variables(data, MAP_HMM) # Plot variables
# Done
print("Done")