Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add to stdout #1

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on: [push, pull_request]
on: [pull_request]

jobs:
build:
Expand All @@ -24,7 +24,9 @@ jobs:

- name: Verify output
run: |
EXPECTED_OUTPUT="Processing FASTQ file: ./data/sample.fastq\nNumber of reads in ./data/sample.fastq: 2\nGC content in ./data/sample.fastq: 50%"
EXPECTED_OUTPUT="Processing FASTQ file: ./data/sample.fastq
Number of reads in ./data/sample.fastq: 2
GC content in ./data/sample.fastq: 50%"
ACTUAL_OUTPUT=$(./bin/fastq-peak.sh ./data/sample.fastq)
if [[ "$ACTUAL_OUTPUT" != "$EXPECTED_OUTPUT" ]]; then
echo "Output did not match expected result."
Expand Down
10 changes: 10 additions & 0 deletions bin/fastq-peak.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,13 @@ LINE_COUNT=$(wc -l < "$FASTQ_FILE")
READ_COUNT=$((LINE_COUNT / 4))

echo "Number of reads in $FASTQ_FILE: $READ_COUNT"

# Calculate Percent GC
## Count the number of G and C nucleotides
GC_COUNT=$(grep -E '^[ATCGN]+$' "$FASTQ_FILE" | tr -cd 'GCgc' | wc -c)
## Count the total number of nucleotides (A, T, C, G)
TOTAL_BASE_COUNT=$(grep -E '^[ATCGN]+$' "$FASTQ_FILE" | tr -cd 'ATCGatcg' | wc -c)
## Calculate the GC content as a percentage
GC_CONTENT=$(awk "BEGIN {print ($GC_COUNT / $TOTAL_BASE_COUNT) * 100}")

echo "GC content in $FASTQ_FILE: $GC_CONTENT%"
Loading