Skip to content

Commit 063c311

Browse files
committed
adding gc-percentage calculation and reporting
1 parent 2a74c7d commit 063c311

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

bin/fastq-peek.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,13 @@ LINE_COUNT=$(wc -l < "$FASTQ_FILE")
2626
READ_COUNT=$((LINE_COUNT / 4))
2727

2828
echo "Number of reads in $FASTQ_FILE: $READ_COUNT"
29+
30+
# Calculate Percent GC
31+
## Count the number of G and C nucleotides
32+
GC_COUNT=$(grep -E '^[ATCGN]+$' "$FASTQ_FILE" | tr -cd 'GC' | wc -c)
33+
## Count the total number of nucleotides (A, T, C, G)
34+
TOTAL_BASE_COUNT=$(grep -E '^[ATCGN]+$' "$FASTQ_FILE" | tr -cd 'ATCG' | wc -c)
35+
## Calculate the GC content as a percentage
36+
GC_CONTENT=$(awk "BEGIN {print ($GC_COUNT / $TOTAL_BASE_COUNT) * 100}")
37+
38+
echo "GC content in $FASTQ_FILE: $GC_CONTENT%"

0 commit comments

Comments
 (0)