diff COBRAxy/ras_generator.py @ 512:f32d3c9089fc draft

Uploaded
author francesco_lapi
date Wed, 08 Oct 2025 12:05:27 +0000
parents c17c6c9d112c
children b02cfa3b36dd
line wrap: on
line diff
--- a/COBRAxy/ras_generator.py	Tue Oct 07 10:31:33 2025 +0000
+++ b/COBRAxy/ras_generator.py	Wed Oct 08 12:05:27 2025 +0000
@@ -297,10 +297,6 @@
     orig_gene_list=dataset.index.copy()
     dataset.index =  [str(el.split(".")[0]) for el in dataset.index]  
 
-    if any(dataset.index.duplicated(keep=False)):
-        list_str=", ".join(orig_gene_list[dataset.index.duplicated(keep=False)])
-        raise ValueError(f"ERROR: Duplicate entries in the gene dataset. The following genes are duplicated: "+list_str)       
-
     #load GPR rules
     rules = load_custom_rules()
     
@@ -310,6 +306,13 @@
         rules_total_string+=rule.replace("(","").replace(")","") + " "
     rules_total_string=list(set(rules_total_string.split(" ")))
 
+    if any(dataset.index.duplicated(keep=False)):
+        genes_duplicates=orig_gene_list[dataset.index.duplicated(keep=False)]
+        genes_duplicates_in_model=[elem for elem in genes_duplicates if elem in rules_total_string]
+        if len(genes_duplicates_in_model)>0:#metabolic genes have duplicated entries in the dataset
+            list_str=", ".join(genes_duplicates_in_model)
+            raise ValueError(f"ERROR: Duplicate entries in the gene dataset present in one or more GPR. The following metabolic genes are duplicated: "+list_str)       
+
     #check if nan value must be ignored in the GPR 
     if ARGS.none:
     #    #e.g. (A or nan --> A)