Samad14 commited on
Commit
32e4be8
·
verified ·
1 Parent(s): 993103d

Upload folder using huggingface_hub

Browse files
app/.source-revision CHANGED
@@ -1 +1 @@
1
- be3cfeecade37370e56e1e0efbe8d6ab0edb8dfc
 
1
+ a526ef945c27431ebec192c8f7cd60a1d5a75a0e
app/services/rdkit_interactions.py CHANGED
@@ -78,7 +78,7 @@ def _pdb_mol(block: str, label: str):
78
  def _protein_mol(block: str):
79
  """Parse protein residues independently to prevent false inter-residue proximity bonds.
80
 
81
- Reconnects sequential peptide C-N bonds after residue-level chemical perception.
82
  Any residue that cannot be perceived is explicitly recorded as excluded.
83
  """
84
  from collections import OrderedDict
@@ -120,23 +120,8 @@ def _protein_mol(block: str):
120
  if info:
121
  names[info.GetName().strip()] = atom.GetIdx() + offset
122
  residue_atom_indices.append((key, names))
123
- editable = Chem.RWMol(combined)
124
  peptide_bonds_added = 0
125
- for (left_key, left_atoms), (right_key, right_atoms) in zip(residue_atom_indices, residue_atom_indices[1:]):
126
- same_chain = left_key[0] == right_key[0]
127
- try:
128
- sequential = int(right_key[1]) == int(left_key[1]) + 1
129
- except ValueError:
130
- sequential = False
131
- if same_chain and sequential and "C" in left_atoms and "N" in right_atoms:
132
- c_idx, n_idx = left_atoms["C"], right_atoms["N"]
133
- p1 = combined.GetConformer().GetAtomPosition(c_idx)
134
- p2 = combined.GetConformer().GetAtomPosition(n_idx)
135
- distance = p1.Distance(p2)
136
- if 1.1 <= distance <= 1.8:
137
- editable.AddBond(c_idx, n_idx, Chem.BondType.SINGLE)
138
- peptide_bonds_added += 1
139
- protein = editable.GetMol()
140
  Chem.SanitizeMol(protein)
141
  protein.SetProp("_omvetra_skipped_residues", json.dumps(skipped))
142
  protein.SetProp("_omvetra_peptide_bonds_added", str(peptide_bonds_added))
@@ -317,7 +302,7 @@ def _ring_interactions(protein, ligand, protein_features, ligand_features):
317
  def calculate_interactions(protein_pdb: str, ligand_pdb: str, ligand_smiles: str) -> dict[str, Any]:
318
  """Return RDKit feature-based interaction evidence for one docked pose."""
319
  factory = _feature_factory()
320
- protein_raw = _protein_mol(protein_pdb)\n protein_parse = {\n "parser": "RDKit residue-wise perception with sequential peptide-bond reconstruction",\n "residues_skipped": json.loads(protein_raw.GetProp("_omvetra_skipped_residues")),\n "peptide_bonds_reconstructed": int(protein_raw.GetProp("_omvetra_peptide_bonds_added")),\n }\n protein = _with_hydrogens(protein_raw)
321
  ligand = _with_hydrogens(_ligand_with_template(ligand_pdb, ligand_smiles))
322
  pf = _atom_features(protein, factory)
323
  lf = _atom_features(ligand, factory)
 
78
  def _protein_mol(block: str):
79
  """Parse protein residues independently to prevent false inter-residue proximity bonds.
80
 
81
+ Residues remain disconnected to avoid false bonds across close spatial neighbors.
82
  Any residue that cannot be perceived is explicitly recorded as excluded.
83
  """
84
  from collections import OrderedDict
 
120
  if info:
121
  names[info.GetName().strip()] = atom.GetIdx() + offset
122
  residue_atom_indices.append((key, names))
123
+ protein = combined
124
  peptide_bonds_added = 0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  Chem.SanitizeMol(protein)
126
  protein.SetProp("_omvetra_skipped_residues", json.dumps(skipped))
127
  protein.SetProp("_omvetra_peptide_bonds_added", str(peptide_bonds_added))
 
302
  def calculate_interactions(protein_pdb: str, ligand_pdb: str, ligand_smiles: str) -> dict[str, Any]:
303
  """Return RDKit feature-based interaction evidence for one docked pose."""
304
  factory = _feature_factory()
305
+ protein_raw = _protein_mol(protein_pdb)\n protein_parse = {\n "parser": "RDKit residue-wise chemical perception; residues kept disconnected",\n "residues_skipped": json.loads(protein_raw.GetProp("_omvetra_skipped_residues")),\n "peptide_bonds_reconstructed": 0,\n }\n protein = _with_hydrogens(protein_raw)
306
  ligand = _with_hydrogens(_ligand_with_template(ligand_pdb, ligand_smiles))
307
  pf = _atom_features(protein, factory)
308
  lf = _atom_features(ligand, factory)