Skip to content

Add --both flag to output left and right terminal repeats#13

Merged
Adamtaranto merged 14 commits intomainfrom
copilot/add-both-terminal-repeats
Jan 19, 2026
Merged

Add --both flag to output left and right terminal repeats#13
Adamtaranto merged 14 commits intomainfrom
copilot/add-both-terminal-repeats

Conversation

Copy link
Contributor

Copilot AI commented Jan 16, 2026

Adds --both option to tsplit TIR and tsplit LTR to extract both terminal repeats instead of only the leftmost.

Changes

  • CLI: Added --both flag to TIR and LTR parsers
  • Output naming:
    • With --both: element_L_TIR/element_R_TIR or element_L_LTR/element_R_LTR
    • Without: element_TIR or element_LTR (unchanged)
  • Orientation: Right TIR is reverse complemented (inverted repeats on opposite strands); right LTR is not (direct repeats on same strand)
  • Gap removal: Terminal repeat sequences have gaps stripped via str().replace('-', '')
  • Mode interaction: Only affects --splitmode in {all, split, external}

Implementation

Modified getTIRs() and getLTRs() in parseAlign.py:

if both:
    # Left TIR
    leftSeg = rec[ref_start : ref_end + 1]
    leftSeg.seq = Seq(str(leftSeg.seq).replace('-', ''))
    leftSeg.id = f'{leftSeg.id}_L_TIR'
    yield leftSeg
    
    # Right TIR - reverse complemented for alignment
    rightSeg = rec[qry_start : qry_end + 1]
    rightSeg.seq = Seq(str(rightSeg.seq).replace('-', ''))
    rightSeg = rightSeg.reverse_complement(id=f'{rec.id}_R_TIR', ...)
    yield rightSeg

Testing

Added 21 tests covering:

  • Both flag behavior with different split modes
  • Correct reverse complementation for TIRs
  • No reverse complementation for LTRs
  • Gap removal
  • Suffix naming conventions
Original prompt

This section details on the original issue you should resolve

<issue_title>Feature: Add option to output both terminal repeats</issue_title>
<issue_description>## Current behaviour

The modules tsplit TIR and tsplit LTR currently have the --splitmode options {all,split,internal,external,None}

When using the --splitmode options {all,split,external} the leftmost terminal repeat is reported in the output fasta. This will have the suffix '_TIR' or '_LTR' depending on which tsplit tool is being used.

New feature

Add a new feature that will output both left and right terminal repeats if set.

Detailed tasks

  • Add new arg to tsplit TIR and tsplit LTR called --both. When "both" option is set and --splitmodeoption is one of{all,split,external}` then the output should include both the left an right instance of the detected terminal repeat.
  • Extract the righthand terminal repeat sequence from the alignment record of the lefthand terminal repeat.
  • If reporting both termini then suffix should indicate which end the repeat was extracted from i.e '_L_TIR', '_R_TIR' for TIRs, or '_L_LTR', '_R_LTR' for LTRs depending on which tool is called.
  • When reporting both TIRs the right end copy of the TIR (Terminal Inverted Repeat) should be reported as the reverse complement sequence so that it is align-able to the left TIR. The right LTR however should not be reverse complemented as it will already be in the same orientation as the left LTR.
  • For TIRs, check if the righthand terminal repeat is already in the same orientation as the lefthand repeat when it is extracted from the biopython alignment object.
  • Reported terminal repeats should not contain gaps
  • Write thorough best practice pytests for all new features.
    </issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 16, 2026 05:42
Co-authored-by: Adamtaranto <2160099+Adamtaranto@users.noreply.github.com>
Co-authored-by: Adamtaranto <2160099+Adamtaranto@users.noreply.github.com>
Copilot AI changed the title [WIP] Add option to output both terminal repeats in tsplit Add --both flag to output left and right terminal repeats Jan 16, 2026
Copilot AI requested a review from Adamtaranto January 16, 2026 05:51
@Adamtaranto Adamtaranto marked this pull request as ready for review January 19, 2026 00:20
@Adamtaranto Adamtaranto merged commit be80d3e into main Jan 19, 2026
7 of 13 checks passed
@Adamtaranto Adamtaranto deleted the copilot/add-both-terminal-repeats branch January 19, 2026 00:20
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.

Feature: Add option to output both terminal repeats

2 participants