From 1712c4280d922dc02c590ba590556353e394ab9c Mon Sep 17 00:00:00 2001 From: jacopoventurin Date: Tue, 19 Sep 2023 16:25:06 +0200 Subject: [PATCH 1/5] added sin and cos featurization --- proteka/metrics/featurizer.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/proteka/metrics/featurizer.py b/proteka/metrics/featurizer.py index 09171b9..7883206 100644 --- a/proteka/metrics/featurizer.py +++ b/proteka/metrics/featurizer.py @@ -427,6 +427,14 @@ def add_psi(self, ensemble: Ensemble): quantity = Quantity(psi, "radians", metadata={"feature": "psi"}) ensemble.set_quantity("psi", quantity) + def add_sin_cos(self, ensemble: Ensemble, feat_name:str, *args, **kwargs): + """Compute sin and cos of the feature corresponding to feat_name.""" + base_feat = self.get_feature(ensemble, feat_name, *args, **kwargs) + quantity = Quantity(np.sin(base_feat), "dimensionless", metadata={"feature": "sin_"+feat_name}) + ensemble.set_quantity("sin_"+feat_name, quantity) + quantity = Quantity(np.cos(base_feat), "dimensionless", metadata={"feature": "cos_"+feat_name}) + ensemble.set_quantity("cos_"+feat_name, quantity) + def add_rmsd( self, ensemble: Ensemble, From d81f87d27bd4c51444af122f95f4e5efd4581aff Mon Sep 17 00:00:00 2001 From: jacopoventurin Date: Tue, 19 Sep 2023 16:32:10 +0200 Subject: [PATCH 2/5] minor --- proteka/metrics/featurizer.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/proteka/metrics/featurizer.py b/proteka/metrics/featurizer.py index 7883206..6d6a231 100644 --- a/proteka/metrics/featurizer.py +++ b/proteka/metrics/featurizer.py @@ -427,12 +427,20 @@ def add_psi(self, ensemble: Ensemble): quantity = Quantity(psi, "radians", metadata={"feature": "psi"}) ensemble.set_quantity("psi", quantity) - def add_sin_cos(self, ensemble: Ensemble, feat_name:str, *args, **kwargs): + def add_sin_cos(self, ensemble: Ensemble, feat_name: str, *args, **kwargs): """Compute sin and cos of the feature corresponding to feat_name.""" base_feat = self.get_feature(ensemble, feat_name, *args, **kwargs) - quantity = Quantity(np.sin(base_feat), "dimensionless", metadata={"feature": "sin_"+feat_name}) + quantity = Quantity( + np.sin(base_feat), + "dimensionless", + metadata={"feature": "sin_"+feat_name}, + ) ensemble.set_quantity("sin_"+feat_name, quantity) - quantity = Quantity(np.cos(base_feat), "dimensionless", metadata={"feature": "cos_"+feat_name}) + quantity = Quantity( + np.cos(base_feat), + "dimensionless", + metadata={"feature": "cos_"+feat_name}, + ) ensemble.set_quantity("cos_"+feat_name, quantity) def add_rmsd( From bb2e604f10edcf9cac048a5d9f403ab92a29e1be Mon Sep 17 00:00:00 2001 From: jacopoventurin Date: Tue, 19 Sep 2023 16:35:34 +0200 Subject: [PATCH 3/5] minor --- proteka/metrics/featurizer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/proteka/metrics/featurizer.py b/proteka/metrics/featurizer.py index 6d6a231..f505786 100644 --- a/proteka/metrics/featurizer.py +++ b/proteka/metrics/featurizer.py @@ -433,15 +433,15 @@ def add_sin_cos(self, ensemble: Ensemble, feat_name: str, *args, **kwargs): quantity = Quantity( np.sin(base_feat), "dimensionless", - metadata={"feature": "sin_"+feat_name}, + metadata={"feature": "sin_" + feat_name}, ) - ensemble.set_quantity("sin_"+feat_name, quantity) + ensemble.set_quantity("sin_" + feat_name, quantity) quantity = Quantity( np.cos(base_feat), "dimensionless", - metadata={"feature": "cos_"+feat_name}, + metadata={"feature": "cos_" + feat_name}, ) - ensemble.set_quantity("cos_"+feat_name, quantity) + ensemble.set_quantity("cos_" + feat_name, quantity) def add_rmsd( self, From 88892988b33f591703fcc48a4eb9eee21502e70b Mon Sep 17 00:00:00 2001 From: jacopoventurin Date: Tue, 19 Sep 2023 16:54:58 +0200 Subject: [PATCH 4/5] minor --- proteka/metrics/featurizer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proteka/metrics/featurizer.py b/proteka/metrics/featurizer.py index f505786..bab6261 100644 --- a/proteka/metrics/featurizer.py +++ b/proteka/metrics/featurizer.py @@ -434,13 +434,13 @@ def add_sin_cos(self, ensemble: Ensemble, feat_name: str, *args, **kwargs): np.sin(base_feat), "dimensionless", metadata={"feature": "sin_" + feat_name}, - ) + ) ensemble.set_quantity("sin_" + feat_name, quantity) quantity = Quantity( - np.cos(base_feat), + np.cos(base_feat), "dimensionless", metadata={"feature": "cos_" + feat_name}, - ) + ) ensemble.set_quantity("cos_" + feat_name, quantity) def add_rmsd( From a4b828c458ed93ef30c82f56cd037016a67bbc77 Mon Sep 17 00:00:00 2001 From: jacopoventurin Date: Tue, 19 Sep 2023 16:57:34 +0200 Subject: [PATCH 5/5] minor --- proteka/metrics/featurizer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proteka/metrics/featurizer.py b/proteka/metrics/featurizer.py index bab6261..795a53c 100644 --- a/proteka/metrics/featurizer.py +++ b/proteka/metrics/featurizer.py @@ -431,14 +431,14 @@ def add_sin_cos(self, ensemble: Ensemble, feat_name: str, *args, **kwargs): """Compute sin and cos of the feature corresponding to feat_name.""" base_feat = self.get_feature(ensemble, feat_name, *args, **kwargs) quantity = Quantity( - np.sin(base_feat), - "dimensionless", + np.sin(base_feat), + "dimensionless", metadata={"feature": "sin_" + feat_name}, ) ensemble.set_quantity("sin_" + feat_name, quantity) quantity = Quantity( np.cos(base_feat), - "dimensionless", + "dimensionless", metadata={"feature": "cos_" + feat_name}, ) ensemble.set_quantity("cos_" + feat_name, quantity)