Skip to content

Commit c2da82f

Browse files
committed
output format cleanup and polish
1 parent 4906ad9 commit c2da82f

File tree

8 files changed

+26
-22
lines changed

8 files changed

+26
-22
lines changed

VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ development head (in the master branch):
130130
Species method outputFull(): allow multi-chromosome output with a new sectioned format, for both text and binary
131131
Species method readFromPopulationFile(): support reading multi-chromosome output, for both text and binary
132132
policy change: readFromPopulationFile() breaks backward compatibility with old file formats, for both text and binary; too much has changed
133+
change file format codes for class Haplosome from GS/GM/GV to HS/HM/HV, matching the rename from Genome to Haplosome
133134

134135

135136
version 4.3 (Eidos version 3.3):

core/haplosome.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,8 +1343,6 @@ void Haplosome::PrintHaplosomes_SLiM(std::ostream &p_out, std::vector<Haplosome
13431343
else
13441344
p_out << "p" << p_source_subpop_id << ":" << j;
13451345

1346-
p_out << " " << p_chromosome.Symbol(); // all haplosomes must be associated with p_chromosome
1347-
13481346
for (int run_index = 0; run_index < haplosome.mutrun_count_; ++run_index)
13491347
{
13501348
const MutationRun *mutrun = haplosome.mutruns_[run_index];
@@ -3069,7 +3067,8 @@ EidosValue_SP Haplosome_Class::ExecuteMethod_outputX(EidosGlobalStringID p_metho
30693067
// BCH 2/2/2025: added the cycle count here after the tick; it was already documented as being here!
30703068
// BCH 2/2/2025: added the chromosome symbol in the header; it is redundant for SLiM-format output,
30713069
// but useful for MS and VCF; I decided to put it in all three for consistency across formats
3072-
output_stream << "#OUT: " << community.Tick() << " " << species->Cycle() << " G";
3070+
// BCH 2/7/2025: changed GS/GM/GV to HS/HM/HV, for the genome -> haplosome transition
3071+
output_stream << "#OUT: " << community.Tick() << " " << species->Cycle() << " H";
30733072

30743073
if (p_method_id == gID_output)
30753074
output_stream << "S";
@@ -3081,7 +3080,10 @@ EidosValue_SP Haplosome_Class::ExecuteMethod_outputX(EidosGlobalStringID p_metho
30813080
output_stream << " " << sample_size;
30823081

30833082
if (chromosomes.size() > 1)
3084-
output_stream << " " << chromosome->Symbol(); // chromosome symbol, with >1 chromosome
3083+
{
3084+
output_stream << " " << chromosome->Type(); // chromosome type, with >1 chromosome
3085+
output_stream << " \"" << chromosome->Symbol() << "\""; // chromosome symbol, with >1 chromosome
3086+
}
30853087

30863088
output_stream << std::endl;
30873089

@@ -3111,10 +3113,14 @@ EidosValue_SP Haplosome_Class::ExecuteMethod_outputX(EidosGlobalStringID p_metho
31113113
// BCH 2/2/2025: added the cycle count here after the tick; it was already documented as being here!
31123114
// BCH 2/2/2025: added the chromosome symbol in the header; it is redundant for SLiM-format output,
31133115
// but useful for MS and VCF; I decided to put it in all three for consistency across formats
3114-
outfile << "#OUT: " << community.Tick() << " " << species->Cycle() << " GS " << sample_size;
3116+
// BCH 2/7/2025: changed GS/GM/GV to HS/HM/HV, for the genome -> haplosome transition
3117+
outfile << "#OUT: " << community.Tick() << " " << species->Cycle() << " HS " << sample_size;
31153118

31163119
if (chromosomes.size() > 1)
3117-
outfile << " " << chromosome->Symbol(); // chromosome symbol, with >1 chromosome
3120+
{
3121+
outfile << " " << chromosome->Type(); // chromosome type, with >1 chromosome
3122+
outfile << " \"" << chromosome->Symbol() << "\""; // chromosome symbol, with >1 chromosome
3123+
}
31183124

31193125
outfile << " " << outfile_path << std::endl;
31203126

core/polymorphism.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void Polymorphism::Print_NoID(std::ostream &p_out) const
7373
{
7474
Chromosome *chromosome = chromosomes[mutation_ptr_->chromosome_index_];
7575

76-
p_out << " " << chromosome->Symbol();
76+
p_out << " \"" << chromosome->Symbol() << "\"";
7777
}
7878

7979
// and then the remainder of the output line

core/population.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7666,9 +7666,9 @@ void Population::PrintAll(std::ostream &p_out, bool p_output_spatial_positions,
76667666
p_out << " " << individual.PedigreeID();
76677667

76687668
if (subpop->sex_enabled_)
7669-
p_out << ((i < first_male_index) ? " F " : " M "); // sex: SEX ONLY
7669+
p_out << ((i < first_male_index) ? " F" : " M"); // sex: SEX ONLY
76707670
else
7671-
p_out << " H "; // hermaphrodite
7671+
p_out << " H"; // hermaphrodite
76727672

76737673
// BCH 2/5/2025: Before version 8, we emitted haplosome identifiers here, like "p1:16" and
76747674
// "p1:17", but now that we have multiple chromosomes that really isn't helpful; removing
@@ -7727,7 +7727,7 @@ void Population::PrintAll(std::ostream &p_out, bool p_output_spatial_positions,
77277727
// write information about the chromosome; note that we write the chromosome symbol, but PrintAllBinary() does not
77287728
slim_chromosome_index_t chromosome_index = chromosome->Index();
77297729

7730-
p_out << "Chromosome: " << (uint32_t)chromosome_index << " " << chromosome->Type() << " " << chromosome->ID() << " " << chromosome->last_position_ << " " << chromosome->Symbol() << std::endl;
7730+
p_out << "Chromosome: " << (uint32_t)chromosome_index << " " << chromosome->Type() << " " << chromosome->ID() << " " << chromosome->last_position_ << " \"" << chromosome->Symbol() << "\"" << std::endl;
77317731

77327732
int first_haplosome_index = species_.FirstHaplosomeIndices()[chromosome_index];
77337733
int last_haplosome_index = species_.LastHaplosomeIndices()[chromosome_index];
@@ -7811,8 +7811,7 @@ void Population::PrintAll(std::ostream &p_out, bool p_output_spatial_positions,
78117811

78127812
// i used to be the haplosome index, now it is the individual index; we will have one or
78137813
// two lines with this individual index, depending on the intrinsic ploidy of the chromosome
7814-
// symbol is redundant but kinda nice for orientation
7815-
p_out << "p" << subpop_id << ":" << individual_index << " " << chromosome->Symbol();
7814+
p_out << "p" << subpop_id << ":" << individual_index;
78167815

78177816
if (haplosome->IsNull())
78187817
{

core/slim_globals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2428,7 +2428,7 @@ void WriteProfileResults(std::string profile_output_path, std::string model_name
24282428

24292429
for (Chromosome *focal_chromosome : chromosomes)
24302430
{
2431-
fout << "<p><i>Chromosome " << focal_chromosome->Symbol() << ":</i></p>\n";
2431+
fout << "<p><i>Chromosome \"" << focal_chromosome->Symbol() << "\":</i></p>\n";
24322432

24332433
{
24342434
int64_t power_tallies[20]; // we only go up to 1024 mutruns right now, but this gives us some headroom

core/species.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,8 +1123,9 @@ slim_tick_t Species::_InitializePopulationFromTextFile(const char *p_file, Eidos
11231123

11241124
// chromosome symbol
11251125
chrom_iss >> sub;
1126+
std::string quoted_symbol = '\"' + chromosome->Symbol() + '\"';
11261127

1127-
if (sub != chromosome->Symbol())
1128+
if (sub != quoted_symbol)
11281129
EIDOS_TERMINATION << "ERROR (Species::_InitializePopulationFromTextFile): chromosome symbol " << sub << " does not match expected symbol " << chromosome->Symbol() << "." << EidosTerminate();
11291130

11301131
GetInputLine(infile, line);
@@ -1287,12 +1288,6 @@ slim_tick_t Species::_InitializePopulationFromTextFile(const char *p_file, Eidos
12871288
int haplosome_index = first_haplosome_index + is_individual_index_repeat;
12881289
Haplosome &haplosome = *(ind->haplosomes_[haplosome_index]);
12891290

1290-
// Now we should have a chromosome symbol, which should match the one we read
1291-
iss >> sub;
1292-
1293-
if (sub != chromosome->Symbol())
1294-
EIDOS_TERMINATION << "ERROR (Species::_InitializePopulationFromTextFile): haplosome is specified with chromosome symbol '" << sub << "', in the Chromosome section for symbol '" << chromosome->Symbol() << "'." << EidosTerminate();
1295-
12961291
if (iss >> sub)
12971292
{
12981293
// BCH 2/5/2025: We instantiate null haplosomes only where expect them to be, based upon

core/subpopulation.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11153,7 +11153,10 @@ EidosValue_SP Subpopulation::ExecuteMethod_outputXSample(EidosGlobalStringID p_m
1115311153
out << " " << requested_sex;
1115411154

1115511155
if (chromosomes.size() > 1)
11156-
output_stream << " " << chromosome->Symbol(); // chromosome symbol, with >1 chromosome
11156+
{
11157+
output_stream << " " << chromosome->Type(); // chromosome type, with >1 chromosome
11158+
output_stream << " \"" << chromosome->Symbol() << "\""; // chromosome symbol, with >1 chromosome
11159+
}
1115711160

1115811161
if (has_file)
1115911162
out << " " << outfile_path;

core/substitution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void Substitution::PrintForSLiMOutput(std::ostream &p_out) const
6060
{
6161
Chromosome *chromosome = chromosomes[chromosome_index_];
6262

63-
p_out << " " << chromosome->Symbol();
63+
p_out << " \"" << chromosome->Symbol() << "\"";
6464
}
6565

6666
// and then the remainder of the output line

0 commit comments

Comments
 (0)