This takes a string as an argument and calls \discretionary{}{}{} after each character. The input line stops with the first dollar sign, so you should not use this.
\def\hyphenateWholeString #1{\xHyphenate#1$\wholeString} \def\xHyphenate#1#2\wholeString {\if#1$% \else\say{#1}\discretionary{}{}{}% \takeTheRest#2\ofTheString \fi} \def\takeTheRest#1\ofTheString\fi {\fi \xHyphenate#1\wholeString} \def\say#1{#1}
You name it as \ hyphenateWholeString {CTAAAGAAAACAGGACG}.
Instead of \ discretionary {} {} {}, you can also try \ hspace {0pt} if you prefer (and in a latex environment). To align the right edge, I think you need to do an even finer adjustment (but see below). Of course, the effect is minimized with a fixed-width font.
Revision:
\def\hyphenateWholeString #1{\xHyphenate#1$\wholeString\unskip} \def\xHyphenate#1#2\wholeString {\if#1$% \else\transform{#1}% \takeTheRest#2\ofTheString\fi} \def\takeTheRest#1\ofTheString\fi {\fi \xHyphenate#1\wholeString} \def\transform#1{#1\hskip 0pt plus 1pt}
Steve's suggestion for using \hskip sounds very good to me, so I made a few corrections. Note that Ive renamed the \say macro and made it more useful since it now actually does the conversion. (However, if you remove \hskip from \transform , you also need to remove \unskip in the definition of the main macro.
Edit:
There is also a seqsplit package which seems to be designed to print DNA data or long numbers. They also bring several options for better output, so maybe this is what you are looking for ...
source share