|
1 | 1 | #
|
2 |
| -# Copyright (C) 2018-2020 University of Oxford |
| 2 | +# Copyright (C) 2018-2022 University of Oxford |
3 | 3 | #
|
4 | 4 | # This file is part of tsinfer.
|
5 | 5 | #
|
@@ -569,7 +569,6 @@ def test_str(self):
|
569 | 569 |
|
570 | 570 | def test_eq(self):
|
571 | 571 | ts = tsutil.get_example_ts(5, random_seed=3)
|
572 |
| - print(ts.num_sites) |
573 | 572 | input_file = formats.SampleData(sequence_length=ts.sequence_length)
|
574 | 573 | self.verify_data_round_trip(ts, input_file)
|
575 | 574 | assert input_file == input_file
|
@@ -663,9 +662,6 @@ def test_insufficient_samples(self):
|
663 | 662 | with pytest.raises(ValueError):
|
664 | 663 | sample_data.add_site(position=0, alleles=["0", "1"], genotypes=[])
|
665 | 664 | sample_data = formats.SampleData(sequence_length=10)
|
666 |
| - with pytest.raises(ValueError): |
667 |
| - sample_data.add_site(position=0, alleles=["0", "1"], genotypes=[0]) |
668 |
| - sample_data = formats.SampleData(sequence_length=10) |
669 | 665 | sample_data.add_individual(ploidy=3)
|
670 | 666 | with pytest.raises(ValueError):
|
671 | 667 | sample_data.add_site(position=0, alleles=["0", "1"], genotypes=[0])
|
@@ -1420,6 +1416,19 @@ def verify_subset_data(self, source, individuals, sites):
|
1420 | 1416 | j += 1
|
1421 | 1417 | assert j == len(sites)
|
1422 | 1418 |
|
| 1419 | + def test_one_sample(self): |
| 1420 | + ts = tsutil.get_example_ts(10) |
| 1421 | + sd1 = formats.SampleData.from_tree_sequence(ts) |
| 1422 | + G1 = ts.genotype_matrix() |
| 1423 | + # Because this is a haploid tree sequence we can use the |
| 1424 | + # individual and sample IDs interchangably. |
| 1425 | + cols = [3] |
| 1426 | + rows = np.arange(ts.num_sites) |
| 1427 | + subset = sd1.subset(individuals=cols, sites=rows) |
| 1428 | + G2 = np.array([v.genotypes for v in subset.variants()]) |
| 1429 | + assert np.array_equal(G1[rows][:, cols], G2) |
| 1430 | + self.verify_subset_data(sd1, cols, rows) |
| 1431 | + |
1423 | 1432 | def test_simple_case(self):
|
1424 | 1433 | ts = tsutil.get_example_ts(10)
|
1425 | 1434 | sd1 = formats.SampleData.from_tree_sequence(ts)
|
|
0 commit comments