Showing
1 changed file
with
16 additions
and
8 deletions
... | @@ -166,7 +166,7 @@ class Chain: | ... | @@ -166,7 +166,7 @@ class Chain: |
166 | def __hash__(self): | 166 | def __hash__(self): |
167 | return hash((self.pdb_id, self.pdb_model, self.pdb_chain_id, self.chain_label)) | 167 | return hash((self.pdb_id, self.pdb_model, self.pdb_chain_id, self.chain_label)) |
168 | 168 | ||
169 | - def extract(self, df, khetatm): | 169 | + def extract(self, df, khetatm) -> None: |
170 | """ Extract the part which is mapped to Rfam from the main CIF file and save it to another file. | 170 | """ Extract the part which is mapped to Rfam from the main CIF file and save it to another file. |
171 | """ | 171 | """ |
172 | setproctitle(f"RNANet.py {self.chain_label} extract()") | 172 | setproctitle(f"RNANet.py {self.chain_label} extract()") |
... | @@ -192,8 +192,17 @@ class Chain: | ... | @@ -192,8 +192,17 @@ class Chain: |
192 | 192 | ||
193 | # Load the whole mmCIF into a Biopython structure object: | 193 | # Load the whole mmCIF into a Biopython structure object: |
194 | mmcif_parser = MMCIFParser() | 194 | mmcif_parser = MMCIFParser() |
195 | - s = mmcif_parser.get_structure(self.pdb_id, path_to_3D_data + "RNAcifs/"+self.pdb_id+".cif") | 195 | + try: |
196 | - | 196 | + s = mmcif_parser.get_structure(self.pdb_id, path_to_3D_data + "RNAcifs/"+self.pdb_id+".cif") |
197 | + except ValueError as e: | ||
198 | + warn(f"ValueError in {self.chain_label} CIF file: {e}") | ||
199 | + self.delete_me = True | ||
200 | + return | ||
201 | + except IndexError as e: | ||
202 | + warn(f"IndexError in {self.chain_label} CIF file: {e}") | ||
203 | + self.delete_me = True | ||
204 | + return | ||
205 | + | ||
197 | if self.mapping is not None: | 206 | if self.mapping is not None: |
198 | valid_set = set(df.old_nt_resnum) | 207 | valid_set = set(df.old_nt_resnum) |
199 | else: | 208 | else: |
... | @@ -206,7 +215,6 @@ class Chain: | ... | @@ -206,7 +215,6 @@ class Chain: |
206 | ioobj = MMCIFIO() | 215 | ioobj = MMCIFIO() |
207 | ioobj.set_structure(s) | 216 | ioobj.set_structure(s) |
208 | ioobj.save(self.file, sel) | 217 | ioobj.save(self.file, sel) |
209 | - | ||
210 | 218 | ||
211 | notify(status) | 219 | notify(status) |
212 | 220 | ||
... | @@ -1137,7 +1145,7 @@ class Pipeline: | ... | @@ -1137,7 +1145,7 @@ class Pipeline: |
1137 | exit(1) | 1145 | exit(1) |
1138 | 1146 | ||
1139 | @trace_unhandled_exceptions | 1147 | @trace_unhandled_exceptions |
1140 | - def list_available_mappings(self): | 1148 | + def list_available_mappings(self) -> None: |
1141 | """List 3D chains with available Rfam mappings. | 1149 | """List 3D chains with available Rfam mappings. |
1142 | 1150 | ||
1143 | Return a list of Chain() objects with the mappings set up. | 1151 | Return a list of Chain() objects with the mappings set up. |
... | @@ -1228,7 +1236,7 @@ class Pipeline: | ... | @@ -1228,7 +1236,7 @@ class Pipeline: |
1228 | else: | 1236 | else: |
1229 | mmcif_list = sorted(set([ c.pdb_id for c in self.update ])) | 1237 | mmcif_list = sorted(set([ c.pdb_id for c in self.update ])) |
1230 | try: | 1238 | try: |
1231 | - p = Pool(initializer=init_worker, initargs=(tqdm.get_lock(),), processes=int(coeff_ncores*ncores), maxtasksperchild=1) | 1239 | + p = Pool(initializer=init_worker, initargs=(tqdm.get_lock(),), processes=int(coeff_ncores*ncores)) |
1232 | pbar = tqdm(mmcif_list, maxinterval=1.0, miniters=1, desc="mmCIF files") | 1240 | pbar = tqdm(mmcif_list, maxinterval=1.0, miniters=1, desc="mmCIF files") |
1233 | for _ in p.imap_unordered(work_mmcif, mmcif_list, chunksize=1): | 1241 | for _ in p.imap_unordered(work_mmcif, mmcif_list, chunksize=1): |
1234 | pbar.update(1) # Everytime the iteration finishes, update the global progress bar | 1242 | pbar.update(1) # Everytime the iteration finishes, update the global progress bar |
... | @@ -1407,7 +1415,7 @@ class Pipeline: | ... | @@ -1407,7 +1415,7 @@ class Pipeline: |
1407 | 1415 | ||
1408 | # Start a process pool to dispatch the RNA families, | 1416 | # Start a process pool to dispatch the RNA families, |
1409 | # over multiple CPUs (one family by CPU) | 1417 | # over multiple CPUs (one family by CPU) |
1410 | - p = Pool(initializer=init_worker, initargs=(tqdm.get_lock(),), processes=nworkers, maxtasksperchild=1) | 1418 | + p = Pool(initializer=init_worker, initargs=(tqdm.get_lock(),), processes=nworkers) |
1411 | 1419 | ||
1412 | try: | 1420 | try: |
1413 | fam_pbar = tqdm(total=len(self.fam_list), desc="RNA families", position=0, leave=True) | 1421 | fam_pbar = tqdm(total=len(self.fam_list), desc="RNA families", position=0, leave=True) |
... | @@ -1841,7 +1849,7 @@ def execute_joblist(fulljoblist): | ... | @@ -1841,7 +1849,7 @@ def execute_joblist(fulljoblist): |
1841 | return results | 1849 | return results |
1842 | 1850 | ||
1843 | @trace_unhandled_exceptions | 1851 | @trace_unhandled_exceptions |
1844 | -def work_infer_mappings(update_only, allmappings, codelist): | 1852 | +def work_infer_mappings(update_only, allmappings, codelist) -> list: |
1845 | """Given a list of PDB chains corresponding to an equivalence class from BGSU's NR list, | 1853 | """Given a list of PDB chains corresponding to an equivalence class from BGSU's NR list, |
1846 | build a list of Chain() objects mapped to Rfam families, by expanding available mappings | 1854 | build a list of Chain() objects mapped to Rfam families, by expanding available mappings |
1847 | of any element of the list to all the list elements. | 1855 | of any element of the list to all the list elements. | ... | ... |
-
Please register or login to post a comment