biointerface 0.1.0__py3-none-any.whl
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.
- biointerface/__init__.py +5 -0
- biointerface/biointerface.py +138 -0
- biointerface-0.1.0.dist-info/AUTHORS.rst +13 -0
- biointerface-0.1.0.dist-info/LICENSE +22 -0
- biointerface-0.1.0.dist-info/METADATA +64 -0
- biointerface-0.1.0.dist-info/RECORD +8 -0
- biointerface-0.1.0.dist-info/WHEEL +5 -0
- biointerface-0.1.0.dist-info/top_level.txt +1 -0
biointerface/__init__.py
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"""Extract interface."""
|
|
2
|
+
|
|
3
|
+
from Bio.PDB.Polypeptide import PPBuilder
|
|
4
|
+
from Bio.PDB.NeighborSearch import NeighborSearch
|
|
5
|
+
from Bio.PDB import Structure, Model, Chain, Residue
|
|
6
|
+
from Bio.PDB import MMCIFIO
|
|
7
|
+
|
|
8
|
+
import pandas as pd
|
|
9
|
+
|
|
10
|
+
from PDBNucleicAcids.NucleicAcid import NABuilder
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def get_interface(structure, protein_chain_id, search_radius, n_atoms):
|
|
14
|
+
"""Extract interface."""
|
|
15
|
+
# get all the atoms from the nucleic acids, in most cases DNA
|
|
16
|
+
na_builder = NABuilder()
|
|
17
|
+
na_list = na_builder.build_nucleic_acids(structure)
|
|
18
|
+
na_atoms = []
|
|
19
|
+
for na in na_list:
|
|
20
|
+
na_atoms.extend(na.get_atoms())
|
|
21
|
+
na_atoms = list(set(na_atoms))
|
|
22
|
+
|
|
23
|
+
# get all the atoms from the protein chain
|
|
24
|
+
protein_chain = structure[0][protein_chain_id]
|
|
25
|
+
pp_builder = PPBuilder()
|
|
26
|
+
pp = pp_builder.build_peptides(protein_chain)[0]
|
|
27
|
+
pp_atoms = []
|
|
28
|
+
for pp in pp_builder.build_peptides(protein_chain):
|
|
29
|
+
for res in pp:
|
|
30
|
+
pp_atoms.extend(res.get_atoms())
|
|
31
|
+
pp_atoms = list(set(pp_atoms))
|
|
32
|
+
|
|
33
|
+
# Crea una lista con tutti gli atomi di DNA e proteina
|
|
34
|
+
all_atoms = na_atoms + pp_atoms
|
|
35
|
+
|
|
36
|
+
# Usa NeighborSearch per trovare gli atomi vicini entro una certa
|
|
37
|
+
# distanza
|
|
38
|
+
ns = NeighborSearch(all_atoms)
|
|
39
|
+
|
|
40
|
+
# Cerca gli atomi vicini entro un raggio di 4 Å tra DNA e proteina
|
|
41
|
+
all_contacts = ns.search_all(search_radius)
|
|
42
|
+
|
|
43
|
+
# Filtra solo i contatti, ovvero le coppied di atomi,
|
|
44
|
+
# che hanno un atomo di DNA
|
|
45
|
+
temp = [
|
|
46
|
+
(atom1, atom2)
|
|
47
|
+
for atom1, atom2 in all_contacts
|
|
48
|
+
if (atom1 in na_atoms or atom2 in na_atoms)
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
# Filtra solo i contatti tra DNA e proteina
|
|
52
|
+
contacts = [
|
|
53
|
+
(atom1, atom2)
|
|
54
|
+
for atom1, atom2 in temp
|
|
55
|
+
if (atom1 in na_atoms and atom2 in pp_atoms)
|
|
56
|
+
] + [
|
|
57
|
+
(atom2, atom1)
|
|
58
|
+
for atom1, atom2 in temp
|
|
59
|
+
if (atom1 in pp_atoms and atom2 in na_atoms)
|
|
60
|
+
]
|
|
61
|
+
# temp è utile per greedyness, prima prendi il DNA, che ha meno
|
|
62
|
+
# atomi, escludendo quelli intra-proteina
|
|
63
|
+
# poi escludi anche quelli intra-DNA
|
|
64
|
+
# inoltre ci assicuriamo che la col 0 contenga gli atomi di DNA e
|
|
65
|
+
# che col 1 contenga gli atomi di proteine
|
|
66
|
+
# Ce ne assicuriamo invertendo atom1 e atom2 nella seconda lista
|
|
67
|
+
|
|
68
|
+
# dataframe
|
|
69
|
+
contacts_df = pd.DataFrame(contacts, columns=["na_atoms", "pp_atoms"])
|
|
70
|
+
|
|
71
|
+
# distance column
|
|
72
|
+
# Atom - Atom = distance in armstrong
|
|
73
|
+
contacts_df["dist"] = contacts_df.apply(
|
|
74
|
+
lambda row: row["na_atoms"] - row["pp_atoms"], axis=1
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
# grouping: minimum distance for every protein atom, then sorted
|
|
78
|
+
dist = contacts_df.groupby(by="pp_atoms")["dist"].min().sort_values()
|
|
79
|
+
|
|
80
|
+
# take the n top smallest distances
|
|
81
|
+
# atoms as indexes
|
|
82
|
+
dist = dist.head(n_atoms) # Series of floats
|
|
83
|
+
interface_atoms = dist.index.tolist() # index of Atom objects, to list
|
|
84
|
+
|
|
85
|
+
return interface_atoms
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def export_atom_list(structure_id, atom_list, out_filepath):
|
|
89
|
+
# not in Path but in string
|
|
90
|
+
out_filepath = str(out_filepath)
|
|
91
|
+
|
|
92
|
+
new_structure = Structure.Structure(structure_id)
|
|
93
|
+
for atom in atom_list:
|
|
94
|
+
_add_atom_to_new_structure(atom, new_structure)
|
|
95
|
+
|
|
96
|
+
# Prepare IO object
|
|
97
|
+
io = MMCIFIO()
|
|
98
|
+
io.set_structure(new_structure)
|
|
99
|
+
|
|
100
|
+
# Esporta la nuova struttura in un file PDB
|
|
101
|
+
# necessita di string type filepath
|
|
102
|
+
io.save(out_filepath)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _add_atom_to_new_structure(atom, new_structure):
|
|
106
|
+
model_id = (
|
|
107
|
+
atom.get_parent().get_parent().get_parent().id
|
|
108
|
+
) # Ottieni l'ID del modello
|
|
109
|
+
chain_id = atom.get_parent().get_parent().id # Ottieni l'ID della catena
|
|
110
|
+
residue_id = atom.get_parent().id # Ottieni l'ID del residuo
|
|
111
|
+
resname = atom.get_parent().resname # Nome del residuo
|
|
112
|
+
|
|
113
|
+
# Controlla se il modello esiste già nel nuovo modello
|
|
114
|
+
if model_id in [model.id for model in new_structure]:
|
|
115
|
+
new_model = new_structure[model_id]
|
|
116
|
+
else:
|
|
117
|
+
new_model = Model.Model(model_id)
|
|
118
|
+
new_structure.add(new_model)
|
|
119
|
+
|
|
120
|
+
# Controlla se la catena esiste già nel nuovo modello
|
|
121
|
+
if chain_id in [chain.id for chain in new_model]:
|
|
122
|
+
new_chain = new_model[chain_id]
|
|
123
|
+
else:
|
|
124
|
+
new_chain = Chain.Chain(chain_id)
|
|
125
|
+
new_model.add(new_chain)
|
|
126
|
+
|
|
127
|
+
# Controlla se il residuo esiste già nella nuova catena
|
|
128
|
+
if residue_id in [res.id for res in new_chain]:
|
|
129
|
+
new_residue = new_chain[residue_id]
|
|
130
|
+
else:
|
|
131
|
+
new_residue = Residue.Residue(
|
|
132
|
+
residue_id, resname, atom.get_parent().segid
|
|
133
|
+
)
|
|
134
|
+
new_chain.add(new_residue)
|
|
135
|
+
|
|
136
|
+
# Copia l'atomo e aggiungilo al residuo
|
|
137
|
+
new_atom = atom.copy()
|
|
138
|
+
new_residue.add(new_atom)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, 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,64 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: biointerface
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: BioInterface is a python package capable of extracting Protein-DNA interfaces from PDB/mmCif structures.
|
|
5
|
+
Author-email: Alessandro Pandolfi <alessandro.pandolfi@protonmail.com>
|
|
6
|
+
Maintainer-email: Alessandro Pandolfi <alessandro.pandolfi@protonmail.com>
|
|
7
|
+
License: MIT license
|
|
8
|
+
Project-URL: bugs, https://gitlab.com/MorfeoRenai/biointerface/-/issues
|
|
9
|
+
Project-URL: changelog, https://gitlab.com/MorfeoRenai/biointerface/-/blob/main/HISTORY.rst
|
|
10
|
+
Project-URL: homepage, https://gitlab.com/MorfeoRenai/biointerface
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Description-Content-Type: text/x-rst
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
License-File: AUTHORS.rst
|
|
15
|
+
Requires-Dist: pandas
|
|
16
|
+
Requires-Dist: biopython
|
|
17
|
+
Requires-Dist: pdbnucleicacids>=0.2.0
|
|
18
|
+
Provides-Extra: dev
|
|
19
|
+
Requires-Dist: coverage; extra == "dev"
|
|
20
|
+
Requires-Dist: mypy; extra == "dev"
|
|
21
|
+
Requires-Dist: pytest; extra == "dev"
|
|
22
|
+
Requires-Dist: ruff; extra == "dev"
|
|
23
|
+
|
|
24
|
+
============
|
|
25
|
+
BioInterface
|
|
26
|
+
============
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
.. image:: https://img.shields.io/pypi/v/biointerface.svg
|
|
30
|
+
:target: https://pypi.python.org/pypi/biointerface
|
|
31
|
+
|
|
32
|
+
.. image:: https://img.shields.io/travis/MorfeoRenai/biointerface.svg
|
|
33
|
+
:target: https://travis-ci.com/MorfeoRenai/biointerface
|
|
34
|
+
|
|
35
|
+
.. image:: https://readthedocs.org/projects/biointerface/badge/?version=latest
|
|
36
|
+
:target: https://biointerface.readthedocs.io/en/latest/?version=latest
|
|
37
|
+
:alt: Documentation Status
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
.. image:: https://pyup.io/repos/github/MorfeoRenai/biointerface/shield.svg
|
|
41
|
+
:target: https://pyup.io/repos/github/MorfeoRenai/biointerface/
|
|
42
|
+
:alt: Updates
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
BioInterface is a python package capable of extracting Protein-DNA interfaces from PDB/mmCif structures.
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
* Free software: MIT license
|
|
50
|
+
* Documentation: https://biointerface.readthedocs.io.
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
Features
|
|
54
|
+
--------
|
|
55
|
+
|
|
56
|
+
* TODO
|
|
57
|
+
|
|
58
|
+
Credits
|
|
59
|
+
-------
|
|
60
|
+
|
|
61
|
+
This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
|
|
62
|
+
|
|
63
|
+
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
|
|
64
|
+
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
biointerface/__init__.py,sha256=jFvgoMrByp0YlveTOAzv2gyphtN70LdEyTodTKn0y3I,153
|
|
2
|
+
biointerface/biointerface.py,sha256=IXkJv0P5pwKXSSCI_sug6dUi2ToHZDB5RVbf2ZRvup8,4569
|
|
3
|
+
biointerface-0.1.0.dist-info/AUTHORS.rst,sha256=PlS91A-GkfHib1OMvyWWkRdgjalaZgkJ5_abeMyqhQk,179
|
|
4
|
+
biointerface-0.1.0.dist-info/LICENSE,sha256=jkfdeLRHl54F0J5pRsgqRV_s6drHgL7dRyhV5ujqx10,1078
|
|
5
|
+
biointerface-0.1.0.dist-info/METADATA,sha256=5y-1Zu_1V-Dq2Z9E63Vd3b9lzvwZwopl_eNnXGRcuOU,2100
|
|
6
|
+
biointerface-0.1.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
7
|
+
biointerface-0.1.0.dist-info/top_level.txt,sha256=rvrViMtBwoeIEjKJGFooCoreOc0KWUSQLJSwCvUPVuI,13
|
|
8
|
+
biointerface-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
biointerface
|