Arguments on why string concatenation loops (SCL) is a bad programming practice were given in a previous post.
You can also google for additional arguments against SCL.
We now show a simple PHP code that makes unnecessary SCL when computing DNA reverse complement sequences. Consider the sequence
This sequence corresponds to the first 21 nucleotides of the NCBI Reference Sequence NC_045512.2; i.e., to the first 21 nts of the complete genome of the severe acute respiratory syndrome coronavirus 2 isolate Wuhan-Hu-1 (https://www.ncbi.nlm.nih.gov/nuccore/NC_045512.2 ).
To compute its reverse complement sequence,
we just need to use the following one-liner:
echo strrev(strtr(‘ATTAAAGGTTTATACCTTCCC’, ‘ACGT’, ‘TGCA’));
No string splitting, concatenation, or looping are needed!
As I always say, graduate students and postdocs who can code have and edge in multidisciplinary research work over those that cannot code.