Skip to content

simplify SeqLike.__getitem__() to ignore the AA sequence when accessing/slicing the NT sequence #72

Description

@ndousis

As currently implemented, slicing a SeqLike that contains AA and NT records yields:

  1. a simple behavior when the AA record is primary, and
  2. a slow and less robust behavior when the NT record is primary (e.g., if the slice is not a triplet, SeqLike returns a "Partial codon" warning)

In particular, the computational overhead of translating the NT sequence during each __getitem__() call can be very tedious (e.g., when applying a long sliding window over an entire sequence).

I propose that we eliminate the second behavior (attempting to slice the AA record when NT is primary)-- i.e., when slicing the NT SeqLike, all bets are off with respect to the AA record, and the user must explicitly translate the SeqLike to yield a new AA record.

Alternatively, we could add a flag to optionally retain the AA record when True (default False; similar to how BioPython already addresses this for SeqRecord.reverse_complement()), though I don't know how to implement this properly in __getitem__().

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions