Spaces:
Sleeping
Sleeping
jannisborn
commited on
Commit
•
453d7ec
1
Parent(s):
5ba2dc5
update
Browse files
app.py
CHANGED
@@ -17,7 +17,7 @@ PH_FNS = ["charge", "charge_density", "isoelectric_point"]
|
|
17 |
|
18 |
|
19 |
def main(property: str, seq: str, seq_file: str, amide: bool, ph: float):
|
20 |
-
|
21 |
prop_name = property.lower()
|
22 |
algo, config = PROTEIN_PROPERTY_PREDICTOR_FACTORY[prop_name]
|
23 |
|
@@ -30,9 +30,9 @@ def main(property: str, seq: str, seq_file: str, amide: bool, ph: float):
|
|
30 |
model = algo(config(**kwargs))
|
31 |
|
32 |
# Read and parse data
|
33 |
-
if seq
|
34 |
raise ValueError("Pass either smiles or seq_file, not both.")
|
35 |
-
elif seq
|
36 |
seqs = [seq]
|
37 |
elif seq_file is not None:
|
38 |
seqs = pd.read_csv(seq_file.name, header=None, sep="\t")[0].tolist()
|
@@ -46,7 +46,6 @@ def main(property: str, seq: str, seq_file: str, amide: bool, ph: float):
|
|
46 |
|
47 |
|
48 |
if __name__ == "__main__":
|
49 |
-
|
50 |
# Preparation (retrieve all available algorithms)
|
51 |
properties = list(PROTEIN_PROPERTY_PREDICTOR_FACTORY.keys())[::-1]
|
52 |
properties = list(map(lambda x: x.capitalize(), properties))
|
@@ -55,7 +54,7 @@ if __name__ == "__main__":
|
|
55 |
metadata_root = pathlib.Path(__file__).parent.joinpath("model_cards")
|
56 |
|
57 |
examples = [
|
58 |
-
["Aliphaticity",
|
59 |
["Isoelectric_point", "KFLIYQMECSTMIFGL", None, False, 7],
|
60 |
["Charge", "KFLIYQMECSTMIFGL", None, True, 12],
|
61 |
]
|
|
|
17 |
|
18 |
|
19 |
def main(property: str, seq: str, seq_file: str, amide: bool, ph: float):
|
20 |
+
print("Property", property, "Seq", seq, "seq_file", seq_file)
|
21 |
prop_name = property.lower()
|
22 |
algo, config = PROTEIN_PROPERTY_PREDICTOR_FACTORY[prop_name]
|
23 |
|
|
|
30 |
model = algo(config(**kwargs))
|
31 |
|
32 |
# Read and parse data
|
33 |
+
if seq != "" and seq_file is not None:
|
34 |
raise ValueError("Pass either smiles or seq_file, not both.")
|
35 |
+
elif seq != "":
|
36 |
seqs = [seq]
|
37 |
elif seq_file is not None:
|
38 |
seqs = pd.read_csv(seq_file.name, header=None, sep="\t")[0].tolist()
|
|
|
46 |
|
47 |
|
48 |
if __name__ == "__main__":
|
|
|
49 |
# Preparation (retrieve all available algorithms)
|
50 |
properties = list(PROTEIN_PROPERTY_PREDICTOR_FACTORY.keys())[::-1]
|
51 |
properties = list(map(lambda x: x.capitalize(), properties))
|
|
|
54 |
metadata_root = pathlib.Path(__file__).parent.joinpath("model_cards")
|
55 |
|
56 |
examples = [
|
57 |
+
["Aliphaticity", "", metadata_root.joinpath("examples.smi"), False, 7],
|
58 |
["Isoelectric_point", "KFLIYQMECSTMIFGL", None, False, 7],
|
59 |
["Charge", "KFLIYQMECSTMIFGL", None, True, 12],
|
60 |
]
|
utils.py
CHANGED
@@ -10,7 +10,11 @@ logger.addHandler(logging.NullHandler())
|
|
10 |
|
11 |
|
12 |
def draw_grid_predict(
|
13 |
-
sequences: List[str],
|
|
|
|
|
|
|
|
|
14 |
) -> str:
|
15 |
"""
|
16 |
Uses mols2grid to draw a HTML grid for the prediction
|
@@ -46,8 +50,9 @@ def draw_grid_predict(
|
|
46 |
result["Seqs"] = sequences
|
47 |
for i, name in enumerate(property_names):
|
48 |
result[name] = properties[:, i]
|
49 |
-
n_cols
|
50 |
-
|
|
|
51 |
obj = mols2grid.display(
|
52 |
result,
|
53 |
tooltip=list(result.keys()),
|
|
|
10 |
|
11 |
|
12 |
def draw_grid_predict(
|
13 |
+
sequences: List[str],
|
14 |
+
properties: np.array,
|
15 |
+
property_names: List[str],
|
16 |
+
domain: str,
|
17 |
+
n_cols: int = -1,
|
18 |
) -> str:
|
19 |
"""
|
20 |
Uses mols2grid to draw a HTML grid for the prediction
|
|
|
50 |
result["Seqs"] = sequences
|
51 |
for i, name in enumerate(property_names):
|
52 |
result[name] = properties[:, i]
|
53 |
+
if n_cols == -1:
|
54 |
+
n_cols = min(3, len(result))
|
55 |
+
size = (250, 200) if len(result) > 3 else (600, 700)
|
56 |
obj = mols2grid.display(
|
57 |
result,
|
58 |
tooltip=list(result.keys()),
|