1- from typing import Iterable , Any , Collection , Union , Literal
1+ from typing import Iterable , Any , Collection , Union , Literal , Sequence
22import os
33
44from medcat .storage .serialisables import AbstractSerialisable
@@ -354,16 +354,14 @@ def filter_by_cui(self, cuis_to_keep: Collection[str]) -> None:
354354 self ._reset_subnames ()
355355 self .is_dirty = True
356356
357- def remove_cui (self , cui : str ) -> None :
358- """This function takes a CUI and removes it the CDB.
359-
360- It also removes the CUI from name specific per_cui_status
361- maps as well as well as removes all the names that do not
362- correspond to any CUIs after the removal of this one.
357+ def remove_cuis_bulk (self , cuis : Sequence [str ]) -> None :
358+ for cui in cuis :
359+ self ._remove_cui (cui )
360+ # reset subnames once
361+ self ._reset_subnames ()
363362
364- Args:
365- cui (str): The CUI to remove.
366- """
363+ def _remove_cui (self , cui : str ) -> None :
364+ # NOTE: remove CUI without doing a subname reset
367365 if cui not in self .cui2info :
368366 logger .warning (
369367 "Trying remove CUI '%s' which does not exist in CDB" , cui )
@@ -375,6 +373,18 @@ def remove_cui(self, cui: str) -> None:
375373 # if name name corresponds to no CUIs
376374 if not ni ['per_cui_status' ]:
377375 del self .name2info [name ]
376+
377+ def remove_cui (self , cui : str ) -> None :
378+ """This function takes a CUI and removes it the CDB.
379+
380+ It also removes the CUI from name specific per_cui_status
381+ maps as well as well as removes all the names that do not
382+ correspond to any CUIs after the removal of this one.
383+
384+ Args:
385+ cui (str): The CUI to remove.
386+ """
387+ self ._remove_cui (cui )
378388 # need to reset subnames
379389 self ._reset_subnames ()
380390 self .is_dirty = True
0 commit comments