Skip to content

Commit 1b4f604

Browse files
committed
multichrom work for SLiM and VCF output, and readFromVCF()
1 parent 0c964c3 commit 1b4f604

File tree

11 files changed

+654
-326
lines changed

11 files changed

+654
-326
lines changed

QtSLiM/help/SLiMHelpClasses.html

Lines changed: 30 additions & 24 deletions
Large diffs are not rendered by default.

SLiMgui/SLiMHelpClasses.rtf

Lines changed: 167 additions & 69 deletions
Large diffs are not rendered by default.

VERSIONS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ development head (in the master branch):
118118
Haplosome method outputMS(): check that all haplosomes belong to a single chromosome, output MS based on that
119119
Subpopulation method outputMSSample(): add a [Niso<Chromosome>$ chromosome = NULL] parameter to identify the chromosome to sample with
120120
Haplosome method readFromMS(): check that all haplosomes belong to a single chromosome, input MS based on that
121+
fix built-in SLiM-format partial input/output methods for multiple chromosomes:
122+
Haplosome method output(): check that all haplosomes belong to a single chromosome; output the chromosome symbol in the header if multi-chrom
123+
Subpopulation method outputSample(): check that all haplosomes belong to a single chromosome
124+
fix built-in VCF input/output methods for multiple chromosomes:
125+
Haplosome method outputVCF(): check that all haplosomes belong to a single chromosome; pairs haplosomes as appropriate
126+
Subpopulation method outputVCFSample(): check that all haplosomes belong to a single chromosome; use chromosome symbols for the CHROM column
127+
add [l$ groupAsIndividuals = T] parameter; if F, each haplosome is emitted as a haploid call rather than forming diploids, regardless of the chromosome's ploidy
128+
Haplosome_Class::ExecuteMethod_readFromVCF(): require VCF data that is single-chromosome, as with output
121129

122130

123131
version 4.3 (Eidos version 3.3):

core/chromosome.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,53 @@ Chromosome::Chromosome(Species &p_species, ChromosomeType p_type, int64_t p_id,
9898
color_sub_ = "#3333FF";
9999
if (!color_sub_.empty())
100100
Eidos_GetColorComponents(color_sub_, &color_sub_red_, &color_sub_green_, &color_sub_blue_);
101+
102+
// depending on the type of chromosome, cache some properties for quick reference
103+
// FIXME MULTICHROM: add more properties here, like:
104+
//
105+
// DefaultsToZeroRecombination()
106+
// IsSexChromosome()
107+
// TypeString() ("A" for type kA_DiploidAutosome, etc.)
108+
// ...lots more, scan the code...
109+
switch (type_)
110+
{
111+
case ChromosomeType::kA_DiploidAutosome: // type "A"
112+
intrinsic_ploidy_ = 2;
113+
break;
114+
case ChromosomeType::kH_HaploidAutosome: // type "H"
115+
intrinsic_ploidy_ = 1;
116+
break;
117+
case ChromosomeType::kX_XSexChromosome: // type "X"
118+
intrinsic_ploidy_ = 2;
119+
break;
120+
case ChromosomeType::kY_YSexChromosome: // type "Y"
121+
intrinsic_ploidy_ = 1;
122+
break;
123+
case ChromosomeType::kZ_ZSexChromosome: // type "Z"
124+
intrinsic_ploidy_ = 2;
125+
break;
126+
case ChromosomeType::kW_WSexChromosome: // type "W"
127+
intrinsic_ploidy_ = 1;
128+
break;
129+
case ChromosomeType::kHF_HaploidFemaleInherited: // type "HF"
130+
intrinsic_ploidy_ = 1;
131+
break;
132+
case ChromosomeType::kFL_HaploidFemaleLine: // type "FL"
133+
intrinsic_ploidy_ = 1;
134+
break;
135+
case ChromosomeType::kHM_HaploidMaleInherited: // type "HM"
136+
intrinsic_ploidy_ = 1;
137+
break;
138+
case ChromosomeType::kML_HaploidMaleLine: // type "ML"
139+
intrinsic_ploidy_ = 1;
140+
break;
141+
case ChromosomeType::kHNull_HaploidAutosomeWithNull: // type "H-"
142+
intrinsic_ploidy_ = 2;
143+
break;
144+
case ChromosomeType::kNullY_YSexChromosomeWithNull: // type "-Y"
145+
intrinsic_ploidy_ = 2;
146+
break;
147+
}
101148
}
102149

103150
Chromosome::~Chromosome(void)

core/chromosome.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ class Chromosome : public EidosDictionaryRetained
6767
slim_chromosome_index_t index_;
6868
ChromosomeType type_;
6969

70+
// cached properties of the chromosome that depend upon its type
71+
int intrinsic_ploidy_; // 1 or 2; the number of haplosomes kept for the chromosome
72+
7073
// This vector contains all the genomic elements for this chromosome. It is in sorted order once initialization is complete.
7174
std::vector<GenomicElement *> genomic_elements_; // OWNED POINTERS: genomic elements belong to the chromosome
7275

@@ -289,15 +292,18 @@ class Chromosome : public EidosDictionaryRetained
289292
explicit Chromosome(Species &p_species, ChromosomeType p_type, int64_t p_id, std::string p_symbol, slim_chromosome_index_t p_index, int p_preferred_mutcount);
290293
~Chromosome(void);
291294

292-
inline __attribute__((always_inline)) int64_t ID(void) { return id_; }
293-
inline __attribute__((always_inline)) const std::string &Symbol(void) { return symbol_; }
294-
inline __attribute__((always_inline)) slim_chromosome_index_t Index(void) { return index_; }
295-
inline __attribute__((always_inline)) ChromosomeType Type(void) { return type_; }
296-
inline __attribute__((always_inline)) const std::string &Name(void) { return name_; }
295+
inline __attribute__((always_inline)) int64_t ID(void) const { return id_; }
296+
inline __attribute__((always_inline)) const std::string &Symbol(void) const { return symbol_; }
297+
inline __attribute__((always_inline)) slim_chromosome_index_t Index(void) const { return index_; }
298+
inline __attribute__((always_inline)) ChromosomeType Type(void) const { return type_; }
299+
inline __attribute__((always_inline)) const std::string &Name(void) const { return name_; }
297300
inline __attribute__((always_inline)) void SetName(const std::string &p_name) { name_ = p_name; }
298301

302+
inline __attribute__((always_inline)) int IntrinsicPloidy(void) const { return intrinsic_ploidy_; }
303+
299304
inline __attribute__((always_inline)) std::vector<GenomicElement *> &GenomicElements(void) { return genomic_elements_; }
300-
inline __attribute__((always_inline)) NucleotideArray *AncestralSequence(void) { return ancestral_seq_buffer_; }
305+
inline __attribute__((always_inline)) const std::vector<GenomicElement *> &GenomicElements(void) const { return genomic_elements_; }
306+
inline __attribute__((always_inline)) NucleotideArray *AncestralSequence(void) const { return ancestral_seq_buffer_; }
301307

302308
// initialize the random lookup tables used by Chromosome to draw mutation and recombination events
303309
void CreateNucleotideMutationRateMap(void);

0 commit comments

Comments
 (0)