Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -10,15 +10,21 @@ scaler = MinMaxScaler()
|
|
10 |
|
11 |
def extract_features(sequence):
|
12 |
"""Calculate AAC, Dipeptide Composition, and normalize features."""
|
13 |
-
# Calculate Amino Acid Composition (AAC)
|
14 |
-
aac = AAComposition.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
|
17 |
-
# Normalize with pre-trained scaler (avoid fitting new data)
|
18 |
-
normalized_features = scaler.fit_transform([aac])
|
19 |
-
|
20 |
return normalized_features
|
21 |
|
|
|
22 |
def predict(sequence):
|
23 |
"""Predict AMP vs Non-AMP"""
|
24 |
features = extract_features(sequence)
|
|
|
10 |
|
11 |
def extract_features(sequence):
|
12 |
"""Calculate AAC, Dipeptide Composition, and normalize features."""
|
13 |
+
# Calculate Amino Acid Composition (AAC) and convert to array
|
14 |
+
aac = np.array(list(propy.AAComposition.CalculateAAC(sequence).values()))
|
15 |
+
|
16 |
+
# Calculate Dipeptide Composition and convert to array
|
17 |
+
dipeptide_comp = np.array(list(propy.AAComposition.CalculateAADipeptideComposition(sequence).values()))
|
18 |
+
|
19 |
+
# Combine both features (AAC and Dipeptide Composition)
|
20 |
+
features = np.concatenate((aac, dipeptide_comp))
|
21 |
+
|
22 |
+
# Normalize using the pre-trained scaler (Ensure the scaler is loaded correctly)
|
23 |
+
normalized_features = scaler.transform([features]) # Don't use fit_transform(), only transform()
|
24 |
|
|
|
|
|
|
|
|
|
25 |
return normalized_features
|
26 |
|
27 |
+
|
28 |
def predict(sequence):
|
29 |
"""Predict AMP vs Non-AMP"""
|
30 |
features = extract_features(sequence)
|