config

package
v1.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package config provides the object for reading a mendel input file and accessing the variables in it.

Index

Constants

View Source
const (
	HISTORY_FILENAME                 = "mendel.hst"
	FITNESS_FILENAME                 = "mendel.fit"     // this one is faster to produce than mendel.hst
	TOML_FILENAME                    = "mendel_go.toml" // the input parameters
	OUTPUT_FILENAME                  = "mendel_go.out"  //todo: figure out how we can get our own output into this file
	ALLELE_BINS_DIRECTORY            = "allele-bins/"
	NORMALIZED_ALLELE_BINS_DIRECTORY = "normalized-allele-bins/"
	DISTRIBUTION_DEL_DIRECTORY       = "allele-distribution-del/"
	DISTRIBUTION_FAV_DIRECTORY       = "allele-distribution-fav/"
)

Supported file names. Do we need to make this a literal map to be able to check inputted file names??

View Source
const DATA_FILE_PATH_DEFAULT = "./user/output"
View Source
const DEFAULTS_INPUT_FILE = "mendel-defaults.ini"

Variables

View Source
var DEFAULTS_INPUT_DIRS = []string{"/usr/local/share/mendel-go"}

Functions

func FindDefaultFile

func FindDefaultFile() string

FindDefaultFile looks for the defaults input file and returns the 1st one it finds. It exits with error if it can't find one.

func IsVerbose

func IsVerbose(level uint32) bool

IsVerbose tests whether the level given is within the verbose level being output

func ReadCmdArgs

func ReadCmdArgs()

ReadCmdArgs reads the command line args/flag, checks them, and puts them into the Config struct. Will exit if user input error. This is also the factory method for the CommandArgs class and will store the created instance in this packages CmdArgs var.

func ReadFromFile

func ReadFromFile(filename string) error

ReadFromFile reads the specified input file and parses all of the values into the Config struct. This is also the factory method for the Config class and will store the created instance in this packages Cfg var.

func ReadRestartFile

func ReadRestartFile(filename string) error

ReadRestartFile loads values from a restart file. If filename == "", it creates values appropriate for the non-restart case. This is also the factory method for the RestartValues class and will store the created instance in this packages Restart var.

func TribeDir

func TribeDir(tribeNum uint32) string

func TribePrefix

func TribePrefix(tribeNum uint32) string

func Usage

func Usage(exitCode int)

func Verbose

func Verbose(level uint32, msg string, args ...interface{})

These are here, instead of of in pkg utils, to avoid circular imports

Types

type CommandArgs

type CommandArgs struct {
	InputFile, InputFileToCreate, DefaultFile, DataPath, SPCusername string
	CreateZip, Version                                               bool
}
var CmdArgs *CommandArgs

CmdArgs is the singleton instance of CommandArgs that can be accessed throughout the mendel code. It gets set in ReadCmdArgs().

type ComputedValues

type ComputedValues struct {
	Lb_modulo float64
	Alpha_del float64
	Alpha_fav float64
	Gamma_del float64
	Gamma_fav float64
	Del_scale float64 // not sure if i really need these
	Fav_scale float64
}

These values are computed from the Config params and used in several places in the code

var Computed *ComputedValues

func ComputedValuesFactory

func ComputedValuesFactory() (c *ComputedValues)

type Config

type Config struct {
	Basic struct {
		Case_id         string `toml:"case_id"`
		Description     string `toml:"description"`
		Pop_size        uint32 `toml:"pop_size"`
		Num_generations uint32 `toml:"num_generations"`
	} `toml:"basic"`
	Mutations struct {
		Mutn_rate                   float64 `toml:"mutn_rate"`
		Mutn_rate_model             string  `toml:"mutn_rate_model"` // toml does not know how to handle user-defined types like MutationRateModelType
		Frac_fav_mutn               float64 `toml:"frac_fav_mutn"`
		Fraction_neutral            float64 `toml:"fraction_neutral"`
		Genome_size                 float64 `toml:"genome_size"`
		Fitness_effect_model        string  `toml:"fitness_effect_model"`
		Uniform_fitness_effect_del  float64 `toml:"uniform_fitness_effect_del"`
		Uniform_fitness_effect_fav  float64 `toml:"uniform_fitness_effect_fav"`
		High_impact_mutn_fraction   float64 `toml:"high_impact_mutn_fraction"`
		High_impact_mutn_threshold  float64 `toml:"high_impact_mutn_threshold"`
		Max_fav_fitness_gain        float64 `toml:"max_fav_fitness_gain"`
		Fraction_recessive          float64 `toml:"fraction_recessive"`
		Recessive_hetero_expression float64 `toml:"recessive_hetero_expression"`
		Dominant_hetero_expression  float64 `toml:"dominant_hetero_expression"`
		Multiplicative_weighting    float64 `toml:"multiplicative_weighting"`
		Synergistic_epistasis       bool    `toml:"synergistic_epistasis"`
		Se_nonlinked_scaling        float64 `toml:"se_nonlinked_scaling"`
		Se_linked_scaling           float64 `toml:"se_linked_scaling"`
		Upload_mutations            bool    `toml:"upload_mutations"`
		Allow_back_mutn             bool    `toml:"allow_back_mutn"`
		Polygenic_beneficials       bool    `polygenic_beneficials`
		Polygenic_init              string  `toml:"polygenic_init"`
		Polygenic_target            string  `toml:"polygenic_target"`
		Polygenic_effect            float64 `toml:"polygenic_effect"`
	} `toml:"mutations"`
	Selection struct {
		Fraction_random_death       float64 `toml:"fraction_random_death"`
		Fitness_dependent_fertility bool    `toml:"fitness_dependent_fertility"`
		Selection_model             string  `toml:"selection_model"`
		Heritability                float64 `toml:"heritability"`
		Non_scaling_noise           float64 `toml:"non_scaling_noise"`
		Partial_truncation_value    float64 `toml:"partial_truncation_value"`
	} `toml:"selection"`
	Population struct {
		Reproductive_rate            float64 `toml:"reproductive_rate"`
		Num_offspring_model          string  `toml:"num_offspring_model"`
		Recombination_model          uint32  `toml:"recombination_model"`
		Fraction_self_fertilization  float64 `toml:"fraction_self_fertilization"`
		Crossover_model              string  `toml:"crossover_model"`
		Mean_num_crossovers          uint32  `toml:"mean_num_crossovers"`
		Haploid_chromosome_number    uint32  `toml:"haploid_chromosome_number"`
		Num_linkage_subunits         uint32  `toml:"num_linkage_subunits"`
		Num_contrasting_alleles      uint32  `toml:"num_contrasting_alleles"`
		Initial_allele_fitness_model string  `toml:"initial_allele_fitness_model"`
		Initial_alleles_pop_frac     float64 `toml:"initial_alleles_pop_frac"`
		Initial_alleles_frequencies  string  `toml:"initial_alleles_frequencies"`
		Max_total_fitness_increase   float64 `toml:"max_total_fitness_increase"`
		Pop_growth_model             string  `toml:"pop_growth_model"`
		Pop_growth_rate              float64 `toml:"pop_growth_rate"`
		Pop_growth_rate2             float64 `toml:"pop_growth_rate2"`
		Max_pop_size                 uint32  `toml:"max_pop_size"`
		Carrying_capacity            uint32  `toml:"carrying_capacity"`
		Multiple_Bottlenecks         string  `toml:"multiple_bottlenecks"`
		Bottleneck_generation        uint32  `toml:"bottleneck_generation"`
		Bottleneck_pop_size          uint32  `toml:"bottleneck_pop_size"`
		Num_bottleneck_generations   uint32  `toml:"num_bottleneck_generations"`
	} `toml:"population"`
	Tribes struct {
		Num_tribes            uint32  `toml:"num_tribes"`
		Homogenous_tribes     bool    `toml:"homogenous_tribes"`
		Num_indiv_exchanged   uint32  `toml:"num_indiv_exchanged"`
		Migration_generations uint32  `toml:"migration_generations"`
		Migration_model       int     `toml:"migration_model"`
		Tribal_competition    bool    `toml:"tribal_competition"`
		Tribal_fission        bool    `toml:"tribal_fission"`
		Tc_scaling_factor     float64 `toml:"tc_scaling_factor"`
		Group_heritability    float64 `toml:"group_heritability"`
		Social_bonus_factor   float64 `toml:"social_bonus_factor"`
	} `toml:"tribes"`
	Computation struct {
		Tracking_threshold    float32 `toml:"tracking_threshold"`
		Track_neutrals        bool    `toml:"track_neutrals"`
		Extinction_threshold  float64 `toml:"extinction_threshold"`
		Verbosity             uint32  `toml:"verbosity"`
		Data_file_path        string  `toml:"data_file_path"`
		Files_to_output       string  `toml:"files_to_output"`
		Plot_allele_gens      uint32  `toml:"plot_allele_gens"`
		Omit_first_allele_bin bool    `toml:"omit_first_allele_bin"`
		//Restart_case bool  `toml:"restart_case"`
		//Restart_dump_number uint32  `toml:"restart_dump_number"`
		// Considered advanced options:
		Num_threads              uint32 `toml:"num_threads"`
		Random_number_seed       int64  `toml:"random_number_seed"`
		Count_duplicate_alleles  bool   `toml:"count_duplicate_alleles"`
		Performance_profile      string `toml:"performance_profile"`
		Force_gc                 bool   `toml:"force_gc"`
		Allele_count_gc_interval uint32 `toml:"allele_count_gc_interval"`
		Perf_option              int    `toml:"perf_option"`
	} `toml:"computation"`
}

Config is the struct that gets filled in by TOML automatically from the input file.

var Cfg *Config

Cfg is the singleton instance of Config that can be accessed throughout the mendel code. It gets set in ReadFromFile().

func (*Config) WriteToFile

func (c *Config) WriteToFile(file *os.File) error

WriteToFile writes the current config to a file descriptor. The caller is responsible to open the file, log that it is being written, and close the file (so it can be used with files managed by FileMgr).

type FileMgr

type FileMgr struct {
	DataFilePath string                         // the directory in which output files should go
	Files        map[string]*os.File            // key is filename, value is file descriptor (nil if not opened yet)
	Dirs         map[string]map[string]*os.File // directories that hold a group of output files. Key is dir name, value is map in which key is filename, value is file descriptor (nil if not opened yet)
}

FileMgr is a simple object to manage all of the data files mendel writes.

var FMgr *FileMgr

FMgr is the singleton instance of FileMgr, created by FileMgrFactory.

func FileMgrFactory

func FileMgrFactory(dataFilePath, filesToOutput string) *FileMgr

FileMgrFactory creates FMgr and initializes it. filesToOutput comes from the input file.

func (*FileMgr) CloseAllFiles

func (fMgr *FileMgr) CloseAllFiles()

CloseAllFiles closes all of the open files.

func (*FileMgr) CloseDirFile

func (fMgr *FileMgr) CloseDirFile(dirName, fileName string, tribeNum uint32)

CloseDirFile closes a file under a directory.

func (*FileMgr) CloseFile

func (fMgr *FileMgr) CloseFile(fileName string, tribeNum uint32)

CloseFile closes a file under FileMgr control.

func (*FileMgr) GetDirFile

func (fMgr *FileMgr) GetDirFile(dirName, fileName string, tribeNum uint32) *os.File

GetDirFile returns the specified file descriptor in the specified directory, creating/opening the file if necessary.

func (*FileMgr) GetFile

func (fMgr *FileMgr) GetFile(fileName string, tribeNum uint32) *os.File

GetFile returns the specified file descriptor if we have it open.

func (*FileMgr) IsDir

func (fMgr *FileMgr) IsDir(dirName string) bool

IsDir returns true if the specified dir name was specified in the files_to_output config parameter.

func (*FileMgr) IsFile

func (fMgr *FileMgr) IsFile(fileName string) bool

IsFile returns true if the specified file name was specified in the files_to_output config parameter and is open.

type RestartValues

type RestartValues struct {
	Gen_0 uint32
}
var Restart *RestartValues

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL