TeXnik - Tips TeX and LaTeX


Welcome to the TeXnik website (under construction)

DNA Sequences
TUG logo

Main page

Index
UK FAQ
Documentation
Software
CTAN
Search CTAN:

Statistics

Google c.t.t.

Google d.c.t.t.

 


 


To get very long dna-sequences breaked in a senseful way, write in preamble:
\makeatletter
\newcommand\dna[1]{\leavevmode \begingroup
    \dnaZ #1\@empty}
\def\dnaZ #1#2{%
    #1%
     \ifx\@empty#2%
       \let\dnaZ\endgroup
    \else
       \dnaSpace \-%
    \fi
    \dnaZ #2%
}
\makeatother
\newcommand\dnaSpace{\nobreak\hspace{0pt plus .1pt}}
In your text write it in TeXmode (red) like:
\dna{5'-CCATACAACACCCCCGTGTTCGCCATCAAGAAGAAGGACAGTACCAAATGGAG-3'}


To get colored and counted sequences like

dna0.png

write int the preamble

\usepackage{color}

\makeatletter
\def\DNA#1{% by A. Matthias
  \def\@DNA@end{#1}\bgroup\ttfamily
  \settoheight\dimen@{I}\advance\dimen@ by 1pt
  \edef\htst{\the\dimen@}%
  \def\struty{\rule[-.5pt]{\z@}{\htst}}%
  \count@=0 \@tempcnta=0 \@tempcntb=0
  \fboxrule=0pt \fboxsep=0pt
  \noindent\phantom{\@DNA@reserve}\llap 1\
  \@DNA
}
\def\@DNA@reserve{0000}% für 4-stellige Zahlen
\def\@DNA@color{'}
\def\@DNA@thecolor{white}
\def\@DNA@setcolor#1{\def\@DNA@thecolor{#1}\@DNA}
\def\@DNA#1{%
  \ifnum\count@=10\count@=0\ \fi % Abstand nach 10 Zeichen
  \def\@DNA@cmp{#1}%
  \ifx\@DNA@cmp\@DNA@end
    \let\next\egroup
  \else
    \ifx\@DNA@cmp\@DNA@color
      \let\next\@DNA@setcolor
    \else
      \advance\count@ by 1
      \advance\@tempcnta by 1
      \advance\@tempcntb by 1
      \ifnum\@tempcnta=51 \\
        % Umbruch nach 50 Zeichen
        \hskip\z@\phantom{\@DNA@reserve}\llap {\the\@tempcntb}\
        \@tempcnta=1
      \fi
      \colorbox{\@DNA@thecolor}{\struty#1}%
      \penalty0\let\next\@DNA
    \fi
  \fi
  \next
}
\makeatother
and the text for example:
\DNA!
  ACGT'{red}A   CGT'{white}TGCA'{green}x s df'{white}FJKD SLAF DSAIOFDSA
  ACGT'{red}ACGT'{white}TGCA'{green}x  sdf '{white}FJKDSLAF  DSAIOFDSA
  AC  GT'{red}ACGT'{white}TG  CA'{green}xsdf'{white}FJKD  SLAF DSAIOFDSA
  ACGT'{red}ACGT'{white}T  GCA'{green}  xs df'{white}FJKDSLA FDSAIOFDSA
  ACGT'{red}AC  GT'{white}TGCA'{green}xsdf'{white}FJK  DSLA FDSAIOFDSA
!

local time: Tue Dec 10 16:24:42 CET 2019 ; file is: 166.982164351852 days old
contact webmaster _at_ TeXnik.de