view gene_fraction/src/args.h @ 0:0fd352f62446 draft default tip

planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
author chrisd
date Sun, 21 Feb 2016 06:05:24 -0500
parents
children
line wrap: on
line source

#ifndef ARGS_H
#define ARGS_H

#include "int_util.h"

#include <string>
#include <vector>
#include <list>

/**
 * Encapsulates information input
 * from the command line.
 */
struct cmd_args {
	std::string amr_fp;
	std::string sam_fp;
	std::list<std::string> sam_dir_fp;
	std::string out_fp;
	
	int threshold;
	int min;
	int max;
	int skip;
	int s_per_lev;

	bool sam_dir = false;		/* This will be set to true when parsing a
                                           directory of sam files. */
	bool bam_stream = false;	/* This will be set to true when executing
                                           samtools view -h example.bam | csa > output
                                           from the command line. */
};

/**
 * Returns a struct of command line arguments.
 */
static inline cmd_args
parse_command_line(int argc, char *argv[]) {
	std::vector<std::string> args(argv, argv + argc);

	cmd_args arg;

	for(int i = 1; i < argc; i++) {
		if(args[i].compare("-amr_fp") == 0)
			arg.amr_fp = args[++i];
		else if(args[i].compare("-sam_fp") == 0) 
			arg.sam_fp = args[++i];
		else if(args[i].compare("-out_fp") == 0)
			arg.out_fp = args[++i];
		else if(args[i].compare("-t") == 0)
			arg.threshold = s_to_i(args[++i]);
		else if(args[i].compare("-min") == 0)
			arg.min = s_to_i(args[++i]);
		else if(args[i].compare("-max") == 0)
			arg.max = s_to_i(args[++i]);
		else if(args[i].compare("-skip") == 0)
			arg.skip = s_to_i(args[++i]);
		else if(args[i].compare("-samples") == 0)
			arg.s_per_lev = s_to_i(args[++i]);
		else if(args[i].compare("-d") == 0)
			arg.sam_dir = true;
		else if(args[i].compare("-bam") == 0)
			arg.bam_stream = true;
	}

	return arg;
}

#endif /* ARGS_H */