source code
<?php
#
# The Computer Language Benchmarks Game
# https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
#
# reverse complement in PHP
# contributed by Danny Sauer
# modified by Craig Russell
#
ob_implicit_flush(1);
ob_start(NULL, 4096);
$seq = '';
# read in the file, a line at a time
do {
$str = trim(fgets(STDIN));
if( $str[0] == '>' ){
# if we're on a comment line, print the previous seq and move on
if($seq != ''){
echo wordwrap( strrev( strtr(strtoupper($seq),
'CGATMKRYVBHD', 'GCTAKMYRBVDH') ), 60, "\n", true ), "\n";
$seq = '';
}
echo $str, "\n";
}else{
# otherwise, just append to the sequence
$seq .= $str;
}
} while( !feof(STDIN) );
if($seq != ''){
echo wordwrap( strrev( strtr(strtoupper($seq),
'CGATMKRYVBHD', 'GCTAKMYRBVDH') ), 60, "\n", true ), "\n";
}
notes, command-line, and program output
NOTES:
64-bit Ubuntu quad core
PHP 7.4.5 (cli) (built: May 11 2020 13:25:48) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
Mon, 11 May 2020 22:24:14 GMT
COMMAND LINE:
/opt/src/php-7.4.5/bin/php -n -d memory_limit=3072M revcomp.php-2.php 0 < revcomp-input100000000.txt
(TRUNCATED) PROGRAM OUTPUT:
>ONE Homo sapiens alu
GGGATTACAGGCGTGAGCCACCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTCTGTCGC
CCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTCACTGCAACCTCCGCCTCCCGGGTTCAA
GCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACAGGCGCGCGCCACCACGCCC
GGCTAATTTTTGTATTTTTAGTAGAGACGGGGTTTCACCATGTTGGCCAGGCTGGTCTCG
AACTCCTGACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAAAGTGCTGGGATTACAGGCG
TGAGCCACCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTCTGTCGCCCAGGCTGGAGTG
CAGTGGCGCGATCTCGGCTCACTGCAACCT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