1#ifndef SIM_OPERATIONS_H
2#define SIM_OPERATIONS_H
77 #define RND_IMPLEMENTATION
112 #define GSC_ID_T unsigned int
123#define GSC_NA_IDX (GSC_ID_T)-1
139 #define GSC_GLOBALX_T unsigned int
143#define GSC_NA_GLOBALX (GSC_GLOBALX_T)-1
157 #define GSC_LOCALX_T unsigned int
161#define GSC_NA_LOCALX (GSC_LOCALX_T)-1
172 #define GSC_GENOLEN_T unsigned int
176#define GSC_NA_GENOLEN (GSC_GENOLEN_T)-1
179 #define CONTIG_WIDTH 1000
181 #if CONTIG_WIDTH > SIZE_MAX
182 #error "This C compiler cannot handle a CONTIG_WIDTH that large. Please redefine."
183 #elif CONTIG_WIDTH > UINT_MAX
186 #define GSC_LOCALX_T size_t
187 #define GSC_NA_LOCALX SIZE_MAX
189 #undef GSC_NA_GLOBALX
190 #define GSC_GLOBAL_T size_t
191 #define GSC_NA_GLOBALX SIZE_MAX
196 #define NAME_LENGTH 45
199#if defined(GSC_MALLOC) && !defined(GSC_FREE) || !defined(GSC_MALLOC) && defined(GSC_FREE)
200#error "You must define both GSC_MALLOC and GSC_FREE, or neither."
202#if !defined(GSC_MALLOC) && !defined(GSC_FREE)
203 #define GSC_MALLOC(size) malloc(size)
204 #define GSC_FREE(ptr) free(ptr)
228#ifndef GSC_NO_SHORT_NAMES
230#define GENOLEN_T GSC_GENOLEN_T
231#define LOCALX_T GSC_LOCALX_T
232#define GLOBALX_T GSC_GLOBALX_T
234#define LOGICVAL GSC_LOGICVAL
235#define NA_GENOLEN GSC_NA_GENOLEN
236#define NA_LOCALX GSC_NA_LOCALX
237#define NA_GLOBALX GSC_NA_GLOBALX
238#define NA_IDX GSC_NA_IDX
240#define FALSE GSC_FALSE
243#define PedigreeID gsc_PedigreeID
244#define NO_PEDIGREE GSC_NO_PEDIGREE
245#define GroupNum gsc_GroupNum
246#define NO_GROUP GSC_NO_GROUP
247#define EffectID gsc_EffectID
248#define NO_EFFECTSET GSC_NO_EFFECTSET
249#define LabelID gsc_LabelID
250#define NO_LABEL GSC_NO_LABEL
251#define MapID gsc_MapID
252#define NO_MAP GSC_NO_MAP
253#define MultiIDSet gsc_MultiIDSet
255#define TableSize gsc_TableSize
256#define DecimalMatrix gsc_DecimalMatrix
257#define GenOptions gsc_GenOptions
258#define BASIC_OPT GSC_BASIC_OPT
259#define MarkerBlocks gsc_MarkerBlocks
260#define KnownGenome gsc_KnownGenome
261#define RecombinationMap gsc_RecombinationMap
262#define AlleleMatrix gsc_AlleleMatrix
263#define MarkerEffects gsc_MarkerEffects
264#define SimData gsc_SimData
265#define GenoLocation gsc_GenoLocation
266#define INVALID_GENO_LOCATION GSC_INVALID_GENO_LOCATION
267#define IS_VALID_LOCATION GSC_IS_VALID_LOCATION
268#define BidirectionalIterator gsc_BidirectionalIterator
269#define RandomAccessIterator gsc_RandomAccessIterator
271#define create_new_label gsc_create_new_label
272#define change_label_default gsc_change_label_default
273#define change_label_to gsc_change_label_to
274#define change_label_by_amount gsc_change_label_by_amount
275#define change_label_to_values gsc_change_label_to_values
276#define change_names_to_values gsc_change_names_to_values
277#define change_allele_symbol gsc_change_allele_symbol
278#define change_eff_set_centres_to_values gsc_change_eff_set_centres_to_values
279#define change_eff_set_centre_of_markers gsc_change_eff_set_centre_of_markers
280#define change_eff_set_centre_of_allele_count gsc_change_eff_set_centre_of_allele_count
282#define create_empty_simdata gsc_create_empty_simdata
283#define clear_simdata gsc_clear_simdata
284#define load_mapfile gsc_load_mapfile
285#define load_effectfile gsc_load_effectfile
286#define load_genotypefile gsc_load_genotypefile
287#define load_data_files gsc_load_data_files
288#define DETECT_FILE_FORMAT GSC_DETECT_FILE_FORMAT
289#define FileFormatSpec gsc_FileFormatSpec
290#define define_matrix_format_details gsc_define_matrix_format_details
292#define create_bidirectional_iter gsc_create_bidirectional_iter
293#define create_randomaccess_iter gsc_create_randomaccess_iter
294#define set_bidirectional_iter_to_start gsc_set_bidirectional_iter_to_start
295#define set_bidirectional_iter_to_end gsc_set_bidirectional_iter_to_end
296#define next_forwards gsc_next_forwards
297#define next_backwards gsc_next_backwards
298#define next_get_nth gsc_next_get_nth
299#define get_name gsc_get_name
300#define set_name gsc_set_name
301#define get_alleles gsc_get_alleles
302#define get_first_parent gsc_get_first_parent
303#define get_second_parent gsc_get_second_parent
304#define get_id gsc_get_id
305#define get_group gsc_get_group
306#define set_group gsc_set_group
307#define get_label_value gsc_get_label_value
308#define get_index_of_label gsc_get_index_of_label
309#define get_index_of_eff_set gsc_get_index_of_eff_set
310#define get_index_of_map gsc_get_index_of_map
311#define get_index_of_genetic_marker gsc_get_index_of_genetic_marker
312#define get_existing_groups gsc_get_existing_groups
313#define get_existing_group_counts gsc_get_existing_group_counts
314#define get_group_size gsc_get_group_size
315#define get_group_names gsc_get_group_names
316#define get_group_ids gsc_get_group_ids
317#define get_group_indexes gsc_get_group_indexes
318#define get_group_genes gsc_get_group_genes
319#define get_group_bvs gsc_get_group_bvs
320#define get_group_parent_names gsc_get_group_parent_names
321#define get_group_parent_ids gsc_get_group_parent_ids
322#define get_group_pedigrees gsc_get_group_pedigrees
324#define combine_groups gsc_combine_groups
325#define make_group_from gsc_make_group_from
326#define split_by_label_value gsc_split_by_label_value
327#define split_by_label_range gsc_split_by_label_range
328#define split_into_individuals gsc_split_into_individuals
329#define split_into_families gsc_split_into_families
330#define split_into_halfsib_families gsc_split_into_halfsib_families
331#define split_evenly_into_two gsc_split_evenly_into_two
332#define split_evenly_into_n gsc_split_evenly_into_n
333#define split_into_buckets gsc_split_into_buckets
334#define split_randomly_into_two gsc_split_randomly_into_two
335#define split_randomly_into_n gsc_split_randomly_into_n
336#define split_by_probabilities gsc_split_by_probabilities
338#define generate_gamete gsc_generate_gamete
339#define generate_doubled_haploid gsc_generate_doubled_haploid
340#define generate_clone gsc_generate_clone
341#define make_random_crosses gsc_make_random_crosses
342#define make_random_crosses_between gsc_make_random_crosses_between
343#define make_targeted_crosses gsc_make_targeted_crosses
344#define self_n_times gsc_self_n_times
345#define make_doubled_haploids gsc_make_doubled_haploids
346#define make_clones gsc_make_clones
347#define make_all_unidirectional_crosses gsc_make_all_unidirectional_crosses
348#define make_crosses_from_file gsc_make_crosses_from_file
349#define make_double_crosses_from_file gsc_make_double_crosses_from_file
351#define split_by_bv gsc_split_by_bv
352#define calculate_bvs gsc_calculate_bvs
353#define calculate_allele_counts gsc_calculate_allele_counts
354#define create_evenlength_blocks_each_chr gsc_create_evenlength_blocks_each_chr
355#define load_blocks gsc_load_blocks
356#define calculate_local_bvs gsc_calculate_local_bvs
357#define calculate_optimal_haplotype gsc_calculate_optimal_haplotype
358#define calculate_optimal_possible_haplotype gsc_calculate_optimal_possible_haplotype
359#define calculate_optimal_bv gsc_calculate_optimal_bv
360#define calculate_optimal_possible_bv gsc_calculate_optimal_possible_bv
361#define calculate_minimal_bv gsc_calculate_minimal_bv
363#define delete_group gsc_delete_group
364#define delete_label gsc_delete_label
365#define delete_recombination_map gsc_delete_recombination_map
366#define delete_eff_set gsc_delete_eff_set
367#define delete_dmatrix gsc_delete_dmatrix
368#define delete_simdata gsc_delete_simdata
369#define delete_markerblocks gsc_delete_markerblocks
370#define delete_bidirectional_iter gsc_delete_bidirectional_iter
371#define delete_randomaccess_iter gsc_delete_randomaccess_iter
373#define save_markerblocks gsc_save_markerblocks
374#define save_genotypes gsc_save_genotypes
375#define save_allele_counts gsc_save_allele_counts
376#define save_pedigrees gsc_save_pedigrees
377#define save_bvs gsc_save_bvs
378#define save_local_bvs gsc_save_local_bvs
438#define GSC_CREATE_BUFFER(n,type,length) \
439type n##stack[sizeof(int)*CONTIG_WIDTH/sizeof(type)]; size_t n##cap = length; \
440type* n = (n##cap >= sizeof(n##stack)/sizeof(type)) ? gsc_malloc_wrap(sizeof(type)*n##cap,GSC_TRUE) : n##stack;
448#define GSC_BUFFER_ISHEAP(n) n##cap >= sizeof(n##stack)/sizeof(n##stack[0])
463#define GSC_FINALISE_BUFFER(n,as,nentries) do { if (n##cap >= sizeof(n##stack)/sizeof(n##stack[0])) { as = n; } else \
464{ size_t len = nentries > n##cap ? n##cap : nentries; as = gsc_malloc_wrap(sizeof(n##stack[0])*len,GSC_TRUE); memcpy(as,n,sizeof(n##stack[0])*len); } } while (0)
477#define GSC_DELETE_BUFFER(n) do { if (n##cap >= sizeof(n##stack)/sizeof(n##stack[0])) { GSC_FREE(n); } \
478n = NULL; n##cap = 0; } while (0)
498#define GSC_STRETCH_BUFFER(n,newlen) do { \
499 if (newlen < n##cap) { } \
500 else if (n##cap >= sizeof(n##stack)/sizeof(n##stack[0])) { \
501 void* tmp = gsc_malloc_wrap(sizeof(n##stack[0])*newlen,GSC_FALSE); \
503 memcpy(tmp,n,sizeof(n[0])*n##cap); \
504 GSC_FREE(n); n = tmp; n##cap = newlen; }} \
505 else if (newlen >= sizeof(n##stack)/sizeof(n##stack[0])) { \
506 n = gsc_malloc_wrap(sizeof(n##stack[0])*newlen,GSC_FALSE); \
508 memcpy(n,n##stack,sizeof(n##stack[0])*n##cap); n##cap = newlen; }} \
509 else if (newlen < CONTIG_WIDTH) { n##cap = newlen; } \
565#define GSC_NO_PEDIGREE (gsc_PedigreeID){.id=GSC_NA_ID}
578#define GSC_NO_GROUP (gsc_GroupNum){.num=GSC_NA_ID}
590#define GSC_NO_EFFECTSET (gsc_EffectID){.id=GSC_NA_ID}
602#define GSC_NO_LABEL (gsc_LabelID){.id=GSC_NA_ID}
614#define GSC_NO_MAP (gsc_MapID){.id=GSC_NA_ID}
739 GSC_LINKAGEGROUP_REORDER
1093#define GSC_DETECT_FILE_FORMAT ((gsc_FileFormatSpec){.filetype=GSC_GENOTYPEFILE_UNKNOWN})
1132void gsc_shuffle_up_to(rnd_pcg_t* rng,
void* sequence,
const size_t item_size,
const size_t total_n,
const size_t n_to_shuffle);
1142 const gsc_LabelID whichLabel,
const size_t n_values,
const int* values);
1144 const size_t n_values,
const char** values);
1150 const double* values);
1154 const char** marker_names,
1155 const double* centres);
1159 const char** marker_names,
1160 const double* centres,
1162 const _Bool reset_centres);
1198 const int* labelDefaults,
const GSC_LOCALX_T n_genotypes);
1235 double expected_n_recombinations);
1278#define GSC_INVALID_GENO_LOCATION (gsc_GenoLocation){.localAM=0,.localPos=GSC_NA_LOCALX}
1282#define GSC_IS_VALID_LOCATION(g) (g.localAM != 0 && g.localPos != GSC_NA_LOCALX)
1441 if (oldname != NULL) free(oldname);
1584 const int whichParent,
char** output);
1602 const gsc_LabelID whichLabel,
const int valueToSplit);
1604 const int valueLowBound,
const int valueHighBound);
1608 void* somequality_data,
1621 const int parent,
size_t maxentries_results,
gsc_GroupNum* results);
1648 const size_t n,
const double* probs,
gsc_GroupNum* results);
1765 const char symbol_na,
1766 char* opt_haplotype);
1770 const char symbol_na,
1771 char* opt_haplotype);
1815 const _Bool markers_as_rows);
1820 const _Bool markers_as_rows);
1822 const _Bool full_pedigree);
1829 const _Bool headers);
1835 char**
const marker_names,
const _Bool markers_as_rows);
1839 char**
const marker_names,
1840 const _Bool markers_as_rows,
1874 char* parent1,
unsigned int p1num,
1875 char* parent2,
unsigned int p2num,
1876 char* offspring,
int certain);
1878 char* parent1,
unsigned int p1num,
1879 char* parent2,
unsigned int p2num,
1880 char* offspring,
int window_size,
1895 return (p1[i<<1] == p2[i<<1] || p1[(i<<1) + 1] == p2[i] || p1[i] == p2[(i<<1) + 1]);
1914 for (
int j = 0; j < w; ++j) {
1916 same = same && (g1[i<<1] == g2[i<<1] || g1[(i<<1) + 1] == g2[i] || g1[i] == g2[(i<<1) + 1]);
1922 int window_len,
int certain);
double gsc_calculate_optimal_possible_bv(const gsc_SimData *d, const gsc_GroupNum group, const gsc_EffectID effID)
Calculates the breeding value of the highest breeding-value genotype that can be created from the all...
gsc_DecimalMatrix gsc_calculate_utility_local_bvs(gsc_BidirectionalIterator *targets, gsc_MarkerBlocks b, gsc_MarkerEffects e)
Calculate local haplotype block breeding values for a set of genotypes.
gsc_DecimalMatrix gsc_calculate_allele_counts(const gsc_SimData *d, const gsc_GroupNum group, const char allele)
Calculates the number of times at each marker that a particular allele appears.
gsc_DecimalMatrix gsc_calculate_bvs(const gsc_SimData *d, const gsc_GroupNum group, const gsc_EffectID effID)
Calculate the fitness metric/breeding value for every genotype in the simulation or every genotype in...
gsc_MarkerBlocks gsc_create_evenlength_blocks_each_chr(const gsc_SimData *d, const gsc_MapID mapid, const unsigned int n)
Divide the genotype into blocks where each block contains all markers within a 1/n length section of ...
gsc_GroupNum gsc_split_by_bv(gsc_SimData *d, const gsc_GroupNum group, const gsc_EffectID effID, const unsigned int top_n, const _Bool lowIsBest)
Takes the top_n individuals in the group with the best breeding values/fitnesses and puts them in a n...
void gsc_calculate_optimal_haplotype(const gsc_SimData *d, const gsc_EffectID effID, const char symbol_na, char *opt_haplotype)
Create a string containing the allele at each marker with the highest contributions to the additive b...
gsc_DecimalMatrix gsc_calculate_utility_bvs(gsc_BidirectionalIterator *targets, const gsc_MarkerEffects *effset)
Calculate the fitness metric/breeding value for a set of genotypes.
void gsc_calculate_optimal_possible_haplotype(const gsc_SimData *d, const gsc_GroupNum group, const gsc_EffectID effID, const char symbol_na, char *opt_haplotype)
Calculates the highest-breeding-value haplotype that can be created from the alleles present in a giv...
gsc_DecimalMatrix gsc_calculate_local_bvs(const gsc_SimData *d, const gsc_GroupNum group, const gsc_MarkerBlocks b, const gsc_EffectID effID)
Calculate local breeding values for every genotype in the simulation or every genotype in a certain g...
double gsc_calculate_minimal_bv(const gsc_SimData *d, const gsc_EffectID effID)
Calculate the lowest possible breeding value any (diploid) genotype could score using this set of mar...
gsc_MarkerBlocks gsc_load_blocks(const gsc_SimData *d, const char *block_file)
Given a file containing definitions of blocks of markers, process that file and return a struct conta...
double gsc_calculate_optimal_bv(const gsc_SimData *d, const gsc_EffectID effID)
Calculate the highest possible breeding value any (diploid) genotype could score using this set of ma...
unsigned int gsc_get_group_genes(const gsc_SimData *d, const gsc_GroupNum group_id, unsigned int group_size, char **output)
Gets a shallow copy of the genes/alleles of each member of the group.
unsigned int gsc_get_group_parent_ids(const gsc_SimData *d, const gsc_GroupNum group_id, unsigned int group_size, const int whichParent, gsc_PedigreeID *output)
Gets the ids of either the first or second parent of each member of the group.
unsigned int gsc_get_group_parent_names(const gsc_SimData *d, const gsc_GroupNum group_id, unsigned int group_size, const int whichParent, char **output)
Gets the names of either the first or second parent of each member of the group.
unsigned int gsc_get_group_pedigrees(const gsc_SimData *d, const gsc_GroupNum group_id, unsigned int group_size, char **output)
Gets the full pedigree string (as per gsc_save_group_full_pedigree() ) of each member of the group.
unsigned int gsc_get_group_names(const gsc_SimData *d, const gsc_GroupNum group_id, unsigned int group_size, char **output)
Gets a shallow copy of the names of each member of the group.
unsigned int gsc_get_group_indexes(const gsc_SimData *d, const gsc_GroupNum group_id, unsigned int group_size, unsigned int *output)
Gets the 0-based global indexes of each member of the group.
unsigned int gsc_get_group_ids(const gsc_SimData *d, const gsc_GroupNum group_id, unsigned int group_size, gsc_PedigreeID *output)
Gets the ids of each member of the group.
unsigned int gsc_get_group_bvs(const gsc_SimData *d, const gsc_GroupNum group_id, const gsc_EffectID effID, unsigned int group_size, double *output)
Gets the breeding values/breeding values/fitnesses of each member of the group.
size_t gsc_get_existing_group_counts(gsc_SimData *d, gsc_GroupNum *out_groups, unsigned int *out_sizes)
Identify group numbers that currently have members, and how many members they have.
size_t gsc_get_existing_groups(gsc_SimData *d, gsc_GroupNum *output)
Identify group numbers that currently have members.
unsigned int gsc_get_group_size(const gsc_SimData *d, const gsc_GroupNum group_id)
Function to count the number of genotypes that currently belong to the specified group.
gsc_GroupNum gsc_make_double_crosses_from_file(gsc_SimData *d, const char *input_file, const gsc_MapID map1, const gsc_MapID map2, const gsc_GenOptions g)
Perform crosses between previously-generated offspring of pairs of parents identified by name in a fi...
gsc_GroupNum gsc_make_random_crosses(gsc_SimData *d, const gsc_GroupNum from_group, const unsigned int n_crosses, const unsigned int cap, const gsc_MapID which_map, const gsc_GenOptions g)
Performs random crosses among members of a group.
gsc_GroupNum gsc_make_crosses_from_file(gsc_SimData *d, const char *input_file, const gsc_MapID map1, const gsc_MapID map2, const gsc_GenOptions g)
Perform crosses between pairs of parents identified by name in a file and allocate the resulting offs...
gsc_GroupNum gsc_make_doubled_haploids(gsc_SimData *d, const gsc_GroupNum group, const gsc_MapID which_map, const gsc_GenOptions g)
Creates a doubled haploid from each member of a group.
gsc_GroupNum gsc_make_clones(gsc_SimData *d, const gsc_GroupNum group, const _Bool inherit_names, const gsc_GenOptions g)
Creates an identical copy of each member of a group.
gsc_GroupNum gsc_make_random_crosses_between(gsc_SimData *d, const gsc_GroupNum group1, const gsc_GroupNum group2, const unsigned int n_crosses, const unsigned int cap1, const unsigned int cap2, const gsc_MapID map1, const gsc_MapID map2, const gsc_GenOptions g)
Performs random crosses where the first parent comes from one group and the second from another.
gsc_GroupNum gsc_scaffold_make_new_genotypes(gsc_SimData *d, const gsc_GenOptions g, void *parentIterator, union gsc_datastore_make_genotypes *datastore, int(*parentChooser)(void *, union gsc_datastore_make_genotypes *, unsigned int *, gsc_ParentChoice[static 2]), void(*offspringGenerator)(gsc_SimData *, union gsc_datastore_make_genotypes *, gsc_ParentChoice[static 2], gsc_GenoLocation))
Make new genotypes (generic function)
gsc_GroupNum gsc_make_all_unidirectional_crosses(gsc_SimData *d, const gsc_GroupNum from_group, const gsc_MapID mapID, const gsc_GenOptions g)
Perform crosses between all pairs of parents in the group from_group and allocates the resulting offs...
gsc_GroupNum gsc_self_n_times(gsc_SimData *d, const unsigned int n, const gsc_GroupNum group, const gsc_MapID which_map, const gsc_GenOptions g)
Selfs each member of a group for a certain number of generations.
gsc_GroupNum gsc_make_targeted_crosses(gsc_SimData *d, const size_t n_combinations, const unsigned int *firstParents, const unsigned int *secondParents, const gsc_MapID map1, const gsc_MapID map2, const gsc_GenOptions g)
Performs the crosses of pairs of parents whose indexes are provided in an array.
void gsc_delete_label(gsc_SimData *d, const gsc_LabelID whichLabel)
Clears memory of this label from the simulation and all its genotypes.
void gsc_delete_simdata(gsc_SimData *m)
Deletes a gsc_SimData object and frees its memory.
void gsc_delete_eff_set(gsc_SimData *d, gsc_EffectID whichID)
Deletes a particular set of marker effects from memory.
void gsc_delete_effects_table(gsc_MarkerEffects *m)
Deletes an gsc_MarkerEffects object and frees its memory.
void gsc_delete_randomaccess_iter(gsc_RandomAccessIterator *it)
Deletes a gsc_RandomAccessIterator object and frees its memory.
void gsc_delete_recombination_map(gsc_SimData *d, const gsc_MapID whichMap)
Deletes a particular recombination map from memory.
void gsc_delete_bidirectional_iter(gsc_BidirectionalIterator *it)
Deletes a gsc_BidirectionalIterator object.
void gsc_delete_markerblocks(gsc_MarkerBlocks *b)
Delete a gsc_MarkerBlocks struct.
void gsc_delete_dmatrix(gsc_DecimalMatrix *m)
Deletes a gsc_DecimalMatrix and frees its memory.
void gsc_delete_allele_matrix(gsc_AlleleMatrix *m)
Delete the gsc_AlleleMatrix linked list from m onwards and frees its memory.
void gsc_delete_recombination_map_nointegrity(gsc_RecombinationMap *m)
Deletes and clears the memory of a gsc_RecombinationMap struct.
void gsc_delete_group(gsc_SimData *d, const gsc_GroupNum group_id)
Deletes all genotypes belonging to a particular group.
void gsc_move_genotype(gsc_GenoLocation from, gsc_GenoLocation to, int *label_defaults)
Move all details of the genotype at one gsc_GenoLocation to another gsc_GenoLocation.
void gsc_delete_genome(gsc_KnownGenome *g)
Deletes and clears the memory of a gsc_KnownGenome object and its children.
size_t gsc_split_into_buckets(gsc_SimData *d, const gsc_GroupNum group_id, const size_t n, const unsigned int *counts, gsc_GroupNum *results)
Split a group into n groups of equal size (or size differing only by one, if n does not perfectly div...
size_t gsc_split_by_probabilities(gsc_SimData *d, const gsc_GroupNum group_id, const size_t n, const double *probs, gsc_GroupNum *results)
Allocate each member of the group to one of n groups with custom probabilities for each group.
size_t gsc_scaffold_split_by_somequality(gsc_SimData *d, const gsc_GroupNum group_id, void *somequality_data, gsc_GroupNum(*somequality_tester)(gsc_GenoLocation, void *, size_t, size_t, gsc_GroupNum *), size_t maxentries_results, gsc_GroupNum *results)
Split by some quality (generic function)
gsc_GroupNum gsc_split_evenly_into_two(gsc_SimData *d, const gsc_GroupNum group_id)
Split a group into two groups of equal size (or size differing only by one, if the original group had...
gsc_GroupNum gsc_split_by_label_range(gsc_SimData *d, const gsc_GroupNum group, const gsc_LabelID whichLabel, const int valueLowBound, const int valueHighBound)
Allocates the genotypes with values of a label in a particular range to a new group.
size_t gsc_split_into_individuals(gsc_SimData *d, const gsc_GroupNum group_id, size_t maxentries_results, gsc_GroupNum *results)
Split a group into n one-member groups.
size_t gsc_split_into_halfsib_families(gsc_SimData *d, const gsc_GroupNum group_id, const int parent, size_t maxentries_results, gsc_GroupNum *results)
Split a group into families of half-siblings by shared first or second parent.
size_t gsc_split_evenly_into_n(gsc_SimData *d, const gsc_GroupNum group_id, const size_t n, gsc_GroupNum *results)
Split a group into n groups of equal size (or size differing only by one, if n does not perfectly div...
size_t gsc_scaffold_split_by_someallocation(gsc_SimData *d, const gsc_GroupNum group_id, void *someallocator_data, gsc_GroupNum(*someallocator)(gsc_GenoLocation, gsc_SimData *, void *, size_t, size_t *, gsc_GroupNum *), size_t n_outgroups, gsc_GroupNum *outgroups)
Split by some allocator (generic function)
gsc_GroupNum gsc_combine_groups(gsc_SimData *d, const size_t list_len, const gsc_GroupNum *grouplist)
Combine a set of groups into one group.
gsc_GroupNum gsc_split_by_label_value(gsc_SimData *d, const gsc_GroupNum group, const gsc_LabelID whichLabel, const int valueToSplit)
Allocates the genotypes with a particular value of a label to a new group.
gsc_GroupNum gsc_split_randomly_into_two(gsc_SimData *d, const gsc_GroupNum group_id)
Flip a coin for each member of the group to decide if it should be moved to the new group.
gsc_GroupNum gsc_make_group_from(gsc_SimData *d, const size_t index_list_len, const unsigned int *genotype_indexes)
Take a list of indexes and allocate the genotypes at those indexes to a new group.
size_t gsc_split_randomly_into_n(gsc_SimData *d, const gsc_GroupNum group_id, const size_t n, gsc_GroupNum *results)
Allocate each member of the group to one of n groups with equal probability.
size_t gsc_split_into_families(gsc_SimData *d, const gsc_GroupNum group_id, size_t maxentries_results, gsc_GroupNum *results)
Split a group into families by their pedigrees.
gsc_BidirectionalIterator gsc_create_bidirectional_iter(gsc_SimData *d, const gsc_GroupNum group)
Create a bidirectional iterator.
gsc_AlleleMatrix * gsc_get_nth_AlleleMatrix(gsc_AlleleMatrix *listStart, const unsigned int n)
Get an gsc_AlleleMatrix by index in the linked list.
gsc_BidirectionalIterator gsc_create_bidirectional_iter_fromAM(gsc_AlleleMatrix *am, const gsc_GroupNum group)
gsc_GenoLocation gsc_next_forwards(gsc_BidirectionalIterator *it)
Get the next location from a bidirectional iterator.
static int gsc_isValidLocation(const gsc_GenoLocation g)
Identify whether a gsc_GenoLocation is INVALID_GENO_LOCATION.
gsc_GenoLocation gsc_set_bidirectional_iter_to_end(gsc_BidirectionalIterator *it)
Initialise a Bidirectional iterator to the end of its sequence.
gsc_RandomAccessIterator gsc_create_randomaccess_iter(gsc_SimData *d, const gsc_GroupNum group)
Create a Random Access Iterator.
gsc_GenoLocation gsc_set_bidirectional_iter_to_start(gsc_BidirectionalIterator *it)
Initialise a Bidirectional iterator to the start of its sequence.
gsc_GenoLocation gsc_next_backwards(gsc_BidirectionalIterator *it)
Get the previous location from a bidirectional iterator.
gsc_GenoLocation gsc_next_get_nth(gsc_RandomAccessIterator *it, const unsigned int n)
Get a location by index using a gsc_RandomAccessIterator.
static gsc_PedigreeID gsc_get_id(const gsc_GenoLocation loc)
Get the persistent id of a genotype.
static char * gsc_get_name(const gsc_GenoLocation loc)
Get the name of a genotype.
static int gsc_get_label_value(const gsc_GenoLocation loc, const int labelIndex)
Get the value of a specific label of a genotype.
static char * gsc_get_alleles(const gsc_GenoLocation loc)
Get the alleles of a genotype.
static void gsc_set_group(const gsc_GenoLocation loc, const gsc_GroupNum group)
Set the current group membership of a genotype.
static gsc_PedigreeID gsc_get_first_parent(const gsc_GenoLocation loc)
Get the first/left parent of a genotype.
static gsc_PedigreeID gsc_get_second_parent(const gsc_GenoLocation loc)
Get the second/right parent of a genotype.
static void gsc_set_name(const gsc_GenoLocation loc, char *name)
Set the name of a genotype.
static gsc_GroupNum gsc_get_group(const gsc_GenoLocation loc)
Get the current group membership of a genotype.
gsc_AlleleMatrix * gsc_create_empty_allelematrix(const unsigned int n_markers, const unsigned int n_labels, const int *labelDefaults, const unsigned int n_genotypes)
Creator for an empty gsc_AlleleMatrix object of a given size.
gsc_EffectID gsc_load_effectfile(gsc_SimData *d, const char *filename)
Populates a gsc_SimData combination with effect values.
struct gsc_MultiIDSet gsc_load_data_files(gsc_SimData *d, const char *data_file, const char *map_file, const char *effect_file, const gsc_FileFormatSpec format)
Populates a gsc_SimData object with marker allele data, a genetic map, and (optionally) marker effect...
gsc_GroupNum gsc_load_genotypefile(gsc_SimData *d, const char *filename, const gsc_FileFormatSpec format)
Load a set of genotypes to a gsc_SimData object.
gsc_MapID gsc_create_uniformspaced_recombmap(gsc_SimData *d, unsigned int n_markers, char **markernames, double expected_n_recombinations)
Create a uniformly-spaced gsc_RecombinationMap from a list of marker names and save to SimData.
void gsc_clear_simdata(gsc_SimData *d)
Clear a gsc_SimData object on the heap.
gsc_MapID gsc_create_unlinked_recombmap(gsc_SimData *d, unsigned int n_markers, char **markernames)
Create a gsc_RecombinationMap with independent assortment of alleles across a list of marker names,...
gsc_SimData * gsc_create_empty_simdata(unsigned int RNGseed)
Creator for an empty gsc_SimData object on the heap.
gsc_MapID gsc_load_mapfile(gsc_SimData *d, const char *filename)
Load a genetic map to a gsc_SimData object.
gsc_MapID gsc_create_recombmap_from_markerlist(gsc_SimData *d, unsigned int n_markers, struct gsc_MapfileUnit *markerlist)
Parse a list of markers/chrs/positions into a gsc_RecombinationMap and save to SimData.
int gsc_add_matrixvector_product_to_dmatrix(gsc_DecimalMatrix *result, const gsc_DecimalMatrix *a, const double *b)
int gsc_randpoi(rnd_pcg_t *rng, double lambda)
Generates randomly a number from the Poisson distribution with parameter lambda, using the Knuth appr...
gsc_DecimalMatrix gsc_generate_zero_dmatrix(const size_t r, const size_t c)
Generates a matrix of c columns, r rows with all 0.
int gsc_add_doublematrixvector_product_to_dmatrix(gsc_DecimalMatrix *result, const gsc_DecimalMatrix *amat, const double *avec, const gsc_DecimalMatrix *bmat, const double *bvec)
void gsc_generate_clone(gsc_SimData *d, const char *parent_genome, char *output)
Get an identical copy of a given genotype.
void gsc_generate_doubled_haploid(gsc_SimData *d, const char *parent_genome, char *output, const unsigned int mapindex)
Get the alleles of the outcome of producing a doubled haploid from a gamete from a given parent.
void gsc_generate_gamete(gsc_SimData *d, const char *parent_genome, char *output, const unsigned int mapindex)
Fills a char* with the simulated result of meiosis (reduction and recombination) from the marker alle...
static int gsc_has_same_alleles_window(const char *g1, const char *g2, const size_t start, const size_t w)
Simple operator to determine if at markers with indexes i to i+w inclusive, two genotypes share at le...
int gsc_calculate_recombinations_from_file(gsc_SimData *d, const char *input_file, const char *output_file, int window_len, int certain)
Provides guesses as to the location of recombination events that led to the creation of certain genot...
int * gsc_calculate_min_recombinations_fw1(gsc_SimData *d, gsc_MapID mapid, char *parent1, unsigned int p1num, char *parent2, unsigned int p2num, char *offspring, int certain)
Identify markers in the genotype of offspring where recombination from its parents occured.
static int gsc_has_same_alleles(const char *p1, const char *p2, const size_t i)
Simple operator to determine if at marker i, two genotypes share at least one allele.
int * gsc_calculate_min_recombinations_fwn(gsc_SimData *d, gsc_MapID mapid, char *parent1, unsigned int p1num, char *parent2, unsigned int p2num, char *offspring, int window_size, int certain)
Identify markers in the genotype of offspring where recombination from its parents occured,...
void gsc_save_utility_markerblocks(FILE *f, const gsc_MarkerBlocks b, const unsigned int n_markers, char **const marker_names, const gsc_RecombinationMap *map)
Prints the markers contained in a set of blocks to a file.
void gsc_save_utility_dmatrix(FILE *f, gsc_DecimalMatrix *dec, char **row_headers, char **col_headers, _Bool dim1_is_columns)
Output the contents of a matrix to a file.
void gsc_save_utility_allele_counts(FILE *f, gsc_BidirectionalIterator *targets, unsigned int n_markers, char **const marker_names, const _Bool markers_as_rows, const char allele)
Prints allele counts of simulated genotypes to a file.
void gsc_save_utility_pedigrees(FILE *f, gsc_BidirectionalIterator *targets, const _Bool full_pedigree, const gsc_AlleleMatrix *parent_pedigree_store)
Prints pedigrees to a file.
void gsc_save_markerblocks(const char *fname, const gsc_SimData *d, const gsc_MarkerBlocks b, const gsc_MapID labelMapID)
Prints the markers contained in a set of blocks to a file.
void gsc_save_bvs(const char *fname, const gsc_SimData *d, const gsc_GroupNum groupID, const gsc_EffectID effID)
Prints breeding values of genotypes in the simulation to a file.
void gsc_save_local_bvs(const char *fname, const gsc_SimData *d, const gsc_GroupNum groupID, const gsc_MarkerBlocks b, const gsc_EffectID effID, const _Bool headers)
Prints local breeding values of candidates to a file.
void gsc_save_allele_counts(const char *fname, const gsc_SimData *d, const gsc_GroupNum groupID, const char allele, const _Bool markers_as_rows)
Prints allele counts of genotypes from the simulation to a file.
void gsc_save_genotypes(const char *fname, const gsc_SimData *d, const gsc_GroupNum groupID, const _Bool markers_as_rows)
Prints genotypes from the simulation to a file.
void gsc_save_utility_bvs(FILE *f, gsc_BidirectionalIterator *targets, const gsc_MarkerEffects *eff)
Calculate and print breeding values to a file.
void gsc_save_utility_genotypes(FILE *f, gsc_BidirectionalIterator *targets, const unsigned int n_markers, char **const marker_names, const _Bool markers_as_rows)
Prints simulated genotypes to a file.
void gsc_save_pedigrees(const char *fname, const gsc_SimData *d, const gsc_GroupNum groupID, const _Bool full_pedigree)
Prints pedigrees of genotypes in the simulation to a file.
char * gsc_get_genes_of_index(const gsc_AlleleMatrix *start, const unsigned int index)
Get the alleles of a genotype by its index.
char * gsc_get_name_of_id(const gsc_AlleleMatrix *start, const gsc_PedigreeID id)
Returns the name of the genotype with a given id.
void gsc_get_ids_of_names(const gsc_AlleleMatrix *start, const size_t n_names, const char **names, gsc_PedigreeID *output)
Search for genotypes with certain names in a linked list of gsc_AlleleMatrix and save the ids of thos...
unsigned int gsc_get_index_of_child(const gsc_AlleleMatrix *start, const gsc_PedigreeID parent1id, const gsc_PedigreeID parent2id)
Search for a genotype with parentage matching two given parent ids in a linked list of gsc_AlleleMatr...
unsigned int gsc_get_index_of_name(const gsc_AlleleMatrix *start, const char *name)
Search for a genotype with a particular name in a linked list of gsc_AlleleMatrix,...
gsc_PedigreeID gsc_get_id_of_index(const gsc_AlleleMatrix *start, const unsigned int index)
Get the id of a genotype by its index.
int gsc_get_parents_of_id(const gsc_AlleleMatrix *start, const gsc_PedigreeID id, gsc_PedigreeID output[static 2])
Saves the ids of the parents of a genotype with a particular id to the output array output.
#define INVALID_GENO_LOCATION
gsc_GenotypeFileCellStyle
Represent possible representations of alleles at a marker in a genotype file.
gsc_TableFileReader gsc_tablefilereader_create(const char *filename)
Open a file for reading with gsc_TableFileReader.
void gsc_tablefilecell_deep_copy(gsc_TableFileCell *c)
Allocate memory to store a deep copy of a gsc_TableFileCell, if previously only a shallow copy.
void gsc_tablefilereader_close(gsc_TableFileReader *tbl)
Close a gsc_TableFileReader's file pointer.
enum gsc_TableFileCurrentStatus gsc_helper_tablefilereader_classify_char(gsc_TableFileReader *tbl)
Classify the character under the cursor of a TableFileReader as cell contents or otherwise.
gsc_TableFileCell gsc_tablefilereader_get_next_cell(gsc_TableFileReader *tbl)
Read forwards in TableFileReader and return the next cell's contents, as well as how many column gaps...
gsc_TableFileCurrentStatus
Represent possible states of the cursor of a gsc_TableFileReader.
const gsc_GenOptions GSC_BASIC_OPT
Default parameter values for GenOptions, to help with quick scripts and prototypes.
gsc_FileFormatSpec gsc_define_matrix_format_details(const GSC_LOGICVAL has_header, const GSC_LOGICVAL markers_as_rows, const enum gsc_GenotypeFileCellStyle cell_style)
Give genomicSimulation hints on the format of a genotype matrix file to be loaded.
void gsc_helper_tablefilereader_refill_buffer(gsc_TableFileReader *tbl)
Read another buffer's worth of characters from a gsc_TableFileReader's file.
gsc_GenotypeFileType
Enumerate types of genotype files that the simulation knows how to load.
@ GSC_GENOTYPECELLSTYLE_SLASHPAIR
@ GSC_GENOTYPECELLSTYLE_PAIR
@ GSC_GENOTYPECELLSTYLE_UNKNOWN
@ GSC_GENOTYPECELLSTYLE_ENCODED
@ GSC_GENOTYPECELLSTYLE_COUNT
@ GSC_TABLEFILE_ERROR_EOF
@ GSC_TABLEFILE_ERROR_EOBUF
@ GSC_TABLEFILE_COLUMNGAP
@ GSC_GENOTYPEFILE_MATRIX
Either a marker-by-line matrix, where each marker is a row, or a line-by-marker matrix,...
@ GSC_GENOTYPEFILE_UNKNOWN
gsc_GroupNum gsc_get_next_free_group_num(const size_t n_existing_groups, const gsc_GroupNum *existing_groups, size_t *cursor, gsc_GroupNum previous)
Iterator to get the next currently-free group number.
unsigned int gsc_get_from_ordered_pedigree_list(const gsc_PedigreeID target, const unsigned int listLen, const gsc_PedigreeID *list)
Binary search through list of unsigned integers.
gsc_GroupNum gsc_get_new_group_num(gsc_SimData *d)
Function to identify the next sequential integer that does not identify a group that currently has me...
void gsc_change_label_to(gsc_SimData *d, const gsc_GroupNum whichGroup, const gsc_LabelID whichLabel, const int setTo)
Set the values of a custom label.
struct gsc_TableSize gsc_get_file_dimensions(const char *filename, const char sep)
Opens a table file and reads the number of columns and rows (including headers) separated by sep into...
int gsc_get_integer_digits(const int i)
Count and return the number of digits in i.
unsigned int gsc_get_index_of_map(const gsc_SimData *d, const gsc_MapID map)
Function to identify the lookup index of a recombination map identifier.
unsigned int gsc_get_index_of_label(const gsc_SimData *d, const gsc_LabelID label)
Function to identify the label lookup index of a label identifier.
gsc_MapID gsc_get_new_map_id(const gsc_SimData *d)
Function to identify the next sequential integer that is not already allocated to a map ID in the sim...
void gsc_shuffle_up_to(rnd_pcg_t *rng, void *sequence, const size_t item_size, const size_t total_n, const size_t n_to_shuffle)
Produce a random ordering of the first n elements in an array using a (partial) Fisher-Yates shuffle.
void gsc_change_label_default(gsc_SimData *d, const gsc_LabelID whichLabel, const int newDefault)
Set the default value of a custom label.
size_t gsc_get_from_ordered_str_list(const char *target, const size_t listLen, const char **list)
Binary search through a list of strings.
unsigned int gsc_change_eff_set_centre_of_allele_count(gsc_SimData *d, const gsc_EffectID effset, const unsigned int n_markers, const char **marker_names, const double *centres, const char allele, const _Bool reset_centres)
Replace the centring values of specific markers in an effect set.
_Bool gsc_change_eff_set_centres_to_values(gsc_SimData *d, const gsc_EffectID effset, const unsigned int n_values, const double *values)
Replace the centring values of all markers in an effect set.
size_t gsc_get_from_unordered_str_list(const char *target, const size_t listLen, const char **list)
Linear search through a list of strings.
unsigned int gsc_change_eff_set_centre_of_markers(gsc_SimData *d, const gsc_EffectID effset, const unsigned int n_markers, const char **marker_names, const double *centres)
Replace the centring values of specific markers in an effect set.
gsc_EffectID gsc_get_new_eff_set_id(const gsc_SimData *d)
Function to identify the next sequential integer that is not already allocated to a marker effect set...
void gsc_get_n_new_group_nums(gsc_SimData *d, const size_t n, gsc_GroupNum *result)
Function to identify the next n sequential integers that do not identify a group that currently has m...
void gsc_change_label_to_values(gsc_SimData *d, const gsc_GroupNum whichGroup, const unsigned int startIndex, const gsc_LabelID whichLabel, const size_t n_values, const int *values)
Copy a vector of integers into a custom label.
gsc_LabelID gsc_get_new_label_id(const gsc_SimData *d)
Function to identify the next sequential integer that is not already allocated to a label in the simu...
unsigned int gsc_get_index_of_eff_set(const gsc_SimData *d, const gsc_EffectID eff_set_id)
Function to identify the lookup index of a marker effect set identifier.
gsc_LabelID gsc_create_new_label(gsc_SimData *d, const int setTo)
Initialises a new custom label.
void gsc_change_names_to_values(gsc_SimData *d, const gsc_GroupNum whichGroup, const unsigned int startIndex, const size_t n_values, const char **values)
Copy a vector of strings into the genotype name field.
_Bool gsc_get_index_of_genetic_marker(const char *target, gsc_KnownGenome g, unsigned int *out)
Return whether or not a marker name is present in the tracked markers, and at what index.
void gsc_change_allele_symbol(gsc_SimData *d, const char *which_marker, const char from, const char to)
Replace all occurences of a given allele with a different symbol representation.
void gsc_change_label_by_amount(gsc_SimData *d, const gsc_GroupNum whichGroup, const gsc_LabelID whichLabel, const int byValue)
Increment the values of a custom label.
void gsc_condense_allele_matrix(gsc_SimData *d)
A function to tidy the internal storage of genotypes after addition or deletion of genotypes in the g...
unsigned int gsc_randomdraw_replacementrules(gsc_SimData *d, unsigned int max, unsigned int cap, unsigned int *member_uses, unsigned int noCollision)
Randomly pick a number in a range, optionally with a cap on how many times a number can be picked,...
#define GSC_ID_T
genomicSimulation's "ID" type
#define GSC_GLOBALX_T
genomicSimulation's "Candidate global index" type
#define GSC_GENOLEN_T
genomicSimulation's "Genotype length" type
GSC_LOGICVAL
genomicSimulation's "logical value" type
#define GSC_LOCALX_T
genomicSimulation's "Candidate local index" type
char * names[1000]
Array of dynamically allocated strings containing the names of the lines/genotypes in this matrix.
unsigned int n_genotypes
Number of genotypes currently loaded in this matrix.
unsigned int n_markers
Number of markers across which genotypes are tracked.
char * alleles[1000]
A matrix of SNP markers by lines/genotypes containing pairs of alleles eg TT, TA.
unsigned int n_labels
Number of custom labels currently available to this gsc_AlleleMatrix.
gsc_AlleleMatrix * next
Pointer to the next gsc_AlleleMatrix in the linked list, or NULL if this entry is the last.
int ** labels
Pointer to list of labels.
gsc_PedigreeID ids[1000]
Unique ID for each genotype.
gsc_GroupNum groups[1000]
Group allocation of each genotype.
gsc_PedigreeID pedigrees[2][1000]
Two lists of integer IDs of the parents of this genotype (if tracked), or 0 if we don't know/care.
A structure to iterate forwards and backwards through all genotypes in a gsc_SimData or through only ...
_Bool atEnd
Boolean that is TRUE if the iterator's 'cursor' is on the last genotype (genotype with the highest in...
unsigned int cachedAMIndex
Index of cachedAM in the linked list of gsc_AlleleMatrix beginning at d->m.
const gsc_GroupNum group
Group through which to iterate.
gsc_AlleleMatrix * cachedAM
Pointer to the gsc_AlleleMatrix from the linked list of gsc_AlleleMatrix beginning at d->m where the ...
_Bool atStart
Boolean that is TRUE if the iterator's 'cursor' is on the first genotype (genotype with the lowest in...
unsigned int localPos
Local index (index within the cachedAM) of the genotype in the linked list of gsc_AlleleMatrix beginn...
gsc_AlleleMatrix * am
Simulation genotypes through which to iterate.
A row-major heap matrix that contains floating point numbers.
size_t dim1
Number of rows in the matrix.
double ** matrix
The actual matrix and contents.
size_t dim2
number of columns in the matrix
A type representing a particular loaded set of marker effects.
Unprocessed data for one marker effect loaded from an effect file.
A structure to hold an initially empty AlleleMatrix list whose genotypes can be accessed sequentially...
gsc_GroupNum alloctogroup
gsc_AlleleMatrix * firstAM
gsc_AlleleMatrix * localAM
A structure to iterate forwards through all positions in the gsc_AlleleMatrix linked list in gsc_SimD...
unsigned int cursorAMIndex
A type that contains choices of settings for gsc_SimData functions that create a new gsc_AlleleMatrix...
_Bool will_allocate_ids
A boolean: whether to allocate generated offspring session- unique IDs.
_Bool will_track_pedigree
A boolean: whether to track parentage of generated offspring.
_Bool will_name_offspring
A boolean: whether generated offspring should be given names.
const char * filename_prefix
A string used in save-as-you-go file names.
const char * offspring_name_prefix
If will_name_offspring is true, generated offspring are named with the concatenation {offspring_name_...
gsc_EffectID will_save_bvs_to_file
If equal to NO_EFFECTSET, no bvs are calculated or saved.
_Bool will_save_pedigree_to_file
A boolean.
unsigned int family_size
The number of offspring to produce from each cross.
_Bool will_save_to_simdata
A boolean.
_Bool will_save_alleles_to_file
A boolean.
An gsc_AlleleMatrix/gsc_AlleleMatrix index coordinate of a particular genotype in the simulation.
gsc_AlleleMatrix * localAM
Pointer to the gsc_AlleleMatrix in which the genotype can be found.
unsigned int localPos
Index in the localAM where the genotype can be found (min value: 0.
A type representing the identifier of a group of genotypes.
A type that stores the genome structure used in simulation.
char ** marker_names
A vector of n_markers strings containing the names of markers, ordered according to their index in an...
gsc_RecombinationMap * maps
A vector of n_maps recombination maps, to use for simulating meiosis.
char *** names_alphabetical
A vector of n_markers pointers to names in marker_names, ordered in alphabetical order of the names.
unsigned int n_markers
The total number of markers.
unsigned int n_maps
The number of recombination maps currently stored.
gsc_MapID * map_ids
A vector of n_maps identifiers for each of the recombination maps currently stored.
A type representing a particular custom label.
A generic store for a linkage group, used to simulate meiosis on a certain subset of markers.
gsc_ReorderedLinkageGroup reorder
@ GSC_LINKAGEGROUP_SIMPLE
gsc_SimpleLinkageGroup simple
A type representing a particular loaded recombination map.
Unprocessed data for one marker (linkage group and position) loaded from a map file.
A struct used to store a set of blocks of markers.
unsigned int num_blocks
The number of blocks whose details are stored here.
unsigned int * num_markers_in_block
Pointer to a heap array of length num_blocks containing the number of markers that make up each block...
unsigned int ** markers_in_block
Pointer to a heap array of length num_blocks, each entry in which is a pointer to a heap array with l...
A type that stores the information needed to calculate breeding values from alleles at markers.
unsigned int * cumn_alleles
A vector of length n_markers holding the cumulative number of alleles that have effects on breeding v...
double * eff
A vector holding the effect on breeding value of each allele at each marker.
unsigned int n_markers
Number of markers across which genotypes are tracked.
double * centre
Vector of length n_markers, containing a value for each marker which represents the value to subtract...
char * allele
A vector holding the symbol/character representing each allele at each marker.
Simple crate that stores a GroupNum, a MapID, and an EffectID.
gsc_GenoLocation loc
Location in the simulation where this parent is stored.
unsigned int mapindex
Index in d->genome.maps of the recombination map to use when producing gametes from this parent.
A type representing a program-lifetime-unique identifier for a genotype, to be used in tracking pedig...
A structure to search and cache indexes of all genotypes in a gsc_SimData or of all the members of a ...
unsigned int cacheSize
Length in gsc_GenoLocations of cache
const gsc_GroupNum group
Group through which to iterate.
unsigned int largestCached
Local/group index (that is, index in cache) of the highest cell in cache that has been filled.
gsc_SimData * d
Simulation data through which to iterate.
unsigned int groupSize
If the number of genotypes in the simulation that fulfil the iterator's group criteria is known,...
gsc_GenoLocation * cache
Array iteratively updated with the known genotypes in the simulation that fulfil the group criteria o...
A type that stores linkage groups and crossover probabilities for simulating meiosis.
size_t n_chr
The number of chromosomes/linkage groups represented in the map.
gsc_LinkageGroup * chrs
Vector of n_chr recombination maps, one for each chromosome/linkage group in this recombination map.
char ** chr_names
An identifying code for each chromosome/linkage group in the map.
Parameters for simulating meiosis on a linkage group whose markers are re-ordered compared to the fir...
unsigned int n_markers
The number of markers in this chromosome/linkage group.
double expected_n_crossovers
Expected value of the Poisson distribution from which the number of crossovers in this linkage group ...
unsigned int * marker_indexes
Array with n_markers entries.
double * dists
Array with n_markers entries, containing at position i the distance in centimorgans along the linkage...
Composite type that is used to run crossing simulations.
unsigned int n_labels
The number of custom labels in the simulation.
gsc_KnownGenome genome
A gsc_KnownGenome, which stores the information of known markers and linkage groups,...
gsc_LabelID * label_ids
The identifier number of each label in the simulation, in order of their lookup index.
gsc_EffectID * eff_set_ids
The identifier number of each set of allele effects in the simulation, ordered by their lookup index.
int * label_defaults
Array containing the default (birth) value of each custom label.
unsigned int n_groups
Number of groups currently existing in simulation.
unsigned int n_eff_sets
The number of sets of allele effects in the simulation.
gsc_PedigreeID current_id
Highest SimData-unique ID that has been generated so far.
rnd_pcg_t rng
Random number generator working memory.
gsc_AlleleMatrix * m
Pointer to an gsc_AlleleMatrix, which stores data and metadata of founders and simulated offspring.
gsc_MarkerEffects * e
Array of n_eff_sets gsc_MarkerEffects, optional for the use of the simulation.
Parameters for simulating meiosis on a linkage group whose markers are stored contiguously in the sim...
unsigned int first_marker_index
The index of the first marker in this chromosome/linkage group in the simulation's corresponding gsc_...
unsigned int n_markers
The number of markers in this chromosome/linkage group.
double * dists
Array with n_markers entries, containing at position i the distance in centimorgans along the linkage...
double expected_n_crossovers
Expected value of the Poisson distribution from which the number of crossovers in this linkage group ...
Represent a cell read by a gsc_TableFileReader.
int predCol
since last read, how many column gaps have there been?
char * cell
deep copy of the cell contents, or NULL
_Bool isCellShallow
is the string in 'cell' a shallow copy or deep copy?
int predNewline
since last read, how many newlines have there been?
_Bool eof
are we (this cell) at end of file
size_t cell_len
length of cell contents (because a shallow copy may not be null-terminated)
Stream reader for files of some tabular format.
int buf_fill
Number of characters from the file that are currently loaded in buf.
int cursor
Index in buf of the first character that the file reader has not yet parsed.
FILE * fp
File being read.