Created
May 3, 2020 20:25
-
-
Save hopeseekr/d89467e91b3696deac623a3c603c26ab to your computer and use it in GitHub Desktop.
Splits long DNA strings into sequences and then counts the stop codons.
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
<?php | |
$DNA = file($argv[1]); | |
$splitDNA = str_split($DNA[1], 3); | |
$stopCodons = [ | |
'TAG', | |
'TAA', | |
'TGA', | |
]; | |
$codonCounts = array_count_values($splitDNA); | |
foreach ($stopCodons as $stopCodon) { | |
echo "$stopCodon: " . ($codonCounts[$stopCodon] ?? 0) . "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment