From 7c1a6a58e16e0f49eb95b37e3cbab369357d6414 Mon Sep 17 00:00:00 2001 From: Sina Booeshaghi Date: Wed, 7 Aug 2024 15:07:22 -0700 Subject: [PATCH] update the spec to enable zero length regions and zero length sequences when min_len is zero --- seqspec/Region.py | 4 ++-- seqspec/schema/seqspec.schema.json | 29 ++++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/seqspec/Region.py b/seqspec/Region.py index 4845bd6..1e64a73 100644 --- a/seqspec/Region.py +++ b/seqspec/Region.py @@ -75,9 +75,9 @@ def update_attr(self): self.sequence = self.get_sequence() self.min_len, self.max_len = self.get_len() if self.sequence_type == "random": - self.sequence = "X" * self.max_len + self.sequence = "X" * self.min_len if self.sequence_type == "onlist": - self.sequence = "N" * self.max_len + self.sequence = "N" * self.min_len return def __repr__(self) -> str: diff --git a/seqspec/schema/seqspec.schema.json b/seqspec/schema/seqspec.schema.json index 3c23f20..2644251 100644 --- a/seqspec/schema/seqspec.schema.json +++ b/seqspec/schema/seqspec.schema.json @@ -144,8 +144,7 @@ }, "sequence": { "description": "The sequence", - "type": "string", - "pattern": "^[ACGTRYMKSWHBVDNX]+$" + "type": "string" }, "min_len": { "description": "The minimum length of the sequence", @@ -194,7 +193,31 @@ "sequence", "min_len", "max_len" - ] + ], + "if": { + "properties": { + "min_len": { + "const": 0 + } + } + }, + "then": { + "properties": { + "sequence": { + "type": "string", + "pattern": "^[ACGTRYMKSWHBVDNX]*$" + } + } + }, + "else": { + "properties": { + "sequence": { + "type": "string", + "minLength": 1, + "pattern": "^[ACGTRYMKSWHBVDNX]+$" + } + } + } }, "read": { "title": "Read",