Skip to content

Conversation

@AliAlimohammadi
Copy link

Description

This PR adds the Smith-Waterman algorithm implementation to the dynamic_programming directory.

Algorithm Overview

The Smith-Waterman algorithm is a dynamic programming algorithm for determining similar regions between two sequences (nucleotide or protein sequences). It performs local sequence alignment and is particularly useful in bioinformatics.

Key Features:

  • Local alignment: Finds the best matching subsequence rather than aligning entire sequences
  • Dynamic programming: O(m×n) time complexity where m and n are sequence lengths
  • Configurable scoring: Supports custom match, mismatch, and gap penalties
  • Traceback functionality: Reconstructs the optimal alignment

Implementation Details:

  • score_function: Calculates alignment scores for character pairs
  • smith_waterman: Builds the scoring matrix using dynamic programming
  • traceback: Reconstructs the optimal alignment from the scoring matrix

Code Quality

The implementation follows TheAlgorithms/C-Plus-Plus standards:

  • ✅ Doxygen-style documentation
  • ✅ Namespace organization (dynamic_programming::smith_waterman)
  • ✅ Modern C++ practices (C++11 and above)
  • ✅ STL usage (no bits/stdc++.h)
  • ✅ Comprehensive self-tests (8 test cases)
  • ✅ Example usage in main function

Testing

The implementation includes 8 comprehensive test cases:

  • ✅ Simple exact match
  • ✅ Partial match
  • ✅ Traceback verification
  • ✅ No match scenario
  • ✅ Empty string handling
  • ✅ Sequences with gaps
  • ✅ Custom scoring parameters
  • ✅ Case sensitivity

All tests pass:

g++ -std=c++11 -O2 -Wall dynamic_programming/smith_waterman.cpp -o smith_waterman
./smith_waterman

Documentation

  • Detailed file-level Doxygen documentation
  • Function-level documentation with parameters and returns
  • Algorithm explanation with complexity analysis
  • References to original paper and Wikipedia

Checklist

  • Algorithm implementation is correct
  • All tests pass locally
  • Code follows C++ best practices
  • Uses standard library (no bits/stdc++.h)
  • Organized with namespace
  • Doxygen documentation complete
  • No compiler warnings
  • Added to appropriate directory (dynamic_programming)
  • Example usage provided

References

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Author has not responded to the comments for over 2 weeks label Jan 5, 2026
@poyea poyea requested a review from Copilot January 5, 2026 12:51
@poyea poyea self-assigned this Jan 5, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a Smith-Waterman algorithm implementation for local sequence alignment in bioinformatics applications. The implementation uses dynamic programming to find optimal local alignments between two sequences with configurable scoring parameters.

Key changes:

  • Adds a complete Smith-Waterman algorithm with matrix scoring and traceback functionality
  • Includes 8 test cases covering various scenarios including edge cases
  • Provides comprehensive Doxygen documentation following project standards

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions bot removed the stale Author has not responded to the comments for over 2 weeks label Jan 6, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

poyea
poyea previously approved these changes Jan 6, 2026
@AliAlimohammadi
Copy link
Author

@poyea, revisions completed.

@AliAlimohammadi AliAlimohammadi requested a review from poyea January 6, 2026 20:37
@AliAlimohammadi
Copy link
Author

@realstealthninja, this is ready to be merged.

@poyea poyea added the approved Approved; waiting for merge label Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Approved; waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants