Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ga4gh/vrs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions tests/validation/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`."
Expand Down
Loading