Make empty sequences invalid

Open
#23 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
rust

Research direction

Start by tracing IupacDnaSequence::new and the SmallMutation checks mentioned in the issue. Review how alternative sequences are represented, then update construction and deletion handling so empty sequences are rejected while deletions remain representable with Option; done means the affected APIs and downstream checks consistently follow those invariants.

Written by the indexing model from the issue text.

Description

Currently this is a valid construction of a sequence:

let seq = IupacDnaSequence::new("");

But ... rust has the option type for representing the idea of 'None' vs 'Some'. If downstream code needs to express the idea of 'No sequence' or 'empty sequence' currently there are two options. Using Option<Seq> or Returning a sequence with no bases as above.

To simplify APIs and make life easier for downstream sequence processing functions I think we should enforce sequences to be non-empty at construction. This pairs well with our interval types which also cannot represent 0-length intervals.

Example of where this makes life easier:
Any sequence -> length normalised quantititive metrics will no longer have to worry about divide by zero's when dividing by sequence length.

When we implement this, we can now remove the manual checks in SmallMutation for whether reference base is at least length = 1
HOWEVER we will need to make the Alternative sequence and option type (Option) so that we can still represent deletions. E.g. reference = dna!("A") and alternative = None

Dominant language
Rust
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from selkamand/seqlib

All issues in selkamand/seqlib

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.