Download path_config.py from isahn/DenAIgeo: direct link, hf CLI and curl.
- Browser
- Download file 3.84 kB
-
https://huggingface.co/spaces/isahn/DenAIgeo/resolve/main/path_config.py
- Command line
-
hf download hf://spaces/isahn/DenAIgeo/path_config.py
-
curl -L -o path_config.py https://huggingface.co/spaces/isahn/DenAIgeo/resolve/main/path_config.py
3.84 kB
| # path_config.py | |
| # -*- coding: utf-8 -*- | |
| """ | |
| κ²½λ‘ μ€μ κ³΅μ© λͺ¨λ. | |
| μλ³Έ(DenAIGeo.py)μλ get_path_config() κ° μ΄λ¦μ κ°μ§λ§ μλ‘ λ€λ₯Έ λ΄μ©μΌλ‘ | |
| λ λ² μ μλμ΄ μμμ΅λλ€. | |
| - Step 1 λ²μ : ref_path / msa_out_path / simphet_ref_path / simphet_input_path / | |
| target_seq_path / output_path λ₯Ό λ°ν | |
| - Step 2 λ²μ : output / newseq_out / unknown_out / results λ₯Ό λ°ν | |
| λ λ²μ μμ μ°λ κ²½λ‘λ₯Ό μ λΆ ν¬ν¨νλ λ¨μΌ λμ λλ¦¬λ‘ ν΅ν©νμ΅λλ€. ν€ μ΄λ¦κ³Ό | |
| μ€μ κ²½λ‘ κ°(λ¬Έμμ΄)μ μλ³Έκ³Ό λμΌνκ² μ μ§νμ΅λλ€. λ€λ§ Step 1μ | |
| 'output_path'(useTestData μ¬λΆμ λ°λΌ newseq_out λλ unknown_out μ€ νλλ§ κ°λ¦¬ν€λ κ°)λ | |
| 'newseq_out' / 'unknown_out' λ ν€λ‘ νμ ν¨κ» κ³μ°ν΄λκ³ , μ€μ μ¬μ©νλ κ³³(Step 1)μμ | |
| useTestData μ¬λΆλ‘ κ·Έλκ·Έλ κ³¨λΌ μ°λλ‘ μ 리νμ΅λλ€. | |
| """ | |
| from __future__ import annotations | |
| from pathlib import Path | |
| def print_settings(s, out=None): | |
| """λΆμμ μ¬μ©λλ ν΅μ¬ μ€μ κ°μ μΆλ ₯ν©λλ€. | |
| out: νμΌλ₯ κ°μ²΄(μ: io.StringIO()). μ§μ νμ§ μμΌλ©΄ κΈ°μ‘΄κ³Ό λμΌνκ² | |
| sys.stdout(κ·Έ μμ μ μ€μ νμ€μΆλ ₯, μ€λ λ λΌμ°ν ν¬ν¨)μ μΆλ ₯ν©λλ€. | |
| print(..., file=out) λ°©μμ΄λΌ sys.stdout μ 건λλ¦¬μ§ μμΌλ―λ‘, | |
| λ€λ₯Έ μ€λ λκ° sys.stdout μ 리λ€μ΄λ νΈ μ€μ΄μ΄λ μλ‘ κ°μνμ§ μμ΅λλ€. | |
| """ | |
| ref_serotype = 'DENV' + s.targetSerotype | |
| print("--- Analysis Settings ---", file=out) | |
| print(f"- Target Serotype: {ref_serotype}", file=out) | |
| print(f"- Target Gene: {s.targetGene}", file=out) | |
| print(f"- Max Year for Model: {s.upper_year}", file=out) | |
| print(f"- Nucleotide Chunk Size (n): {s.n}", file=out) | |
| print("-" * 25, file=out) | |
| def get_path_config(settings_obj): | |
| """λΆμμ νμν λͺ¨λ νμΌ κ²½λ‘λ₯Ό λμ λλ¦¬λ‘ κ΅¬μ±ν΄ λ°νν©λλ€. | |
| settings_obj: settings_dengue λͺ¨λ(λλ λμΌ μμ±μ κ°μ§ κ°μ²΄) | |
| """ | |
| ref_serotype = 'DENV' + settings_obj.targetSerotype | |
| ref_path = Path(settings_obj.REF_PATH) | |
| sample_path = Path(settings_obj.SAMPLE_PATH) | |
| user_path = Path(settings_obj.USER_PATH) | |
| model_path = Path(settings_obj.MODEL_PATH) | |
| base_path = Path(settings_obj.BASE_PATH) | |
| n_str = str(settings_obj.n) | |
| safe_gene_name = settings_obj.targetGene.replace('/', '-') | |
| common_suffix = f"WHOLE({safe_gene_name})_{ref_serotype}" | |
| ref_suffix = f"DENV{settings_obj.targetSerotype}_{safe_gene_name}" | |
| paths = { | |
| # ββ Step 1 (MSA / λ³μ΄ λΆμ μμ±) ββββββββββββββββββββββββββ | |
| 'ref_path': ref_path / f"[ref]Dengue_REF_{ref_suffix}", | |
| 'msa_out_path': base_path / f"[d5-2]Dengue_Sample_MSAout_{common_suffix}", | |
| 'simphet_ref_path': base_path / f"[d6-1]Dengue_NewSeq_Div({n_str})REF_{common_suffix}", | |
| 'simphet_input_path': base_path / f"[d6-2]Dengue_NewSeq_Div({n_str})INPUT_{common_suffix}", | |
| 'target_seq_path': sample_path if settings_obj.useTestData else user_path, | |
| # ββ Step 1 μΆλ ₯ = Step 2 μ λ ₯ (useTestData μ¬λΆλ‘ κ°λΌμ§λ output_path λ₯Ό νμ λ λ€ κ³μ°) ββ | |
| 'newseq_out': base_path / f"[d7-1]Dengue_Sample_Div({n_str})OUT_{common_suffix}_chunkMutation_CSV", | |
| 'unknown_out': base_path / f"[d7-2]Dengue_Users_Div({n_str})OUT_{common_suffix}_chunkMutation_CSV", | |
| # ββ Step 2 (μμΈ‘/μ μ¬λ λΉκ΅) ββββββββββββββββββββββββββββ | |
| 'output': model_path / f"[model]Dengue_Div({n_str})OUT_{common_suffix}_chunkMutation_CSV", | |
| 'results': base_path / "[Results]", | |
| } | |
| paths['results'].mkdir(parents=True, exist_ok=True) | |
| return paths | |