// Protocol buffers for representing gnomAD-CNV v4 data.

syntax = "proto3";

package annonars.gnomad.gnomad_cnv4;

import "annonars/gnomad/exac_cnv.proto";


// Carrier counts
message CarrierCounts {
    // Number of releaseable samples with a variant at this site.
    int32 sc = 1;
    // Proportion of releaseable samples (site frequency) with a variant at
    // this site.
    float sf = 2;
    // Total number of releaseable samples considered at this site.
    int32 sn = 3;
}

// Store the carrier counts for the given sub cohort and sub cohort factored by sex.
message CarrierCountsBySex {
    // Overall carrier counts in the sub cohort.
    CarrierCounts overall = 1;
    // Carrier counts in female/XX karyotype individuals of sub cohort.
    optional CarrierCounts xx = 2;
    // Carrier counts in male/XY karyotype individuals of sub cohort.
    optional CarrierCounts xy = 3;
}

// ExAC population.
enum Population {
    // unknown
    POPULATION_UNKNOWN = 0;
    // African
    POPULATION_AFR = 1;
    // Ad Mixed American
    POPULATION_AMR = 2;
    // Ashkenazi Jewish
    POPULATION_ASJ = 3;
    // East Asian
    POPULATION_EAS = 4;
    // Finnish
    POPULATION_FIN = 5;
    // Middle Eastern
    POPULATION_MID = 6;
    // Non-Finnish European
    POPULATION_NFE = 7;
    // South Asian
    POPULATION_SAS = 8;
}

// Store the carrier counts for a population.
message PopulationCarrierCounts {
    // The population.
    Population population = 1;
    // The overall allele counts and the one by sex.
    CarrierCountsBySex counts = 2;
}

// Store the allele counts for the given cohort.
message CohortCarrierCounts {
    // Name of the cohort, empty for global.
    optional string cohort = 1;
    // The overall carrier counts and the one by sex.
    CarrierCountsBySex by_sex = 2;
    // Carrier counts for each population.
    repeated PopulationCarrierCounts by_population = 3;
}

// One record in the gnomAD-CNV v4 dataset.
message Record {
    // Chromosome name.
    string chrom = 1;
    // 1-based start position.
    int32 start = 2;
    // 1-based stop position.
    int32 stop = 3;

    // 1-based inner start position.
    int32 inner_start = 4;
    // 1-based inner stop position.
    int32 inner_stop = 5;
    // 1-based outer start position.
    int32 outer_start = 6;
    // 1-based inner stop position.
    int32 outer_stop = 7;

    // Unique identifier for the variant.
    string id = 8;

    // Length of the SV.
    int32 sv_len = 9;
    // The type of the variant.
    annonars.gnomad.exac_cnv.CnvType sv_type = 10;

    // Median number of callable exons spanned by variant passing QS
    // threshold.
    int32 n_exn_var = 11;
    // Median number of callable intervals spanned by variant passing
    // QS threshold.
    int32 n_int_var = 12;
    // Symbols of genes predicted to be impacted by variant
    repeated string genes = 13;

    // Carrier counts in the different population.
    //
    // The populations in gnomAD CNV v4 are: empty for global, "non_neuro",
    // and "non_neuro_coontrols".
    repeated CohortCarrierCounts carrier_counts = 14;
}
