@@ -38,15 +38,19 @@ def process_studies(
3838 self ,
3939 included_studies : List [Study ],
4040 all_studies : List [Study ] = None ,
41+ all_abstract_studies : List [Study ] = None ,
4142 output_dir : str = None
4243 ) -> List [AnnotationDecision ]:
4344 """
4445 Process studies and annotate their analyses.
4546
4647 Args:
4748 included_studies: List of INCLUDED studies with parsed analyses
48- all_studies: Optional list of ALL studies (INCLUDED + EXCLUDED)
49- with parsed analyses for the all_studies annotation
49+ all_studies: Optional list of all studies from search with parsed
50+ analyses for the all_studies annotation
51+ all_abstract_studies: Optional list of studies included after
52+ abstract screening, with parsed analyses for the all_abstract
53+ annotation
5054 output_dir: Output directory for caching results
5155
5256 Returns:
@@ -55,55 +59,80 @@ def process_studies(
5559 # Load existing cached results
5660 existing_cached_results = self ._load_cached_results (output_dir ) or []
5761
58- if not included_studies :
62+ if (
63+ not included_studies
64+ and not all_studies
65+ and not all_abstract_studies
66+ ):
67+ logger .info ("No studies with analyses found for annotation" )
68+ return existing_cached_results
69+
70+ if included_studies :
5971 logger .info (
60- "No INCLUDED studies with analyses found for annotation"
72+ f"Processing { len (included_studies )} INCLUDED studies with "
73+ "analyses for annotation"
6174 )
62- return existing_cached_results
63-
64- logger .info (
65- f"Processing { len (included_studies )} INCLUDED studies with "
66- "analyses for annotation"
67- )
6875
6976 if output_dir :
7077 for study in included_studies :
7178 if not study .full_text_output_dir :
7279 study .full_text_output_dir = output_dir
73- if all_studies :
74- for study in all_studies :
75- if not study .full_text_output_dir :
76- study .full_text_output_dir = output_dir
80+ for study in all_studies or []:
81+ if not study .full_text_output_dir :
82+ study .full_text_output_dir = output_dir
83+ for study in all_abstract_studies or []:
84+ if not study .full_text_output_dir :
85+ study .full_text_output_dir = output_dir
7786
7887 # Process all analysis-annotation combinations incrementally by study
7988 all_decisions = []
80-
81- # Process the "all_analyses" annotation for INCLUDED studies
82- if self .config .create_all_included_annotation :
83- all_analyses_decisions = self ._create_all_analyses_annotations_by_study (
84- included_studies ,
85- annotation_name = "all_analyses" ,
86- output_dir = output_dir ,
87- existing_results = existing_cached_results
88- )
89- all_decisions .extend (all_analyses_decisions )
90-
91- # Process the "all_studies" annotation for ALL studies if enabled
92- if self .config .create_all_from_search_annotation and all_studies :
93- logger .info (
94- f"Creating 'all_studies' annotation for "
95- f"{ len (all_studies )} studies (INCLUDED + EXCLUDED)"
96- )
97- all_studies_decisions = self ._create_all_analyses_annotations_by_study (
98- all_studies ,
99- annotation_name = "all_studies" ,
100- output_dir = output_dir ,
101- existing_results = existing_cached_results
102- )
103- all_decisions .extend (all_studies_decisions )
89+
90+ # Process system annotations from search/screening/full-text inclusion.
91+ if self .config .create_all_included_annotations :
92+ if all_studies :
93+ logger .info (
94+ f"Creating 'all_studies' annotation for "
95+ f"{ len (all_studies )} studies from search"
96+ )
97+ all_studies_decisions = (
98+ self ._create_all_analyses_annotations_by_study (
99+ all_studies ,
100+ annotation_name = "all_studies" ,
101+ output_dir = output_dir ,
102+ existing_results = existing_cached_results
103+ )
104+ )
105+ all_decisions .extend (all_studies_decisions )
106+
107+ if all_abstract_studies :
108+ logger .info (
109+ f"Creating 'all_abstract' annotation for "
110+ f"{ len (all_abstract_studies )} "
111+ "abstract-screened studies"
112+ )
113+ all_abstract_decisions = (
114+ self ._create_all_analyses_annotations_by_study (
115+ all_abstract_studies ,
116+ annotation_name = "all_abstract" ,
117+ output_dir = output_dir ,
118+ existing_results = existing_cached_results
119+ )
120+ )
121+ all_decisions .extend (all_abstract_decisions )
122+
123+ if included_studies :
124+ all_analyses_decisions = (
125+ self ._create_all_analyses_annotations_by_study (
126+ included_studies ,
127+ annotation_name = "all_analyses" ,
128+ output_dir = output_dir ,
129+ existing_results = existing_cached_results
130+ )
131+ )
132+ all_decisions .extend (all_analyses_decisions )
104133
105134 # Process custom annotations on INCLUDED studies only
106- if self .config .annotations :
135+ if self .config .annotations and included_studies :
107136 custom_decisions = self ._process_custom_annotations_by_study (
108137 included_studies ,
109138 self .config .model ,
@@ -691,7 +720,11 @@ def _save_results_by_study(self, new_decisions: List[AnnotationDecision], output
691720 updated_annotation_names = {
692721 decision .annotation_name for decision in study_decisions
693722 }
694- keep_system_annotations = {"all_analyses" , "all_studies" }
723+ keep_system_annotations = {
724+ "all_analyses" ,
725+ "all_studies" ,
726+ "all_abstract" ,
727+ }
695728 has_custom_updates = any (
696729 name not in keep_system_annotations
697730 for name in updated_annotation_names
0 commit comments