2020
2121from alphafold3_pytorch .data .data_pipeline import *
2222from alphafold3_pytorch .data .data_pipeline import make_mmcif_features
23+
2324from alphafold3_pytorch .common .biomolecule import (
2425 Biomolecule ,
2526 _from_mmcif_object ,
3334from alphafold3_pytorch .data import mmcif_writing , mmcif_parsing
3435
3536from alphafold3_pytorch .life import (
37+ ATOMS ,
3638 reverse_complement ,
3739 reverse_complement_tensor
3840)
@@ -84,6 +86,8 @@ def test_alphafold3_input(
8486 directed_bonds
8587):
8688
89+ CUSTOM_ATOMS = list ({* ATOMS , 'Na' , 'Fe' , 'Si' , 'F' , 'K' })
90+
8791 alphafold3_input = Alphafold3Input (
8892 proteins = ['MLEICLKLVGCKSKKGLSSSSSCYLEEALQRPVASDF' , 'MGKCRGLRTARKLRSHRRDQKWHDKQYKKAHLGTALKANPFGGASHAKGIVLEKVGVEAKQPNSAIRKCVRVQLIKNGKKITAFVPNDGCLNFIEENDEVLVAGFGRKGHAVGDIPGVRFKVVKVANVSLLALYKGKKERPRS' ],
8993 ds_dna = ['ACGTT' ],
@@ -95,7 +99,8 @@ def test_alphafold3_input(
9599 ligands = ['CC1=C(C=C(C=C1)NC(=O)C2=CC=C(C=C2)CN3CCN(CC3)C)NC4=NC=CC(=N4)C5=CN=CC=C5' ],
96100 add_atom_ids = True ,
97101 add_atompair_ids = True ,
98- directed_bonds = directed_bonds
102+ directed_bonds = directed_bonds ,
103+ custom_atoms = CUSTOM_ATOMS
99104 )
100105
101106 batched_atom_input = alphafold3_inputs_to_batched_atom_input (alphafold3_input )
@@ -107,7 +112,7 @@ def test_alphafold3_input(
107112 alphafold3 = Alphafold3 (
108113 dim_atom_inputs = 3 ,
109114 dim_atompair_inputs = 5 ,
110- num_atom_embeds = 47 ,
115+ num_atom_embeds = len ( CUSTOM_ATOMS ) ,
111116 num_atompair_embeds = num_atom_bond_types + 1 , # 0 is for no bond
112117 atoms_per_window = 27 ,
113118 dim_template_feats = 108 ,
@@ -187,17 +192,17 @@ def test_alphafold3_input_to_mmcif(tmp_path):
187192 """Test the Inference I/O Pipeline. This codifies the data_pipeline.py file used for training."""
188193
189194 alphafold3_input = Alphafold3Input (
190- proteins = ['MLEICLKLVGCKSKKGLSSSSSCYLEEALQRPVASDF' , 'MGKCRGLRTARKLRSHRRDQKWHDKQYKKAHLGTALKANPFGGASHAKGIVLEKVGVEAKQPNSAIRKCVRVQLIKNGKKITAFVPNDGCLNFIEENDEVLVAGFGRKGHAVGDIPGVRFKVVKVANVSLLALYKGKKERPRS' ],
191- ds_dna = ['ACGTT' ],
192- ds_rna = ['GCCAU' , 'CCAGU' ],
193- ss_dna = ['GCCTA' ],
194- ss_rna = ['CGCAUA' ],
195- metal_ions = ['Na' , 'Na' , 'Fe' ],
196- misc_molecule_ids = ['Phospholipid' ],
197- ligands = ['CC1=C(C=C(C=C1)NC(=O)C2=CC=C(C=C2)CN3CCN(CC3)C)NC4=NC=CC(=N4)C5=CN=CC=C5' ],
198- add_atom_ids = True ,
199- add_atompair_ids = True ,
200- directed_bonds = True
195+ proteins = ['MLEICLKLVGCKSKKGLSSSSSCYLEEALQRPVASDF' , 'MGKCRGLRTARKLRSHRRDQKWHDKQYKKAHLGTALKANPFGGASHAKGIVLEKVGVEAKQPNSAIRKCVRVQLIKNGKKITAFVPNDGCLNFIEENDEVLVAGFGRKGHAVGDIPGVRFKVVKVANVSLLALYKGKKERPRS' ],
196+ ds_dna = ['ACGTT' ],
197+ ds_rna = ['GCCAU' , 'CCAGU' ],
198+ ss_dna = ['GCCTA' ],
199+ ss_rna = ['CGCAUA' ],
200+ metal_ions = ['Na' , 'Na' , 'Fe' ],
201+ misc_molecule_ids = ['Phospholipid' ],
202+ ligands = ['CC1=C(C=C(C=C1)NC(=O)C2=CC=C(C=C2)CN3CCN(CC3)C)NC4=NC=CC(=N4)C5=CN=CC=C5' ],
203+ add_atom_ids = True ,
204+ add_atompair_ids = True ,
205+ directed_bonds = True
201206 )
202207
203208 test_biomol = alphafold3_input_to_biomolecule (alphafold3_input , atom_positions = torch .randn (261 , 47 , 3 ).numpy ())
@@ -328,7 +333,7 @@ def test_atompos_input():
328333 atom_encoder_depth = 1 ,
329334 token_transformer_depth = 1 ,
330335 atom_decoder_depth = 1 ,
331- )
336+ ),
332337 )
333338
334339 loss = alphafold3 (** batched_atom_input .model_forward_dict ())
0 commit comments