Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
progress
Browse files
tiger.py
CHANGED
|
@@ -99,17 +99,29 @@ def process_data(transcript_seq: str):
|
|
| 99 |
return target_seq, guide_seq, model_inputs
|
| 100 |
|
| 101 |
|
| 102 |
-
def prediction_transform(predictions: np.array,
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
|
| 115 |
def predict_on_target(transcript_seq: str, model: tf.keras.Model):
|
|
|
|
| 99 |
return target_seq, guide_seq, model_inputs
|
| 100 |
|
| 101 |
|
| 102 |
+
def prediction_transform(predictions: np.array, **params):
|
| 103 |
+
|
| 104 |
+
# regime indices
|
| 105 |
+
active_saturation = predictions < params['a']
|
| 106 |
+
linear_regime = (params['a'] <= predictions) & (predictions <= params['c'])
|
| 107 |
+
inactive_saturation = params['c'] < predictions
|
| 108 |
+
|
| 109 |
+
# linear regime
|
| 110 |
+
slope = (params['d'] - params['b']) / (params['c'] - params['a'])
|
| 111 |
+
intercept = -params['a'] * slope + params['b']
|
| 112 |
+
predictions[linear_regime] = slope * predictions[linear_regime] + intercept
|
| 113 |
+
|
| 114 |
+
# active saturation regime
|
| 115 |
+
alpha = slope / params['b']
|
| 116 |
+
beta = alpha * params['a'] - np.log(params['b'])
|
| 117 |
+
predictions[active_saturation] = np.exp(alpha * predictions[active_saturation] - beta)
|
| 118 |
+
|
| 119 |
+
# inactive saturation regime
|
| 120 |
+
alpha = slope / (1 - params['d'])
|
| 121 |
+
beta = -alpha * params['c'] - np.log(1 - params['d'])
|
| 122 |
+
predictions[inactive_saturation] = 1 - np.exp(-alpha * predictions[inactive_saturation] - beta)
|
| 123 |
+
|
| 124 |
+
return 1 - predictions
|
| 125 |
|
| 126 |
|
| 127 |
def predict_on_target(transcript_seq: str, model: tf.keras.Model):
|