-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChopRNAPulls.ipf
151 lines (124 loc) · 4.49 KB
/
ChopRNAPulls.ipf
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
Function NumStepsOrRamps(Settings,SettingsStr)
Wave Settings
Wave/T SettingsStr
StrSwitch(SettingsStr[%CurrentMode])
Case "LocalRamp":
Variable TimePerRamp=Settings[%Distance]/Settings[%ApproachVelocity]+Settings[%Distance]/Settings[%RetractVelocity]+Settings[%DwellTime]
// Setup parms for loop
Return Floor(Settings[%TotalTime]/TimePerRamp)
break
Case "Steps":
Return Settings[%NumSteps]
break
EndSwitch
End
Function GetRamp(RNASettings, ForceOrZSensorData)
Wave RNASettings,ForceOrZSensorData
Variable PointsPerRamp=Floor(RNASettings[%SamplingRate]*(RNASettings[%Distance]/RNASettings[%Velocity]))*2
String UnfoldName=NameOfWave(ForceOrZSensorData)+"_U_"
String RefoldName=NameOfWave(ForceOrZSensorData)+"_R_"
Variable Counter=0
Variable NumRamps=Floor(RNASettings[%TotalTime]/(RNASettings[%Distance]/RNASettings[%Velocity]*2))
For(Counter=0;Counter<NumRamps;Counter+=1)
Variable StartUIndex=Counter*PointsPerRamp
Variable EndUindex=(Counter+0.5)*PointsPerRamp
Variable StartFIndex=EndUIndex+1
Variable EndFIndex=(Counter+1)*PointsPerRamp-1
String UnfoldWaveName=UnfoldName+num2str(Counter)
String RefoldWaveName=RefoldName+num2str(Counter)
Duplicate/O/R=[StartUIndex,EndUIndex] ForceOrZSensorData, $UnfoldWaveName
Duplicate/O/R=[StartFIndex,EndFIndex] ForceOrZSensorData, $RefoldWaveName
EndFor
End
Function GetRampSectionTime(RNAPullingSettings,Index,Section,[StartOrEnd])
Wave RNAPullingSettings
Variable Index
String Section,StartOrEnd
If(ParamIsDefault(StartOrEnd))
StartOrEnd="Start"
EndIf
Variable RetractRampTime=RNAPullingSettings[%Distance]/RNAPullingSettings[%RetractVelocity]
Variable ApproachRampTime=RNAPullingSettings[%Distance]/RNAPullingSettings[%ApproachVelocity]
Variable DwellTime=RNAPullingSettings[%DwellTime]
Variable StartTime=GetRampStartTime(RNAPullingSettings,Index)
Variable EndTime=GetRampStartTime(RNAPullingSettings,Index)+RetractRampTime
StrSwitch(Section)
case "Unfolding":
break
case "Refolding":
StartTime+=RetractRampTime
EndTime=(StartTime+ApproachRampTime)
break
case "Dwell":
StartTime+=(RetractRampTime+ApproachRampTime)
EndTime=(StartTime+ApproachRampTime+DwellTime)
break
case "RefoldingAndDwell":
StartTime+=(RetractRampTime)
EndTime=(StartTime+ApproachRampTime+DwellTime)
break
case "All":
EndTime=(StartTime+RetractRampTime+ApproachRampTime+DwellTime)
break
EndSwitch
Variable ReportTime=0
StrSwitch(StartOrEnd)
case "Start":
ReportTime=StartTime
break
case "End":
ReportTime= EndTime
break
EndSwitch
Return ReportTime
End
Function GetStepOrRampST(MasterIndex,RampOrStepIndex)
Variable MasterIndex,RampOrStepIndex
String SettingsWaveName="root:RNAPulling:SavedData:Settings"+num2str(MasterIndex)
String SettingsStrWaveName="root:RNAPulling:SavedData:SettingsStr"+num2str(MasterIndex)
If(WaveExists($SettingsWaveName))
Wave RNAPullingSettings=$SettingsWaveName
Wave/T RNAPullingSettingsStr=$SettingsStrWaveName
Return GetRNAStartTime(RNAPullingSettings,RNAPullingSettingsStr,RampOrStepIndex)
EndIf
End
Function GetRNAStartTime(RNAPullingSettings,RNAPullingSettingsStr,Index)
Wave RNAPullingSettings
Wave/T RNAPullingSettingsStr
Variable Index
StrSwitch(RNAPullingSettingsStr[%CurrentMode])
case "LocalRamp":
Return GetRampStartTime(RNAPullingSettings,Index)
break
case "Steps":
Return GetStepStartTime(RNAPullingSettings,Index)
break
Endswitch
End
Function GetRampStartTime(RNAPullingSettings,Index)
Wave RNAPullingSettings
Variable Index
Variable TimePerRamp=RNAPullingSettings[%Distance]/RNAPullingSettings[%ApproachVelocity]+RNAPullingSettings[%Distance]/RNAPullingSettings[%RetractVelocity]+RNAPullingSettings[%DwellTime]
// Setup parms for loop
Variable NumRamps=Floor(RNAPullingSettings[%TotalTime]/TimePerRamp)
If(Index>=0&&Index<NumRamps)
Variable StartTime=Index*TimePerRamp
Return StartTime
Else
Print "Invalid ramp index"
EndIF
End
Function GetStepStartTime(RNAPullingSettings,Index)
Wave RNAPullingSettings
Variable Index
Variable TimePerRamp=RNAPullingSettings[%Distance]/RNAPullingSettings[%ApproachVelocity]+RNAPullingSettings[%Distance]/RNAPullingSettings[%RetractVelocity]+RNAPullingSettings[%DwellTime]
// Setup parms for loop
Variable NumSteps=RNAPullingSettings[%NumSteps]
If(Index>=0&&Index<NumSteps)
Variable StartTime=Index*RNAPullingSettings[%TimePerStep]
Return StartTime
Else
Print "Invalid step index"
EndIF
End