| | import argparse
|
| | import os
|
| | import subprocess
|
| | import sys
|
| | from pathlib import Path
|
| |
|
| | def main():
|
| | parser = argparse.ArgumentParser(description="Azure ML Driver for CAFA Evaluator")
|
| | parser.add_argument("--data_dir", type=str, required=True, help="Mount point for the data asset")
|
| | parser.add_argument("--prediction_path", type=str, required=True, help="Relative path to prediction files inside data asset")
|
| | parser.add_argument("--output_dir", type=str, default="./outputs", help="Output directory for results")
|
| | args = parser.parse_args()
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | gt_rel_path = "validation/validation_superset_term.tsv"
|
| | obo_rel_path = "go_info/go-basic.obo"
|
| | ia_rel_path = "IA.tsv"
|
| |
|
| |
|
| | data_dir = Path(args.data_dir)
|
| |
|
| | ground_truth_path = data_dir / gt_rel_path
|
| | ontology_path = data_dir / obo_rel_path
|
| | ia_path = data_dir / ia_rel_path
|
| | prediction_dir = data_dir / args.prediction_path
|
| | output_dir = Path(args.output_dir)
|
| |
|
| |
|
| | missing = []
|
| | if not ground_truth_path.exists(): missing.append(f"Ground truth: {ground_truth_path}")
|
| | if not ontology_path.exists(): missing.append(f"Ontology: {ontology_path}")
|
| | if not ia_path.exists(): missing.append(f"IA file: {ia_path}")
|
| | if not prediction_dir.exists(): missing.append(f"Predictions: {prediction_dir}")
|
| |
|
| | if missing:
|
| | print("="*60)
|
| | print("β Critical Input Files Missing:")
|
| | for m in missing: print(f" - {m}")
|
| | print("Listing data dir contents for debugging:")
|
| | try:
|
| | for root, dirs, files in os.walk(data_dir):
|
| | level = root.replace(str(data_dir), '').count(os.sep)
|
| | if level < 2:
|
| | indent = ' ' * 4 * (level)
|
| | print(f'{indent}{os.path.basename(root)}/')
|
| | for f in files: print(f'{indent} {f}')
|
| | except: pass
|
| | print("="*60)
|
| | sys.exit(1)
|
| |
|
| |
|
| | output_dir.mkdir(parents=True, exist_ok=True)
|
| |
|
| |
|
| |
|
| | script_path = Path("CAFA-evaluator-PK/src/cafaeval/__main__.py")
|
| | if not script_path.exists():
|
| | if Path("src/CAFA-evaluator-PK/src/cafaeval/__main__.py").exists():
|
| | script_path = Path("src/CAFA-evaluator-PK/src/cafaeval/__main__.py")
|
| | else:
|
| | print(f"β Error: CAFA evaluator script not found at {script_path}")
|
| | sys.exit(1)
|
| |
|
| |
|
| |
|
| | cafa_src_path = script_path.parent.parent.resolve()
|
| | env = os.environ.copy()
|
| | env["PYTHONPATH"] = str(cafa_src_path) + os.pathsep + env.get("PYTHONPATH", "")
|
| |
|
| | cmd = [
|
| | sys.executable,
|
| | str(script_path),
|
| | str(ontology_path),
|
| | str(prediction_dir),
|
| | str(ground_truth_path),
|
| | "-ia", str(ia_path),
|
| | "-out_dir", str(output_dir),
|
| | "-no_orphans",
|
| | "-th_step", "0.01"
|
| | ]
|
| |
|
| | print("="*60)
|
| | print("π Starting CAFA Evaluator Wrapper")
|
| | print(f"π Predictions: {prediction_dir}")
|
| | print(f"π Outputs: {output_dir}")
|
| | print(f"π§ PYTHONPATH: {env['PYTHONPATH']}")
|
| | print(f"π Command: {' '.join(cmd)}")
|
| | print("="*60)
|
| |
|
| | try:
|
| |
|
| |
|
| | process = subprocess.run(
|
| | cmd,
|
| | check=True,
|
| | stdout=sys.stdout,
|
| | stderr=sys.stderr,
|
| | text=True,
|
| | env=env
|
| | )
|
| | print("="*60)
|
| | print("β
CAFA Evaluator completed successfully.")
|
| | print("="*60)
|
| |
|
| | except subprocess.CalledProcessError as e:
|
| | print("="*60)
|
| | print("β CAFA EVALUATOR ERROR")
|
| | print(f"Command failed with exit code {e.returncode}")
|
| | print("See stderr above for details.")
|
| | print("="*60)
|
| | sys.exit(e.returncode)
|
| | except Exception as e:
|
| | print("="*60)
|
| | print(f"β UNEXPECTED ERROR: {e}")
|
| | print("="*60)
|
| | sys.exit(1)
|
| |
|
| | if __name__ == "__main__":
|
| | main()
|
| |
|