-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit_entities.py
More file actions
41 lines (33 loc) · 1.33 KB
/
split_entities.py
File metadata and controls
41 lines (33 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from data import data as D
from Bio.PDB import is_aa
import numpy as np
import os
import copy
from utilities import d3to1, chem_components
def splitEntities(structure, regexes=None, atom_mapper=None, mi=0):
"""Docstring"""
if regexes is None:
regexes = D.regexes
RNA = ["A","C","G","U","T","DA","DC","DG","DT"]
pro = []
lig = []
for chain in structure[mi]:
for residue in chain:
resname = residue.get_resname().strip()
if resname in d3to1.keys():
pro.append(residue.get_full_id())
else:
if resname in RNA:
lig.append(residue.get_full_id())
elif resname in chem_components.keys():
lig.append(residue.get_full_id())
protein = copy.deepcopy(structure)
rna = copy.deepcopy(structure)
for res in structure.get_residues():
if res.get_full_id() not in pro:
protein[mi][res.get_parent().id].detach_child(res.get_id())
for res in structure.get_residues():
if res.get_full_id() not in lig:
rna[mi][res.get_parent().id].detach_child(res.get_id())
return protein[0], rna[0]
#return structure.slice(structure, pro, name='{}_protein'.format(structure.name)), structure.slice(structure, lig, name='{}_ligand'.format(structure.name))