-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: N50 Calculator CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y gcc make zlib1g-dev | ||
- name: Build N50 Calculator | ||
run: make | ||
|
||
- name: Run tests | ||
run: make test | ||
|
||
- name: Run simple test | ||
run: make test-simple | ||
|
||
- name: Archive binary | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: n50-calculator | ||
path: bin/n50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
CC = gcc | ||
CFLAGS = -Wall -Wextra -O3 | ||
LDFLAGS = -lz -lpthread | ||
|
||
SRC_DIR = src | ||
BIN_DIR = bin | ||
TEST_DIR = test | ||
TARGET = $(BIN_DIR)/n50 | ||
|
||
.PHONY: all clean test | ||
|
||
all: $(TARGET) | ||
|
||
$(TARGET): $(SRC_DIR)/n50.c | $(BIN_DIR) | ||
$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) | ||
|
||
$(BIN_DIR): | ||
mkdir -p $(BIN_DIR) | ||
|
||
clean: | ||
rm -rf $(BIN_DIR) | ||
|
||
test: $(TARGET) | ||
@echo "Running tests..." | ||
@passed=0; failed=0; \ | ||
for file in $(TEST_DIR)/*.*; do \ | ||
filename=$$(basename $$file); \ | ||
expected_n50=$${filename%%.*}; \ | ||
echo "Testing $$filename (Expected N50: $$expected_n50)"; \ | ||
output=$$($(TARGET) $$file); \ | ||
actual_n50=$$(echo "$$output" | cut -f4); \ | ||
if [ "$$actual_n50" = "$$expected_n50" ]; then \ | ||
echo " Passed"; \ | ||
passed=$$((passed + 1)); \ | ||
else \ | ||
echo " Failed. Expected N50: $$expected_n50, Got: $$actual_n50"; \ | ||
failed=$$((failed + 1)); \ | ||
fi; \ | ||
done; \ | ||
echo "Tests completed. Passed: $$passed, Failed: $$failed"; \ | ||
if [ $$failed -ne 0 ]; then exit 1; fi | ||
|
||
# Original simple test | ||
test-simple: $(TARGET) | ||
@echo "Running simple test..." | ||
@echo ">seq1" > test.fasta | ||
@echo "ATCGATCGATCG" >> test.fasta | ||
@echo ">seq2" >> test.fasta | ||
@echo "ATCGATCGATCGATCGATCG" >> test.fasta | ||
@echo ">seq3" >> test.fasta | ||
@echo "ATCG" >> test.fasta | ||
@output=$$($(TARGET) test.fasta); \ | ||
echo "Output: $$output"; \ | ||
total_bp=$$(echo "$$output" | cut -f2); \ | ||
total_seq=$$(echo "$$output" | cut -f3); \ | ||
n50=$$(echo "$$output" | cut -f4); \ | ||
if [ "$$total_bp" = "36" ] && [ "$$total_seq" = "3" ] && [ "$$n50" = "20" ]; then \ | ||
echo "Simple test passed successfully!"; \ | ||
else \ | ||
echo "Simple test failed!"; \ | ||
echo "Expected: 36 total bp, 3 sequences, N50 of 20"; \ | ||
echo "Got: $$total_bp total bp, $$total_seq sequences, N50 of $$n50"; \ | ||
exit 1; \ | ||
fi | ||
@rm test.fasta | ||
@echo "Simple test completed." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
>Seq1 Description | ||
GATACTGACTGACTGATCGATCGTAGCTAGCTAGCTGATCTAGCTAGCTAGCTA | ||
>Seq2 Description | ||
GACTGATCGATCGTAGCTA | ||
>Seq3 Description | ||
GATACTGACTGACTGATCGATCGTAGCTAGCTAGCTGATCTAGCTAGCTAGCTA | ||
>Seq4 Description | ||
GACTGATCGATCGTAGCTA | ||
>Seq5 Description | ||
GATACTGACTGACTGATCGATCGTAGCTAGCTAGCTGATCTAGCTAGCTAGCTA | ||
>Seq6 Description | ||
GACTGATCGATCGTAGCTA | ||
>Seq7 Description | ||
GATACTGAGAGTATATACACACACGACTGACTGATCGATCGTAGCTAGCTAGCTGATCTAGCTAGCTAGCTA | ||
>Seq8 Description | ||
GACTGATCGATCGTAGCTA | ||
>Seq9 Description | ||
GATACTCTGATCGATCGTAGCTAGCTAGCTGATCTAGCTAGCTAGCTA | ||
>Seq10 Description | ||
GACTGATCGATCGTAGCTA |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
@Seq1 Description | ||
GATACTGACTGACTGATCGATCGTAGCTAGCTAGCTGATCTAGCTAGCTAGCTA | ||
+ | ||
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB | ||
@Seq2 Description | ||
GACTGATCGATCGTAGCTA | ||
+ | ||
BBBBBBBBBBBBBBBBBBB | ||
@Seq3 Description | ||
GATACTGACTGACTGATCGATCGTAGCTAGCTAGCTGATCTAGCTAGCTAGCTA | ||
+ | ||
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB | ||
@Seq4 Description | ||
GACTGATCGATCGTAGCTA | ||
+ | ||
BBBBBBBBBBBBBBBBBBB | ||
@Seq5 Description | ||
GATACTGACTGACTGATCGATCGTAGCTAGCTAGCTGATCTAGCTAGCTAGCTA | ||
+ | ||
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB | ||
@Seq6 Description | ||
GACTGATCGATCGTAGCTA | ||
+ | ||
BBBBBBBBBBBBBBBBBBB | ||
@Seq7 Description | ||
GATACTGAGAGTATATACACACACGACTGACTGATCGATCGTAGCTAGCTAGCTGATCTAGCTAGCTAGCTA | ||
+ | ||
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB | ||
@Seq8 Description | ||
GACTGATCGATCGTAGCTA | ||
+ | ||
BBBBBBBBBBBBBBBBBBB | ||
@Seq9 Description | ||
GATACTCTGATCGATCGTAGCTAGCTAGCTGATCTAGCTAGCTAGCTA | ||
+ | ||
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB | ||
@Seq10 Description | ||
GACTGATCGATCGTAGCTA | ||
+ | ||
BBBBBBBBBBBBBBBBBBB |
Binary file not shown.