@@ -59,7 +59,6 @@ def _create_from_cif_path(
5959 cif_path : str ,
6060 ) -> SampleModelBase :
6161 """Create a model by reading and parsing a CIF file."""
62- # Parse CIF and build model
6362 doc = cls ._read_cif_document_from_path (cif_path )
6463 block = cls ._pick_first_structural_block (doc )
6564 return cls ._create_model_from_block (block )
@@ -70,7 +69,6 @@ def _create_from_cif_str(
7069 cif_str : str ,
7170 ) -> SampleModelBase :
7271 """Create a model by parsing a CIF string."""
73- # Parse CIF string and build model
7472 doc = cls ._read_cif_document_from_string (cif_str )
7573 block = cls ._pick_first_structural_block (doc )
7674 return cls ._create_model_from_block (block )
@@ -81,16 +79,19 @@ def _create_from_cif_str(
8179 # gemmi helpers
8280 # -------------
8381
82+ # TODO: Move to a common CIF utility module? io.cif.parse?
8483 @staticmethod
8584 def _read_cif_document_from_path (path : str ) -> gemmi .cif .Document :
8685 """Read a CIF document from a file path."""
8786 return gemmi .cif .read_file (path )
8887
88+ # TODO: Move to a common CIF utility module? io.cif.parse?
8989 @staticmethod
9090 def _read_cif_document_from_string (text : str ) -> gemmi .cif .Document :
9191 """Read a CIF document from a raw text string."""
9292 return gemmi .cif .read_string (text )
9393
94+ # TODO: Move to a common CIF utility module? io.cif.parse?
9495 @staticmethod
9596 def _has_structural_content (block : gemmi .cif .Block ) -> bool :
9697 """Return True if the CIF block contains structural content."""
@@ -108,6 +109,7 @@ def _has_structural_content(block: gemmi.cif.Block) -> bool:
108109 ]
109110 return all (block .find_value (tag ) for tag in required_cell )
110111
112+ # TODO: Move to a common CIF utility module? io.cif.parse?
111113 @classmethod
112114 def _pick_first_structural_block (
113115 cls ,
@@ -124,6 +126,7 @@ def _pick_first_structural_block(
124126 except Exception :
125127 return doc [0 ]
126128
129+ # TODO: Move to a common CIF utility module? io.cif.parse?
127130 @classmethod
128131 def _create_model_from_block (
129132 cls ,
@@ -137,11 +140,13 @@ def _create_model_from_block(
137140 cls ._set_atom_sites_from_cif_block (model , block )
138141 return model
139142
143+ # TODO: Move to a common CIF utility module? io.cif.parse?
140144 @classmethod
141145 def _extract_name_from_block (cls , block : gemmi .cif .Block ) -> str :
142146 """Extract a model name from the CIF block name."""
143147 return block .name or 'model'
144148
149+ # TODO: Move to a common CIF utility module? io.cif.parse?
145150 @classmethod
146151 def _set_space_group_from_cif_block (
147152 cls ,
@@ -151,6 +156,7 @@ def _set_space_group_from_cif_block(
151156 """Populate the model's space group from a CIF block."""
152157 model .space_group .from_cif (block )
153158
159+ # TODO: Move to a common CIF utility module? io.cif.parse?
154160 @classmethod
155161 def _set_cell_from_cif_block (
156162 cls ,
@@ -160,6 +166,7 @@ def _set_cell_from_cif_block(
160166 """Populate the model's unit cell from a CIF block."""
161167 model .cell .from_cif (block )
162168
169+ # TODO: Move to a common CIF utility module? io.cif.parse?
163170 @classmethod
164171 def _set_atom_sites_from_cif_block (
165172 cls ,
@@ -168,3 +175,7 @@ def _set_atom_sites_from_cif_block(
168175 ) -> None :
169176 """Populate the model's atom sites from a CIF block."""
170177 model .atom_sites .from_cif (block )
178+
179+ # TODO: How to automatically parce and populate all categories?
180+ # for category in model.categories:
181+ # cls._set_category_from_cif_block(category, block)
0 commit comments