<commit_before>/** \file call_main.cpp
 *
 * Defines the "vg call" subcommand, which calls variation from a graph and a pileup.
 */

#include <omp.h>
#include <unistd.h>
#include <getopt.h>

#include <list>
#include <fstream>

#include "subcommand.hpp"

#include "../vg.hpp"
#include "../caller.hpp"



using namespace std;
using namespace vg;
using namespace vg::subcommand;

void help_call(char** argv) {
    cerr << "usage: " << argv[0] << " call [options] <graph.vg> <pileup.vgpu> > output.vcf" << endl
         << "Output variant calls in VCF format given a graph and pileup" << endl
         << endl
         << "options:" << endl
         << "    -d, --min_depth INT        minimum depth of pileup [" << Caller::Default_min_depth <<"]" << endl
         << "    -e, --max_depth INT        maximum depth of pileup [" << Caller::Default_max_depth <<"]" << endl
         << "    -s, --min_support INT      minimum number of reads required to support snp [" << Caller::Default_min_support <<"]" << endl
         << "    -f, --min_frac FLOAT       minimum percentage of reads required to support snp[" << Caller::Default_min_frac <<"]" << endl
         << "    -q, --default_read_qual N  phred quality score to use if none found in the pileup ["
         << (int)Caller::Default_default_quality << "]" << endl
         << "    -b, --max_strand_bias FLOAT limit to absolute difference between 0.5 and proportion of supporting reads on reverse strand. [" << Caller::Default_max_strand_bias << "]" << endl
         << "    -a, --link-alts            add all possible edges between adjacent alts" << endl
         << "    -A, --aug-graph FILE       write out the agumented graph in vg format" << endl
         << "    -r, --ref PATH             use the given path name as the reference path" << endl
         << "    -c, --contig NAME          use the given name as the VCF contig name" << endl
         << "    -S, --sample NAME          name the sample in the VCF with the given name [SAMPLE]" << endl
         << "    -o, --offset INT           offset variant positions by this amount in VCF [0]" << endl
         << "    -l, --length INT           override total sequence length in VCF" << endl
         << "    -U, --subgraph             expect a subgraph and ignore extra pileup entries outside it" << endl
         << "    -P, --pileup               write pileup under VCF lines (for debugging, output not valid VCF)" << endl
         << "    -D, --depth INT            maximum depth for path search [default 10 nodes]" << endl
         << "    -F, --min_cov_frac FLOAT   min fraction of average coverage at which to call [0.0]" << endl
         << "    -H, --max_het_bias FLOAT   max imbalance factor between alts to call heterozygous [3]" << endl
         << "    -R, --max_ref_bias FLOAT   max imbalance factor between ref and alts to call heterozygous ref [4]" << endl
         << "    -M, --bias_mult FLOAT      multiplier for bias limits for indels as opposed to substitutions [1]" << endl
         << "    -n, --min_count INT        min total supporting read count to call a variant [1]" << endl
         << "    -B, --bin_size  INT        bin size used for counting coverage [250]" << endl
         << "    -C, --exp_coverage INT     specify expected coverage (instead of computing on reference)" << endl
         << "    -O, --no_overlap           don't emit new variants that overlap old ones" << endl
         << "    -u, --use_avg_support      use average instead of minimum support" << endl
         << "    -I, --singleallelic        disable support for multiallelic sites" << endl
         << "    -E, --min_mad              min. minimum allele depth required to PASS filter [5]" << endl
         << "    -h, --help                 print this help message" << endl
         << "    -p, --progress             show progress" << endl
         << "    -v, --verbose              print information and warnings about vcf generation" << endl
         << "    -t, --threads N            number of threads to use" << endl;
}

int main_call(int argc, char** argv) {

    if (argc <= 3) {
        help_call(argv);
        return 1;
    }

    double het_prior = Caller::Default_het_prior;
    int min_depth = Caller::Default_min_depth;
    int max_depth = Caller::Default_max_depth;
    int min_support = Caller::Default_min_support;
    double min_frac = Caller::Default_min_frac;
    int default_read_qual = Caller::Default_default_quality;
    double max_strand_bias = Caller::Default_max_strand_bias;
    string aug_file;
    bool bridge_alts = false;
    
    
    
    // Should we expect a subgraph and ignore pileups for missing nodes/edges?
    bool expectSubgraph = false;
    
    // Should we annotate the VCF with pileup info?
    bool pileupAnnotate = false;

    // This manages conversion from an augmented graph to a VCF, and makes the
    // actual calls.
    Call2Vcf call2vcf;

    bool show_progress = false;
    int thread_count = 1;

    int c;
    optind = 2; // force optind past command positional arguments
    while (true) {
        static struct option long_options[] =
            {
                {"min_depth", required_argument, 0, 'd'},
                {"max_depth", required_argument, 0, 'e'},
                {"min_support", required_argument, 0, 's'},
                {"min_frac", required_argument, 0, 'f'},
                {"default_read_qual", required_argument, 0, 'q'},
                {"max_strand_bias", required_argument, 0, 'b'},
                {"aug_graph", required_argument, 0, 'A'},
                {"link-alts", no_argument, 0, 'a'},
                {"progress", no_argument, 0, 'p'},
                {"verbose", no_argument, 0, 'v'},
                {"threads", required_argument, 0, 't'},
                {"ref", required_argument, 0, 'r'},
                {"contig", required_argument, 0, 'c'},
                {"sample", required_argument, 0, 'S'},
                {"offset", required_argument, 0, 'o'},
                {"depth", required_argument, 0, 'D'},
                {"length", required_argument, 0, 'l'},
                {"subgraph", no_argument, 0, 'U'},
                {"pileup", no_argument, 0, 'P'},
                {"min_cov_frac", required_argument, 0, 'F'},
                {"max_het_bias", required_argument, 0, 'H'},
                {"max_ref_bias", required_argument, 0, 'R'},
                {"bias_mult", required_argument, 0, 'M'},
                {"min_count", required_argument, 0, 'n'},
                {"bin_size", required_argument, 0, 'B'},
                {"avg_coverage", required_argument, 0, 'C'},
                {"no_overlap", no_argument, 0, 'O'},
                {"use_avg_support", no_argument, 0, 'u'},
                {"min_mad", required_argument, 0, 'E'},
                {"help", no_argument, 0, 'h'},
                {0, 0, 0, 0}
            };

        int option_index = 0;
        c = getopt_long (argc, argv, "d:e:s:f:q:b:A:apvt:r:c:S:o:D:l:UPF:H:R:M:n:B:C:OuE:h",
                         long_options, &option_index);

        /* Detect the end of the options. */
        if (c == -1)
            break;

        switch (c)
        {
        case 'd':
            min_depth = atoi(optarg);<commit_msg>Change underscore options to dashes like the other subcommands use<commit_after>/** \file call_main.cpp
 *
 * Defines the "vg call" subcommand, which calls variation from a graph and a pileup.
 */

#include <omp.h>
#include <unistd.h>
#include <getopt.h>

#include <list>
#include <fstream>

#include "subcommand.hpp"

#include "../vg.hpp"
#include "../caller.hpp"



using namespace std;
using namespace vg;
using namespace vg::subcommand;

void help_call(char** argv) {
    cerr << "usage: " << argv[0] << " call [options] <graph.vg> <pileup.vgpu> > output.vcf" << endl
         << "Output variant calls in VCF format given a graph and pileup" << endl
         << endl
         << "options:" << endl
         << "    -d, --min-depth INT        minimum depth of pileup [" << Caller::Default_min_depth <<"]" << endl
         << "    -e, --max-depth INT        maximum depth of pileup [" << Caller::Default_max_depth <<"]" << endl
         << "    -s, --min-support INT      minimum number of reads required to support snp [" << Caller::Default_min_support <<"]" << endl
         << "    -f, --min-frac FLOAT       minimum percentage of reads required to support snp[" << Caller::Default_min_frac <<"]" << endl
         << "    -q, --default-read-qual N  phred quality score to use if none found in the pileup ["
         << (int)Caller::Default_default_quality << "]" << endl
         << "    -b, --max-strand-bias FLOAT limit to absolute difference between 0.5 and proportion of supporting reads on reverse strand. [" << Caller::Default_max_strand_bias << "]" << endl
         << "    -a, --link-alts            add all possible edges between adjacent alts" << endl
         << "    -A, --aug-graph FILE       write out the agumented graph in vg format" << endl
         << "    -r, --ref PATH             use the given path name as the reference path" << endl
         << "    -c, --contig NAME          use the given name as the VCF contig name" << endl
         << "    -S, --sample NAME          name the sample in the VCF with the given name [SAMPLE]" << endl
         << "    -o, --offset INT           offset variant positions by this amount in VCF [0]" << endl
         << "    -l, --length INT           override total sequence length in VCF" << endl
         << "    -U, --subgraph             expect a subgraph and ignore extra pileup entries outside it" << endl
         << "    -P, --pileup               write pileup under VCF lines (for debugging, output not valid VCF)" << endl
         << "    -D, --depth INT            maximum depth for path search [default 10 nodes]" << endl
         << "    -F, --min-cov-frac FLOAT   min fraction of average coverage at which to call [0.0]" << endl
         << "    -H, --max-het-bias FLOAT   max imbalance factor between alts to call heterozygous [3]" << endl
         << "    -R, --max-ref-bias FLOAT   max imbalance factor between ref and alts to call heterozygous ref [4]" << endl
         << "    -M, --bias-mult FLOAT      multiplier for bias limits for indels as opposed to substitutions [1]" << endl
         << "    -n, --min-count INT        min total supporting read count to call a variant [1]" << endl
         << "    -B, --bin-size  INT        bin size used for counting coverage [250]" << endl
         << "    -C, --exp-coverage INT     specify expected coverage (instead of computing on reference)" << endl
         << "    -O, --no-overlap           don't emit new variants that overlap old ones" << endl
         << "    -u, --use-avg-support      use average instead of minimum support" << endl
         << "    -I, --singleallelic        disable support for multiallelic sites" << endl
         << "    -E, --min_mad              min. minimum allele depth required to PASS filter [5]" << endl
         << "    -h, --help                 print this help message" << endl
         << "    -p, --progress             show progress" << endl
         << "    -v, --verbose              print information and warnings about vcf generation" << endl
         << "    -t, --threads N            number of threads to use" << endl;
}

int main_call(int argc, char** argv) {

    if (argc <= 3) {
        help_call(argv);
        return 1;
    }

    double het_prior = Caller::Default_het_prior;
    int min_depth = Caller::Default_min_depth;
    int max_depth = Caller::Default_max_depth;
    int min_support = Caller::Default_min_support;
    double min_frac = Caller::Default_min_frac;
    int default_read_qual = Caller::Default_default_quality;
    double max_strand_bias = Caller::Default_max_strand_bias;
    string aug_file;
    bool bridge_alts = false;
    
    
    
    // Should we expect a subgraph and ignore pileups for missing nodes/edges?
    bool expectSubgraph = false;
    
    // Should we annotate the VCF with pileup info?
    bool pileupAnnotate = false;

    // This manages conversion from an augmented graph to a VCF, and makes the
    // actual calls.
    Call2Vcf call2vcf;

    bool show_progress = false;
    int thread_count = 1;

    int c;
    optind = 2; // force optind past command positional arguments
    while (true) {
        static struct option long_options[] =
            {
                {"min-depth", required_argument, 0, 'd'},
                {"max-depth", required_argument, 0, 'e'},
                {"min-support", required_argument, 0, 's'},
                {"min-frac", required_argument, 0, 'f'},
                {"default-read-qual", required_argument, 0, 'q'},
                {"max-strand-bias", required_argument, 0, 'b'},
                {"aug-graph", required_argument, 0, 'A'},
                {"link-alts", no_argument, 0, 'a'},
                {"progress", no_argument, 0, 'p'},
                {"verbose", no_argument, 0, 'v'},
                {"threads", required_argument, 0, 't'},
                {"ref", required_argument, 0, 'r'},
                {"contig", required_argument, 0, 'c'},
                {"sample", required_argument, 0, 'S'},
                {"offset", required_argument, 0, 'o'},
                {"depth", required_argument, 0, 'D'},
                {"length", required_argument, 0, 'l'},
                {"subgraph", no_argument, 0, 'U'},
                {"pileup", no_argument, 0, 'P'},
                {"min-cov-frac", required_argument, 0, 'F'},
                {"max-het-bias", required_argument, 0, 'H'},
                {"max-ref-bias", required_argument, 0, 'R'},
                {"bias-mult", required_argument, 0, 'M'},
                {"min-count", required_argument, 0, 'n'},
                {"bin-size", required_argument, 0, 'B'},
                {"avg-coverage", required_argument, 0, 'C'},
                {"no-overlap", no_argument, 0, 'O'},
                {"use-avg-support", no_argument, 0, 'u'},
                {"min-mad", required_argument, 0, 'E'},
                {"help", no_argument, 0, 'h'},
                {0, 0, 0, 0}
            };

        int option_index = 0;
        c = getopt_long (argc, argv, "d:e:s:f:q:b:A:apvt:r:c:S:o:D:l:UPF:H:R:M:n:B:C:OuE:h",
                         long_options, &option_index);

        /* Detect the end of the options. */
        if (c == -1)
            break;

        switch (c)
        {
        case 'd':
            min_depth = atoi(optarg);
{'fraction_non_alphanumeric': 0.13462202278218846, 'fraction_numerical': 0.008008284432171211, 'mean_word_length': 1.9515077424612877, 'pattern_counts': {'":': 0, '<': 351, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '216174', 'n_tokens_mistral': 4435, 'n_tokens_neox': 4170, 'n_words': 1388}