Spaces:
Running

File size: 3,835 Bytes
4ada50a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# 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