Skip to content

Commit

Permalink
Merge pull request #29 from PennChopMicrobiomeProgram/28-use-fmt-cont…
Browse files Browse the repository at this point in the history
…rollers

Use `#fmt` controllers for test_align.py linting
  • Loading branch information
Ulthran authored Jun 27, 2024
2 parents 23ddca1 + d1eebfb commit b1850fc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
15 changes: 5 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ jobs:
fail-fast: false
matrix:
python-version: ['3.12']
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest]
# Windows runners can take way too long to be available
# and the setup-conda action isn't compatible with macOS and python 3.12
# os: [ubuntu-latest, windows-latest, macos-latest]
include:
- python-version: '3.11'
os: ubuntu-latest
Expand Down Expand Up @@ -85,17 +88,9 @@ jobs:
- name: Install Dependencies
run: pip install black

# test_align.py includes tests that have weird formatting because we want to be able to line
# up the expected and actual alignments in the test output. I've found it's really easy to
# run 'black .' and forget about it, so I'm including this check to make sure it FAILS the
# formatting check. If this trips you up, probably just revert the changes to that file.
- name: Lint Code Base
run: |
black --check --exclude="test_align.py" .
if black --check --include="test_align.py" . ; then
exit 1
fi
black --check .
codacy-analysis-cli:
name: Codacy Analysis CLI
Expand Down
3 changes: 0 additions & 3 deletions reformat.sh

This file was deleted.

12 changes: 12 additions & 0 deletions tests/unit/test_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,55 @@ def test_no_endgaps(self):
self.assertEqual(align_semiglobal(qseq, sseq), (qseq, sseq))

def test_endgaps_both_sides_query(self):
# fmt: off
qseq = "GATGAACGCTAGCTTCAGGCTTAAC"
sseq = "CTCAGGATGAACGCTAGCTACAGGCTTAACACATGCAAGT"
# fmt: on
aligned_qseq, aligned_sseq = align_semiglobal(qseq, sseq)
self.assertEqual(aligned_qseq, "-----" + qseq + "----------")
self.assertEqual(aligned_sseq, sseq)

def test_endgaps_left_query(self):
# fmt: off
qseq = "GATGAACGCTAGCTTCAGGCTTAAC"
sseq = "CTCAGGATGAACGCTAGCTACAGGCTTAAC"
# fmt: on
aligned_qseq, aligned_sseq = align_semiglobal(qseq, sseq)
self.assertEqual(aligned_qseq, "-----" + qseq)
self.assertEqual(aligned_sseq, sseq)

def test_endgaps_right_query(self):
# fmt: off
qseq = "GATGAACGCTAGCTTCAGGCTTAAC"
sseq = "GATGAACGCTAGCTACAGGCTTAACACATGCAAGT"
# fmt: on
aligned_qseq, aligned_sseq = align_semiglobal(qseq, sseq)
self.assertEqual(aligned_qseq, qseq + "----------")
self.assertEqual(aligned_sseq, sseq)

def test_ragged_left_subject(self):
# fmt: off
qseq = "CTCAGGATGAACGCTAGCTACAGGCTTAAC"
sseq = "GATGAACGCTAGCTTCAGGCTTAACACATG"
# fmt: on
aligned_qseq, aligned_sseq = align_semiglobal(qseq, sseq)
self.assertEqual(aligned_qseq, qseq + "-----")
self.assertEqual(aligned_sseq, "-----" + sseq)

def test_ragged_right_subject(self):
# fmt: off
qseq = "GATGAACGCTAGCTACAGGCTTAACACATG"
sseq = "CTCAGGATGAACGCTAGCTTCAGGCTTAAC"
# fmt: on
aligned_qseq, aligned_sseq = align_semiglobal(qseq, sseq)
self.assertEqual(aligned_qseq, "-----" + qseq)
self.assertEqual(aligned_sseq, sseq + "-----")

def test_funky_query_left(self):
# fmt: off
qseq = "TTTTGATGAACGCTAGCTACAGGCTTA"
sseq = "CTCAGGATGAACGCTAGCTTCAGGCTTAAC"
# fmt: on
aligned_qseq, aligned_sseq = align_semiglobal(qseq, sseq)
self.assertEqual(aligned_qseq, "-" + qseq + "--")
self.assertEqual(aligned_sseq, sseq)
Expand Down

0 comments on commit b1850fc

Please sign in to comment.