aegis_sim.recording.gvcfrecorder

 1import logging
 2import pathlib
 3
 4from .recorder import Recorder
 5from aegis_sim import variables
 6from aegis_sim.parameterization import parametermanager
 7from aegis_sim.utilities.gvcf import encode_population_to_gvcf
 8from aegis_sim.utilities.funcs import skip
 9
10
11class GVCFRecorder(Recorder):
12    """Write the living population as a FASTA-coordinate multi-sample gVCF at
13    the configured rate. Output is Clair3-format-compatible: ref blocks for
14    invariant runs, <NON_REF> symbolic ALT, multi-allelic genotypes, synthetic
15    GQ=99/DP=30 values. Drops straight into GLnexus joint-genotyping.
16
17    Output: /gvcf/step{step}.gvcf
18    Rate parameter: GVCF_RATE.
19    """
20
21    def __init__(self, odir: pathlib.Path):
22        self.odir = odir / "gvcf"
23        self.init_odir()
24
25    def write(self, population):
26        """
27        # OUTPUT SPECIFICATION
28        path: /gvcf/step{step}.gvcf
29        filetype: gvcf (VCFv4.2 with <NON_REF> + reference blocks)
30        category: log
31        description: Multi-sample gVCF in FASTA-coordinate base positions. REF = consensus across the population, ALT = observed non-REF alleles + <NON_REF>. Designed as a drop-in replacement for Clair3 output so the existing GLnexus -> ABBA-BABA pipeline can use AEGIS truth as ground-truth comparison against read-derived calls.
32        trait granularity: base position (one row per FASTA base or one row per reference block)
33        time granularity: snapshot
34        frequency parameter: GVCF_RATE
35        structure: VCFv4.2 with gVCF extensions.
36        """
37        if parametermanager.parameters.GVCF_RATE <= 0:
38            return
39
40        step = variables.steps
41        should_skip = skip("GVCF_RATE")
42        is_first_step = step == 1
43        is_last_step = step == parametermanager.parameters.STEPS_PER_SIMULATION
44
45        if not (is_first_step or not should_skip or is_last_step):
46            return
47
48        if len(population) == 0:
49            return
50
51        logging.debug(f"gvcf recorded at step {step}.")
52        encode_population_to_gvcf(
53            population=population,
54            output_dir=self.odir,
55            name=f"step{step}",
56        )
class GVCFRecorder(aegis_sim.recording.recorder.Recorder):
12class GVCFRecorder(Recorder):
13    """Write the living population as a FASTA-coordinate multi-sample gVCF at
14    the configured rate. Output is Clair3-format-compatible: ref blocks for
15    invariant runs, <NON_REF> symbolic ALT, multi-allelic genotypes, synthetic
16    GQ=99/DP=30 values. Drops straight into GLnexus joint-genotyping.
17
18    Output: /gvcf/step{step}.gvcf
19    Rate parameter: GVCF_RATE.
20    """
21
22    def __init__(self, odir: pathlib.Path):
23        self.odir = odir / "gvcf"
24        self.init_odir()
25
26    def write(self, population):
27        """
28        # OUTPUT SPECIFICATION
29        path: /gvcf/step{step}.gvcf
30        filetype: gvcf (VCFv4.2 with <NON_REF> + reference blocks)
31        category: log
32        description: Multi-sample gVCF in FASTA-coordinate base positions. REF = consensus across the population, ALT = observed non-REF alleles + <NON_REF>. Designed as a drop-in replacement for Clair3 output so the existing GLnexus -> ABBA-BABA pipeline can use AEGIS truth as ground-truth comparison against read-derived calls.
33        trait granularity: base position (one row per FASTA base or one row per reference block)
34        time granularity: snapshot
35        frequency parameter: GVCF_RATE
36        structure: VCFv4.2 with gVCF extensions.
37        """
38        if parametermanager.parameters.GVCF_RATE <= 0:
39            return
40
41        step = variables.steps
42        should_skip = skip("GVCF_RATE")
43        is_first_step = step == 1
44        is_last_step = step == parametermanager.parameters.STEPS_PER_SIMULATION
45
46        if not (is_first_step or not should_skip or is_last_step):
47            return
48
49        if len(population) == 0:
50            return
51
52        logging.debug(f"gvcf recorded at step {step}.")
53        encode_population_to_gvcf(
54            population=population,
55            output_dir=self.odir,
56            name=f"step{step}",
57        )

Write the living population as a FASTA-coordinate multi-sample gVCF at the configured rate. Output is Clair3-format-compatible: ref blocks for invariant runs, symbolic ALT, multi-allelic genotypes, synthetic GQ=99/DP=30 values. Drops straight into GLnexus joint-genotyping.

Output: /gvcf/step{step}.gvcf Rate parameter: GVCF_RATE.

GVCFRecorder(odir: pathlib.Path)
22    def __init__(self, odir: pathlib.Path):
23        self.odir = odir / "gvcf"
24        self.init_odir()
odir
def write(self, population):
26    def write(self, population):
27        """
28        # OUTPUT SPECIFICATION
29        path: /gvcf/step{step}.gvcf
30        filetype: gvcf (VCFv4.2 with <NON_REF> + reference blocks)
31        category: log
32        description: Multi-sample gVCF in FASTA-coordinate base positions. REF = consensus across the population, ALT = observed non-REF alleles + <NON_REF>. Designed as a drop-in replacement for Clair3 output so the existing GLnexus -> ABBA-BABA pipeline can use AEGIS truth as ground-truth comparison against read-derived calls.
33        trait granularity: base position (one row per FASTA base or one row per reference block)
34        time granularity: snapshot
35        frequency parameter: GVCF_RATE
36        structure: VCFv4.2 with gVCF extensions.
37        """
38        if parametermanager.parameters.GVCF_RATE <= 0:
39            return
40
41        step = variables.steps
42        should_skip = skip("GVCF_RATE")
43        is_first_step = step == 1
44        is_last_step = step == parametermanager.parameters.STEPS_PER_SIMULATION
45
46        if not (is_first_step or not should_skip or is_last_step):
47            return
48
49        if len(population) == 0:
50            return
51
52        logging.debug(f"gvcf recorded at step {step}.")
53        encode_population_to_gvcf(
54            population=population,
55            output_dir=self.odir,
56            name=f"step{step}",
57        )

OUTPUT SPECIFICATION

path: /gvcf/step{step}.gvcf filetype: gvcf (VCFv4.2 with + reference blocks) category: log description: Multi-sample gVCF in FASTA-coordinate base positions. REF = consensus across the population, ALT = observed non-REF alleles + . Designed as a drop-in replacement for Clair3 output so the existing GLnexus -> ABBA-BABA pipeline can use AEGIS truth as ground-truth comparison against read-derived calls. trait granularity: base position (one row per FASTA base or one row per reference block) time granularity: snapshot frequency parameter: GVCF_RATE structure: VCFv4.2 with gVCF extensions.