← 输入框|github.com|刷新
Skip to content

Fix reverse complement calculation in CDSSequence.getCodingSequence (#1016) - #1160

Open
nayanhasnolyf wants to merge 1 commit into
biojava:masterfrom
nayanhasnolyf:fix/cds-sequence-reverse-complement-1016
Open

nayanhasnolyf wants to merge 1 commit into
biojava:masterfrom
nayanhasnolyf:fix/cds-sequence-reverse-complement-1016

Conversation

@nayanhasnolyf

Copy link
Copy Markdown

Fixes #1016

Problem

When CDSSequence.getCodingSequence() is called on a negative-strand transcript/gene, it previously resulted in a sequence that was only reversed rather than reverse-complemented.

This occurred because this.getSequenceAsString(getBioBegin(), getBioEnd(), getStrand()) delegates to SimpleLocation.getSubSequence(), which invokes AbstractLocation.reverseSequence(). For Strand.NEGATIVE, AbstractLocation.reverseSequence() already wraps the sequence in both ReversedSequenceView and ComplementSequenceView, successfully generating the reverse complement.

However, CDSSequence.getCodingSequence() then executed an additional if (getStrand() == Strand.NEGATIVE) block that complemented every nucleotide a second time. Because $\text{complement}(\text{complement}(N)) = N$, this second complementation inverted the nucleotides back to their original bases while leaving the sequence reversed (e.g. producing CCCCCAAAAA instead of GGGGGTTTTT).

Solution

  • Removed the redundant second complementation block in CDSSequence.getCodingSequence().
  • Removed now-unused imports (CompoundSet, NucleotideCompound) in CDSSequence.java.
  • Enabled the existing disabled unit test TranscriptSequenceTest.getCDNASeqNegativeStrand() and asserted both CDSSequence.getCodingSequence() and TranscriptSequence.getDNACodingSequence() return the proper reverse complement.
  • Verified all 536 tests in biojava-core pass with zero regressions.

…iojava#1016)

Signed-off-by: Nayan Pokhriyal <nayanpokhriyal25@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

o.b.n.core.sequence.CDSSequence doesn't reverse-complement correctly

1 participant