code: def remove_genelist(self, list_id, case_obj=None):
          
          gene_list = self.gene_list(list_id)
  
          if case_obj:
              # remove a single link between case and gene list
              case_ids = [case_obj.id]
          else:
              # remove all links and the list itself
              case_ids = [case.id for case in gene_list.cases]
              self.session.delete(gene_list)
  
          case_links = self.query(CaseGenelistLink).filter(
              CaseGenelistLink.case_id.in_(case_ids),
              CaseGenelistLink.genelist_id == gene_list.id
          )
          for case_link in case_links:
              self.session.delete(case_link)
  
          self.save()
docs: Remove a gene list and links to cases.