77import pandas as pd # type: ignore
88from typing import Iterator , List , Optional , Tuple
99
10- NUM_TEST_MODELS = 5
11-
12-
1310############################################
1411class BiomodelsItem :
1512 """Represents a single BioModel with its associated file paths."""
1613
17- def __init__ (self , model_name : str , sbml_paths : List [str ], sedml_paths : List [str ],
18- existing_df : pd .DataFrame = pd .DataFrame ()) -> None :
14+ def __init__ (self ,
15+ model_name : str ,
16+ sbml_paths : List [str ],
17+ sedml_paths : List [str ],
18+ existing_df : pd .DataFrame = pd .DataFrame (),
19+ last_model_num : int = int (1e9 )) -> None :
1920 """
2021 Initialize a BiomodelsItem.
2122
@@ -34,9 +35,8 @@ def __init__(self, model_name: str, sbml_paths: List[str], sedml_paths: List[str
3435 self .model_name = model_name
3536 self .sbml_paths = sbml_paths
3637 self .sedml_paths = sedml_paths
37- if existing_df is None :
38- self .existing_df = pd .DataFrame ()
39- else :
38+ self .existing_df = pd .DataFrame ()
39+ if existing_df is not None :
4040 self .existing_df = existing_df
4141
4242 def __repr__ (self ) -> str :
@@ -57,7 +57,8 @@ def __init__(self,
5757 excluded_models : List [str ] = [],
5858 existing_csv_path : Optional [str ] = None ,
5959 is_report : bool = True ,
60- is_test : bool = False ,
60+ first_model_num : int = 0 ,
61+ last_model_num : int = int (1e9 )
6162 ) -> None :
6263 """
6364 Initialize a BiomodelsIterator.
@@ -75,15 +76,18 @@ def __init__(self,
7576 Path to an existing CSV file containing processed models. If provided,
7677 models listed in this file will be added to the excluded_models list.
7778 The column cn.COL_MODEL_NAME will be used to identify processed models.
78- is_test : bool
79- Whether to run in test mode, which may limit the number of models processed or alter behavior
79+ first_model_num : int
80+ The first model number to include (inclusive).
81+ last_model_num : int
82+ The last model number to include (inclusive).
8083 """
8184 self .biomodels_dir = biomodels_dir
8285 self .excluded_models = excluded_models
8386 self ._is_report = is_report
8487 self ._existing_csv_path = existing_csv_path
8588 self ._existing_df , self ._processed_models = self ._getProcessedModelsFromCSV ()
86- self ._is_test = is_test
89+ self .first_model_num = first_model_num
90+ self .last_model_num = last_model_num
8791
8892 def _getProcessedModelsFromCSV (self ) -> Tuple [pd .DataFrame , List [str ]]:
8993 """
@@ -142,6 +146,14 @@ def getBiomodelInfo(cls, model_dir: str) -> BiomodelsItem:
142146 sedml_paths = sedml_paths ,
143147 existing_df = pd .DataFrame ()
144148 )
149+
150+ @staticmethod
151+ def extractModelNum (model_name : str ) -> int :
152+ """Extracts the numeric part of a model name like 'BIOMD0000000001'."""
153+ try :
154+ return int (model_name .replace ("BIOMD" , "" ))
155+ except ValueError :
156+ return - 1 # Return -1 for unexpected model name formats
145157
146158 def __iter__ (self ) -> Iterator [BiomodelsItem ]:
147159 """
@@ -157,10 +169,11 @@ def __iter__(self) -> Iterator[BiomodelsItem]:
157169 if os .path .isdir (os .path .join (self .biomodels_dir , d ))
158170 and "BIOMD" in d
159171 )
160- for idx , model_name in enumerate (model_names ):
161- if idx > NUM_TEST_MODELS and self ._is_test :
162- self ._msg (f"Test mode enabled, stopping after { NUM_TEST_MODELS } models." )
163- break
172+ for model_name in model_names :
173+ model_num = self .extractModelNum (model_name )
174+ if model_num < self .first_model_num or model_num > self .last_model_num :
175+ self ._msg (f"Skipping model { model_name } with number { model_num } " )
176+ continue
164177 model_dir = os .path .join (self .biomodels_dir , model_name )
165178 if model_name in self ._processed_models :
166179 self ._msg (f"Skipping processed model: { model_name } " )
0 commit comments