habdine commited on
Commit
183290f
1 Parent(s): d6cd0d2

Delete utils_convert.py

Browse files
Files changed (1) hide show
  1. utils_convert.py +0 -82
utils_convert.py DELETED
@@ -1,82 +0,0 @@
1
- import numpy as np
2
- from biopandas.pdb import PandasPdb
3
-
4
- pdb_order = [
5
- "record_name",
6
- "atom_number",
7
- "blank_1",
8
- "atom_name",
9
- "alt_loc",
10
- "residue_name",
11
- "blank_2",
12
- "chain_id",
13
- "residue_number",
14
- "insertion",
15
- "blank_3",
16
- "x_coord",
17
- "y_coord",
18
- "z_coord",
19
- "occupancy",
20
- "b_factor",
21
- "blank_4",
22
- "segment_id",
23
- "element_symbol",
24
- "charge",
25
- "line_idx",
26
- ]
27
- mmcif_read = {
28
- "group_PDB": "record_name",
29
- "id": "atom_number",
30
- "auth_atom_id": "atom_name",
31
- "auth_comp_id": "residue_name",
32
- "auth_asym_id": "chain_id",
33
- "auth_seq_id": "residue_number",
34
- "Cartn_x": "x_coord",
35
- "Cartn_y": "y_coord",
36
- "Cartn_z": "z_coord",
37
- "occupancy": "occupancy",
38
- "B_iso_or_equiv": "b_factor",
39
- "type_symbol": "element_symbol",
40
- }
41
-
42
- nonefields = [
43
- "blank_1",
44
- "alt_loc",
45
- "blank_2",
46
- "insertion",
47
- "blank_3",
48
- "blank_4",
49
- "segment_id",
50
- "charge",
51
- "line_idx",
52
- ]
53
-
54
-
55
- def biopandas_mmcif2pdb(pandasmmcif, model_index = 1):
56
- """
57
- Converts the ATOM and HETATM dataframes of PandasMmcif() to PandasPdb() format.
58
- """
59
- pandaspdb = PandasPdb()
60
- for a in ["ATOM", "HETATM"]:
61
- dfa = pandasmmcif.df[a]
62
- dfa = dfa.loc[dfa.pdbx_PDB_model_num == model_index]
63
- if a =='ATOM':
64
- if len(dfa) == 0:
65
- raise ValueError(f"No model found for index: {model_index}")
66
- # keep only those fields found in pdb
67
- dfa = dfa[mmcif_read.keys()]
68
- # rename fields
69
- dfa = dfa.rename(columns=mmcif_read)
70
- # add empty fields
71
- for i in nonefields:
72
- dfa[i] = ""
73
- dfa["charge"] = np.nan
74
- # reorder columns to PandasPdb order
75
- dfa = dfa[pdb_order]
76
- pandaspdb.df[a] = dfa
77
-
78
- # update line_idx
79
- pandaspdb.df["ATOM"]["line_idx"] = pandaspdb.df["ATOM"].index.values
80
- pandaspdb.df["HETATM"]["line_idx"] = pandaspdb.df["HETATM"].index
81
-
82
- return pandaspdb