diff --git a/src/ga4gh/vrs/models.py b/src/ga4gh/vrs/models.py index ad2978d5..16b39649 100644 --- a/src/ga4gh/vrs/models.py +++ b/src/ga4gh/vrs/models.py @@ -782,7 +782,7 @@ def validate_adjoined_sequences(cls, v) -> list[iriReference | SequenceLocation] """ for adjoined_seq in v: if isinstance(adjoined_seq, SequenceLocation): - if adjoined_seq.start and adjoined_seq.end: + if adjoined_seq.start is not None and adjoined_seq.end is not None: err_msg = "Adjoined sequence must not have both `start` and `end`." raise ValueError(err_msg) return v diff --git a/tests/validation/test_models.py b/tests/validation/test_models.py index e126a5b5..ab36373b 100644 --- a/tests/validation/test_models.py +++ b/tests/validation/test_models.py @@ -186,6 +186,18 @@ def test_copy_number_change(): def test_adjacency(): """Test the Adjacency field validator""" + # A bound of 0 still counts as provided + for start, end in [(0, 2), (1, 0), (0, 0)]: + with pytest.raises( + ValueError, match="Adjoined sequence must not have both `start` and `end`." + ): + models.Adjacency( + adjoinedSequences=[ + models.SequenceLocation(start=1), + models.SequenceLocation(start=start, end=end), + ] + ) + # Both start and end provided with pytest.raises( ValueError, match="Adjoined sequence must not have both `start` and `end`."