Skip to content

Commit

Permalink
Pheno input doesn't need to be ordered
Browse files Browse the repository at this point in the history
Bad bug: was storing input index vector then sorting, so it went out of
order and gave the wrong result. Will have worked for ordered .pheno
inputs which were most of my test cases.

Tested, and now works with ordered and unordered input .pheno files as
it should

Closes #14
johnlees committed Nov 18, 2015
1 parent adbe900 commit 5ae40fe
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/seerIO.cpp
Original file line number Diff line number Diff line change
@@ -29,18 +29,22 @@ void readPheno(const std::string& filename, std::vector<Sample>& samples, std::u
throw std::runtime_error("Could not open pheno file " + filename + "\n");
}

// Read in
Sample s;
int sample_index = 0;
while (ist >> s)
{
samples.push_back(s);

sample_map[s.iid()] = sample_index;
sample_index++;
}

// Always keep samples sorted, for consistency between programs
std::sort(samples.begin(), samples.end(), Sample::compareSamples);

// Map of sample names to index in vector
for (unsigned int sample_index = 0; sample_index < samples.size(); ++sample_index)
{
sample_map[samples[sample_index].iid()] = sample_index;
}
}

// Open dsm files, which are possibly zipped

0 comments on commit 5ae40fe

Please sign in to comment.