pdbnucleicacids 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. pdbnucleicacids-0.1.0/AUTHORS.rst +13 -0
  2. pdbnucleicacids-0.1.0/CONTRIBUTING.rst +135 -0
  3. pdbnucleicacids-0.1.0/HISTORY.rst +8 -0
  4. pdbnucleicacids-0.1.0/LICENSE +22 -0
  5. pdbnucleicacids-0.1.0/MANIFEST.in +11 -0
  6. pdbnucleicacids-0.1.0/PDBNucleicAcids/BasePairRules.py +188 -0
  7. pdbnucleicacids-0.1.0/PDBNucleicAcids/Geometry.py +176 -0
  8. pdbnucleicacids-0.1.0/PDBNucleicAcids/MMCIF2DataFrame.py +159 -0
  9. pdbnucleicacids-0.1.0/PDBNucleicAcids/Pairing.py +109 -0
  10. pdbnucleicacids-0.1.0/PDBNucleicAcids/Structure2DataFrame.py +6 -0
  11. pdbnucleicacids-0.1.0/PDBNucleicAcids/__init__.py +5 -0
  12. pdbnucleicacids-0.1.0/PDBNucleicAcids/_basepair_dataframe.py +98 -0
  13. pdbnucleicacids-0.1.0/PDBNucleicAcids/_polymer_dataframe.py +66 -0
  14. pdbnucleicacids-0.1.0/PDBNucleicAcids/utils.py +84 -0
  15. pdbnucleicacids-0.1.0/PKG-INFO +82 -0
  16. pdbnucleicacids-0.1.0/README.rst +58 -0
  17. pdbnucleicacids-0.1.0/docs/Makefile +20 -0
  18. pdbnucleicacids-0.1.0/docs/authors.rst +1 -0
  19. pdbnucleicacids-0.1.0/docs/conf.py +168 -0
  20. pdbnucleicacids-0.1.0/docs/contributing.rst +1 -0
  21. pdbnucleicacids-0.1.0/docs/history.rst +1 -0
  22. pdbnucleicacids-0.1.0/docs/index.rst +20 -0
  23. pdbnucleicacids-0.1.0/docs/installation.rst +51 -0
  24. pdbnucleicacids-0.1.0/docs/make.bat +36 -0
  25. pdbnucleicacids-0.1.0/docs/readme.rst +1 -0
  26. pdbnucleicacids-0.1.0/docs/usage.rst +7 -0
  27. pdbnucleicacids-0.1.0/pdbnucleicacids.egg-info/PKG-INFO +82 -0
  28. pdbnucleicacids-0.1.0/pdbnucleicacids.egg-info/SOURCES.txt +38 -0
  29. pdbnucleicacids-0.1.0/pdbnucleicacids.egg-info/dependency_links.txt +1 -0
  30. pdbnucleicacids-0.1.0/pdbnucleicacids.egg-info/requires.txt +9 -0
  31. pdbnucleicacids-0.1.0/pdbnucleicacids.egg-info/top_level.txt +1 -0
  32. pdbnucleicacids-0.1.0/pyproject.toml +180 -0
  33. pdbnucleicacids-0.1.0/setup.cfg +4 -0
  34. pdbnucleicacids-0.1.0/tests/__init__.py +1 -0
  35. pdbnucleicacids-0.1.0/tests/data/gattaca.cif +547 -0
  36. pdbnucleicacids-0.1.0/tests/test_BasePairRules.py +198 -0
  37. pdbnucleicacids-0.1.0/tests/test_Geometry.py +79 -0
  38. pdbnucleicacids-0.1.0/tests/test_Pairing.py +90 -0
  39. pdbnucleicacids-0.1.0/tests/test_Structure2DataFrame.py +25 -0
  40. pdbnucleicacids-0.1.0/tests/test_pdbnucleic.py +19 -0
@@ -0,0 +1,13 @@
1
+ =======
2
+ Credits
3
+ =======
4
+
5
+ Development Lead
6
+ ----------------
7
+
8
+ * Alessandro Pandolfi <alessandro.pandolfi@protonmail.com>
9
+
10
+ Contributors
11
+ ------------
12
+
13
+ None yet. Why not be the first?
@@ -0,0 +1,135 @@
1
+ .. highlight:: shell
2
+
3
+ ============
4
+ Contributing
5
+ ============
6
+
7
+ Contributions are welcome, and they are greatly appreciated! Every little bit
8
+ helps, and credit will always be given.
9
+
10
+ You can contribute in many ways:
11
+
12
+ Types of Contributions
13
+ ----------------------
14
+
15
+ Report Bugs
16
+ ~~~~~~~~~~~
17
+
18
+ Report bugs at https://gitlab.com/MorfeoRenai/pdbnucleicacids/-/issues
19
+
20
+ If you are reporting a bug, please include:
21
+
22
+ * Your operating system name and version.
23
+ * Any details about your local setup that might be helpful in troubleshooting.
24
+ * Detailed steps to reproduce the bug.
25
+
26
+ Fix Bugs
27
+ ~~~~~~~~
28
+
29
+ Look through the GitHub issues for bugs. Anything tagged with "bug" and "help
30
+ wanted" is open to whoever wants to implement it.
31
+
32
+ Implement Features
33
+ ~~~~~~~~~~~~~~~~~~
34
+
35
+ Look through the GitHub issues for features. Anything tagged with "enhancement"
36
+ and "help wanted" is open to whoever wants to implement it.
37
+
38
+ Write Documentation
39
+ ~~~~~~~~~~~~~~~~~~~
40
+
41
+ PDBNucleicAcids could always use more documentation, whether as part of the
42
+ official PDBNucleicAcids docs, in docstrings, or even on the web in blog posts,
43
+ articles, and such.
44
+
45
+ Submit Feedback
46
+ ~~~~~~~~~~~~~~~
47
+
48
+ The best way to send feedback is to file an issue at https://gitlab.com/MorfeoRenai/pdbnucleicacids/-/issues
49
+
50
+ If you are proposing a feature:
51
+
52
+ * Explain in detail how it would work.
53
+ * Keep the scope as narrow as possible, to make it easier to implement.
54
+ * Remember that this is a volunteer-driven project, and that contributions
55
+ are welcome :)
56
+
57
+ Get Started!
58
+ ------------
59
+
60
+ Ready to contribute? Here's how to set up `pdbnucleicacids` for local development.
61
+
62
+ 1. Fork the `pdbnucleicacids` repo on GitHub.
63
+ 2. Clone your fork locally::
64
+
65
+ $ git clone git@gitlab.com:your_name_here/pdbnucleicacids.git
66
+
67
+ 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
68
+
69
+ $ mkvirtualenv pdbnucleicacids
70
+ $ cd pdbnucleicacids/
71
+ $ pip install -r requirements-dev.txt
72
+
73
+ 4. Create a branch for local development::
74
+
75
+ $ git checkout -b name-of-your-bugfix-or-feature
76
+
77
+ Now you can make your changes locally.
78
+
79
+ 5. When you're done making changes, check that your changes pass flake8 and the
80
+ tests, including testing other Python versions with tox::
81
+
82
+ $ make lint
83
+ $ make test
84
+ Or
85
+ $ make test-all
86
+
87
+ To get flake8 and tox, just pip install them into your virtualenv.
88
+
89
+ 6. Commit your changes and push your branch to GitHub::
90
+
91
+ $ git add .
92
+ $ git commit -m "Your detailed description of your changes."
93
+ $ git push origin name-of-your-bugfix-or-feature
94
+
95
+ 7. Submit a pull request through the GitHub website.
96
+
97
+ Pull Request Guidelines
98
+ -----------------------
99
+
100
+ Before you submit a pull request, check that it meets these guidelines:
101
+
102
+ 1. The pull request should include tests.
103
+ 2. If the pull request adds functionality, the docs should be updated. Put
104
+ your new functionality into a function with a docstring, and add the
105
+ feature to the list in README.rst.
106
+ 3. The pull request should work for Python 3.5, 3.6, 3.7 and 3.8, and for PyPy.
107
+ Make sure that the tests pass for all supported Python versions.
108
+
109
+ Tips
110
+ ----
111
+
112
+ To run a subset of tests::
113
+
114
+
115
+ $ make test
116
+
117
+ Deploying
118
+ ---------
119
+
120
+ A reminder for the maintainers on how to deploy.
121
+ Make sure all your changes are committed (including an entry in HISTORY.rst).
122
+ Then run::
123
+
124
+ $ bump-my-version patch # possible: major / minor / patch
125
+ $ git push
126
+ $ git push --tags
127
+
128
+
129
+ Code of Conduct
130
+ ---------------
131
+
132
+ Please note that this project is released with a `Contributor Code of Conduct`_.
133
+ By participating in this project you agree to abide by its terms.
134
+
135
+ .. _`Contributor Code of Conduct`: CODE_OF_CONDUCT.rst
@@ -0,0 +1,8 @@
1
+ =======
2
+ History
3
+ =======
4
+
5
+ 0.1.0 (2024-09-18)
6
+ ------------------
7
+
8
+ * First release on PyPI.
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024, Alessandro Pandolfi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,11 @@
1
+ include AUTHORS.rst
2
+ include CONTRIBUTING.rst
3
+ include HISTORY.rst
4
+ include LICENSE
5
+ include README.rst
6
+
7
+ recursive-include tests *
8
+ recursive-exclude * __pycache__
9
+ recursive-exclude * *.py[co]
10
+
11
+ recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif
@@ -0,0 +1,188 @@
1
+ """Classes with rules for proper base pairing."""
2
+
3
+ import warnings
4
+
5
+ # from Bio.PDB.vectors import calc_dihedral
6
+ from Bio.PDB.Residue import Residue
7
+ from Bio.PDB.Atom import Atom
8
+ from Bio.PDB.Polypeptide import is_nucleic
9
+
10
+ # absolute imports
11
+ from PDBNucleicAcids.Geometry import angle_between_planes, plane_separation
12
+
13
+
14
+ class dsDNAWatsonCrickBasePairRules:
15
+ """
16
+ Rules for Watson-Crick base pairs in double-strand DNA.
17
+
18
+ Parameters
19
+ ----------
20
+ max_distance : float | int, optional
21
+ Maximum distance between nucleotide bases, in Armstrong.
22
+ The default is 3.5.
23
+ max_angle : float | int, optional
24
+ Maximum angle between the planes of the bases, in degrees.
25
+ The default is 65.
26
+ max_stagger : float | int, optional
27
+ Maximum vertical distance between the planes of the bases, in degrees.
28
+ The default is 65.
29
+
30
+ """
31
+
32
+ def __init__(
33
+ self,
34
+ max_distance: float | int = 4,
35
+ max_angle: float | int = 65,
36
+ max_stagger: float | int = 2.5,
37
+ # dihedral_range: tuple[int, float] = (90, 150),
38
+ ):
39
+ self.complementary_pairs: set[tuple[str]] = {
40
+ ("DA", "DT"),
41
+ ("DT", "DA"),
42
+ ("DG", "DC"),
43
+ ("DC", "DG"),
44
+ }
45
+
46
+ # parameters taken from
47
+ # http://forum.x3dna.org/faqs/
48
+ # how-to-fix-missing-(superfluous)-base-pairs-identified-by-find_pair/
49
+ self.max_distance = max_distance
50
+ self.max_angle = max_angle
51
+ self.max_stagger = max_stagger
52
+ # self.dihedral_angle_range = dihedral_range
53
+
54
+ def atoms_from_base_ring(self, base: Residue) -> tuple[Atom] | None:
55
+ """Get atoms from the ring of a base."""
56
+ if base.get_resname() in ["DA", "DG"]: # Purine
57
+ atoms: tuple[Atom] = (base["N1"], base["C2"], base["C6"])
58
+ elif base.get_resname() in ["DT", "DC"]: # Pirimidine
59
+ atoms: tuple[Atom] = (base["N3"], base["C2"], base["C4"])
60
+ elif base.get_resname() == "HOH": # Water
61
+ atoms = None
62
+ else: # Hetero-residue?
63
+ warnings.warn(
64
+ f"{base.full_id} has no atoms from base ring. Might \
65
+ be hetero-residue non-standard-base."
66
+ )
67
+ atoms = None
68
+ return atoms
69
+
70
+ def atom_from_central_hbond(self, base) -> Atom | None:
71
+ """Get central H-bond atom of a base."""
72
+ atoms = self.atoms_from_base_ring(base)
73
+ if atoms:
74
+ return atoms[0]
75
+ else:
76
+ return None
77
+
78
+ def distance(self, base1, base2) -> float | None:
79
+ """Compute distance between central H-bond atoms of two bases."""
80
+ atom1 = self.atom_from_central_hbond(base1)
81
+ atom2 = self.atom_from_central_hbond(base2)
82
+ if atom1 is not None and atom2 is not None:
83
+ return atom1 - atom2
84
+ else:
85
+ return None
86
+
87
+ def angle_between_bases(
88
+ self, base1: Residue, base2: Residue
89
+ ) -> float | None:
90
+ """Compute angle between between planes of two bases."""
91
+ atom_list1 = self.atoms_from_base_ring(base1)
92
+ atom_list2 = self.atoms_from_base_ring(base2)
93
+ if atom_list1 is None or atom_list2 is None:
94
+ return None
95
+ plane1 = (atom.coord for atom in atom_list1)
96
+ plane2 = (atom.coord for atom in atom_list2)
97
+ return angle_between_planes(plane1, plane2)
98
+
99
+ def stagger(self, base1: Residue, base2: Residue) -> float | None:
100
+ """Compute vertical stagger between between planes of two bases."""
101
+ atom_list1 = self.atoms_from_base_ring(base1)
102
+ atom_list2 = self.atoms_from_base_ring(base2)
103
+ if atom_list1 is None or atom_list2 is None:
104
+ return None
105
+ plane1 = (atom.coord for atom in atom_list1)
106
+ plane2 = (atom.coord for atom in atom_list2)
107
+ return plane_separation(plane1, plane2)
108
+
109
+ # def dihedrals(self, base1, base2) -> float:
110
+ # atom1, atom2, atom3 = self.atoms_from_base_ring(base1)
111
+ # atom4, atom5, atom6 = self.atoms_from_base_ring(base2)
112
+
113
+ # v1, v2, v3, v4, v5, v6 = (
114
+ # atom1.get_vector(),
115
+ # atom2.get_vector(),
116
+ # atom3.get_vector(),
117
+ # atom4.get_vector(),
118
+ # atom5.get_vector(),
119
+ # atom6.get_vector(),
120
+ # )
121
+ # dihedral1 = calc_dihedral(v1, v2, v3, v4)
122
+ # dihedral2 = calc_dihedral(v1, v5, v6, v4)
123
+
124
+ # return (dihedral1, dihedral2)
125
+
126
+ def is_different_residue(self, base1: Residue, base2: Residue) -> bool:
127
+ """Check if two bases are distinct bases."""
128
+ return base1 != base2
129
+
130
+ def is_complementary(self, base1: Residue, base2: Residue) -> bool:
131
+ """Check if two bases are complementary."""
132
+ pair: tuple[str] = (base1.get_resname(), base2.get_resname())
133
+ return pair in self.complementary_pairs
134
+
135
+ def is_from_different_chain(self, base1: Residue, base2: Residue) -> bool:
136
+ """Check if two bases are from distinct chains."""
137
+ return base1.parent != base2.parent
138
+
139
+ def is_valid_distance(self, base1: Residue, base2: Residue) -> bool:
140
+ """Check validity of distance between central two bases."""
141
+ dist = self.distance(base1, base2)
142
+ if dist is not None:
143
+ return dist <= self.max_distance
144
+ else:
145
+ return False
146
+
147
+ def is_valid_angle(self, base1: Residue, base2: Residue) -> bool:
148
+ """Check validity of angle between between planes of the bases."""
149
+ angle = self.angle_between_bases(base1, base2)
150
+ if angle is not None:
151
+ return angle <= self.max_angle or angle >= 180 - self.max_angle
152
+ else:
153
+ False
154
+
155
+ def is_valid_stagger(self, base1: Residue, base2: Residue) -> bool:
156
+ """Check validity of stagger between between planes of the bases."""
157
+ # TODO to be used
158
+ return self.stagger(base1, base2) <= self.max_stagger
159
+
160
+ def is_candidate(self, base1: Residue, base2: Residue) -> bool:
161
+ """
162
+ Check if (base1, base2) is a likely base pair.
163
+
164
+ Use all the constraint methods to infer if base2 is likely to be
165
+ paired with base1.
166
+ """
167
+ if not is_nucleic(base1, standard=False):
168
+ # TODO add warning
169
+ return False
170
+ elif not is_nucleic(base2, standard=False):
171
+ return False
172
+ elif not is_nucleic(base1, standard=True):
173
+ # TODO add warning
174
+ return False
175
+ elif not is_nucleic(base2, standard=True):
176
+ return False
177
+ elif not self.is_different_residue(base1, base2):
178
+ return False
179
+ elif not self.is_complementary(base1, base2):
180
+ return False
181
+ elif not self.is_from_different_chain(base1, base2):
182
+ return False
183
+ elif not self.is_valid_distance(base1, base2):
184
+ return False
185
+ elif not self.is_valid_angle(base1, base2):
186
+ return False
187
+ else:
188
+ return True
@@ -0,0 +1,176 @@
1
+ """Functions that address atom geometry."""
2
+
3
+ import numpy as np
4
+
5
+ # from Bio.PDB.Atom import Atom
6
+
7
+
8
+ def calculate_normal_vector(v1, v2, v3) -> np.float64:
9
+ """Compute normal vector from three 3D points."""
10
+ u1 = v2 - v1
11
+ u2 = v3 - v1
12
+
13
+ # Calcolo del vettore normale
14
+ normal = np.cross(u1, u2)
15
+
16
+ # Normalizzazione manuale del vettore normale
17
+ norm = np.linalg.norm(normal)
18
+ if norm == 0:
19
+ raise ValueError("Vettore normale nullo")
20
+ normal_normalized = normal / norm
21
+
22
+ return normal_normalized
23
+
24
+
25
+ def angle_between_vectors(v1, v2) -> np.float64:
26
+ """Compute angle between two vectors."""
27
+ cos_theta = np.dot(v1, v2) / (np.linalg.norm(v1) * np.linalg.norm(v2))
28
+
29
+ return np.degrees(np.arccos(np.clip(cos_theta, -1.0, 1.0)))
30
+
31
+
32
+ def angle_between_planes(plane1, plane2) -> np.float64:
33
+ """Compute angle between two planes, composed of three 3D points each."""
34
+ v1, v2, v3 = plane1
35
+ v4, v5, v6 = plane2
36
+
37
+ normal1 = calculate_normal_vector(v1, v2, v3)
38
+ normal2 = calculate_normal_vector(v4, v5, v6)
39
+
40
+ angle = angle_between_vectors(normal1, normal2)
41
+
42
+ return angle
43
+
44
+
45
+ def plane_separation(plane1, plane2) -> np.float64:
46
+ """Calcola la distanza verticale tra due piani."""
47
+ v1, v2, v3 = plane1
48
+ v4, v5, v6 = plane2
49
+
50
+ # Ottieni i vettori normali
51
+ normal1 = calculate_normal_vector(v1, v2, v3)
52
+ # normal2 = calculate_normal_vector(v4, v5, v6)
53
+
54
+ # Ottieni i centri dei piani
55
+ center1 = np.mean(plane1, axis=0)
56
+ center2 = np.mean(plane2, axis=0)
57
+
58
+ # Calcola il vettore tra i centri dei due piani
59
+ center_vector = center2 - center1
60
+
61
+ # Proietta il vettore tra i centri lungo la direzione del normale del
62
+ # primo piano
63
+ separation: np.float64 = abs(np.dot(center_vector, normal1))
64
+
65
+ return separation
66
+
67
+
68
+ # def angle_between_3_atoms(atom1: Atom, atom2: Atom, atom3: Atom) -> float:
69
+ # """
70
+ # Get angle in degrees between three atoms. OBSOLETE.
71
+
72
+ # Atom 1 has the angle that is returned
73
+
74
+ # Parameters
75
+ # ----------
76
+ # atom1 : Bio.PDB.Atom.Atom
77
+ # First atom, on which the returned angle rests.
78
+ # atom2 : Bio.PDB.Atom.Atom
79
+ # Second atom.
80
+ # atom3 : Bio.PDB.Atom.Atom
81
+ # Third atom.
82
+
83
+ # Returns
84
+ # -------
85
+ # float
86
+ # Angle between the three atoms, measured in degrees.
87
+
88
+ # """
89
+ # # get coordinate vectors
90
+ # p1: np.array = atom1.coord
91
+ # p2: np.array = atom2.coord
92
+ # p3: np.array = atom3.coord
93
+
94
+ # # Calculate the vectors
95
+ # v1 = p2 - p1 # from p1 to p2
96
+ # v2 = p3 - p1 # from p1 to p3
97
+
98
+ # # Calculate the angle in radians
99
+ # # rule of the cosine
100
+ # angle_radians = np.arccos(
101
+ # np.clip(
102
+ # np.dot(v1, v2) / (np.linalg.norm(v1) * np.linalg.norm(v2)),
103
+ # -1.0,
104
+ # 1.0,
105
+ # )
106
+ # )
107
+
108
+ # # Convert to degrees, cast into float
109
+ # angle_degrees = np.degrees(angle_radians)
110
+ # angle_degrees = float(angle_degrees)
111
+
112
+ # return angle_degrees
113
+
114
+
115
+ # def dihedral_angle_between_4_atoms(
116
+ # atom1: Atom, atom2: Atom, atom3: Atom, atom4: Atom
117
+ # ) -> float:
118
+ # """
119
+ # Get dihedral angle in degrees between four atoms. OBSOLETE.
120
+
121
+ # The first plane rests of the dihedral angle rests on the first three
122
+ # atoms while the second rests on the last three. `atom1` and `atom2`
123
+ # are in common between the two planes.
124
+
125
+ # Parameters
126
+ # ----------
127
+ # atom1 : Bio.PDB.Atom.Atom
128
+ # First atom.
129
+ # atom2 : Bio.PDB.Atom.Atom
130
+ # Second atom.
131
+ # atom3 : Bio.PDB.Atom.Atom
132
+ # Third atom.
133
+ # atom4 : Bio.PDB.Atom.Atom
134
+ # Forth atom.
135
+
136
+ # Returns
137
+ # -------
138
+ # float
139
+ # Dihedral angle between the four atoms, measured in degrees.
140
+
141
+ # """
142
+ # # Punti tridimensionali, 4 atomi
143
+ # p1 = atom1.coord
144
+ # p2 = atom2.coord
145
+ # p3 = atom3.coord
146
+ # p4 = atom4.coord
147
+
148
+ # # Vettori tra i punti
149
+ # v1 = p2 - p1
150
+ # v2 = p3 - p2
151
+ # v3 = p4 - p3
152
+
153
+ # # Vettori normali ai piani
154
+ # n1 = np.cross(v1, v2)
155
+ # n2 = np.cross(v2, v3)
156
+
157
+ # # Vettore di riferimento per la direzione
158
+ # m = np.cross(n1, v2)
159
+
160
+ # # Normalizzazione dei vettori
161
+ # n1 /= np.linalg.norm(n1)
162
+ # n2 /= np.linalg.norm(n2)
163
+ # m /= np.linalg.norm(m)
164
+
165
+ # # Calcola coseno e seno dell'angolo
166
+ # cos_theta = np.dot(n1, n2)
167
+ # sin_theta = np.dot(m, n2)
168
+
169
+ # # Calcola l'angolo diedro
170
+ # theta = np.arctan2(sin_theta, cos_theta)
171
+
172
+ # # Converti l'angolo da radianti a gradi e castalo in float
173
+ # theta_deg = np.degrees(theta)
174
+ # theta_deg = float(theta_deg)
175
+
176
+ # return theta_deg