異なる行の文字の間に縦線を追加します。DNA配列塩基

異なる行の文字の間に縦線を追加します。DNA配列塩基

次の DNA 二重鎖配列を LaTeX でタイプセットする方法を知っている人はいますか?

この画像のように、ベース(文字)の間に縦線を追加したいと思います。

ありがとう

DNA二重鎖

もう一つの例を次に示します。

修飾子を含む DNA 二重鎖

答え1

これは、DNA 配列を使用し、それを塩基に分割して補完も行い、それぞれをexpl3-\seq変数に格納するバージョンです。

表示は とTikZノードの構築で行われ、5'3'終了マーカーは後で追加されます。

\documentclass{article}

\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{calc}

\ExplSyntaxOn
\cs_generate_variant:Nn \tl_item:Nn {Nx}

\seq_new:N \l_jpaul_dna_seq
\seq_new:N \l_jpaul_complement_seq

\cs_new:Npn \splitdnaseq #1 {%
  \seq_set_split:Nnn \l_jpaul_dna_seq {} {#1}
  \tl_set:Nn \l_tmpa_tl {#1}
  % Building DNA complement strand
  \tl_replace_all:Nnn \l_tmpa_tl {A} {Q}
  \tl_replace_all:Nnn \l_tmpa_tl {T} {A}
  \tl_replace_all:Nnn \l_tmpa_tl {Q} {T}
  \tl_replace_all:Nnn \l_tmpa_tl {C} {Q}
  \tl_replace_all:Nnn \l_tmpa_tl {G} {C}
  \tl_replace_all:Nnn \l_tmpa_tl {Q} {G}
  % Splitting again and storing to the complement seq
  \seq_set_split:NnV \l_jpaul_complement_seq {} {\l_tmpa_tl}
}

\cs_new:Npn \lengthdna {
  \seq_count:N \l_jpaul_dna_seq
}

\cs_new:Npn \dnaitem #1 {%
  \seq_item:Nn \l_jpaul_dna_seq {#1}
}

\cs_new:Npn \complementitem #1 {%
  \seq_item:Nn \l_jpaul_complement_seq {#1}
}
\ExplSyntaxOff

\NewDocumentCommand{\displaydnaseq}{O{0.2}+m}{%
  \begingroup
  \def\factor{#1}
  \splitdnaseq{#2}
  \begin{tikzpicture}
    \node[red] (5primeleft) at (-\factor,0) {$5'$};
    \foreach \x in {1,...,\lengthdna} {%
      \node[font=\ttfamily,red] (base\x) at (\factor*\x,0)       {\dnaitem{\x}};
      \node[font=\ttfamily,blue] (compbase\x) at (\factor*\x,-1) {\complementitem{\x}};
      \draw[line width=0.7pt] (base\x) -- (compbase\x);
    }
    \node[font=\bfseries,outer sep=0pt,inner sep=0pt,red,right] (3primeright) at ($(base\lengthdna) + (\factor,0)$) {$3'$};
    \node[blue] (3primeleft) at (-\factor,-1) {$3'$};
    \node[font=\bfseries,outer sep=0pt,inner sep=0pt,blue,right] (5primeright) at ($(compbase\lengthdna) + (\factor,0)$) {$5'$};
  \end{tikzpicture}
  \endgroup
}


\begin{document}
\displaydnaseq{TGAATCATTAGCATAG}
\end{document}

ここに画像の説明を入力してください

答え2

下は上によって決まるので、どちらかを指定すれば十分です。私は上を選択しました。

\documentclass{article}

\usepackage{xparse}
\usepackage{xcolor,booktabs}

\ExplSyntaxOn
\NewDocumentCommand{\duplexsequence}{mmm}
 {
  \mbox
   {
    \renewcommand{\arraystretch}{0}
    \jpaul_ds_duplexsequence:nnn { #1 } { #2 } { #3 }
   }
 }

\cs_new_protected:Nn \jpaul_ds_duplexsequence:nnn
 {
  \jpaul_ds_lr:nn { #1 } { #2 }
  \hspace{1em}
  \tl_map_function:nN { #3 } \jpaul_ds_pair:n
  \hspace{1em}
  \jpaul_ds_lr:nn { #2 } { #1 }
 }

\cs_new_protected:Nn \jpaul_ds_pair:n
 {
  \begin{tabular}{@{}c@{}}
  \jpaul_ds_top:n { #1 } \\\addlinespace[.6ex]
  $|$ \\\addlinespace[.6ex]
  \jpaul_ds_bottom:n { #1 }
  \end{tabular}
 }

\cs_new_protected:Nn \jpaul_ds_top:n
 {
  \textcolor{top}{#1}
 }
\cs_new_protected:Nn \jpaul_ds_bottom:n
 {
  \textcolor{bottom}
   {
    \str_case:nn { #1 }
     {
      {T}{A}
      {A}{T}
      {C}{G}
      {G}{C}
     }
   }
 }

\cs_new_protected:Nn \jpaul_ds_lr:nn
 {
  \begin{tabular}{@{}c@{}}
  \smash{\textcolor{top}{#1}}\vphantom{T}\\\addlinespace[.6ex]
  \phantom{$|$}\\\addlinespace[.6ex]
  \smash{\textcolor{bottom}{#2}}\vphantom{T}
  \end{tabular}
 }
\ExplSyntaxOff

\definecolor{top}{RGB}{199,17,34}
\definecolor{bottom}{RGB}{0,39,160}

\begin{document}

\duplexsequence{5$'$}{3$'$}{TGAATCATTAGCATAG}

\end{document}

アイデアはシンプルです。シーケンスをマップし、各項目の表を作成します。あまり効率的ではありませんが、効果的です。

ここに画像の説明を入力してください

一番上の行にプレフィックスとポストフィックスを許可するバージョン:

\documentclass{article}

\usepackage{xparse}
\usepackage{xcolor,booktabs}

\ExplSyntaxOn
\NewDocumentCommand{\duplexsequence}{mO{}mO{}m}
 {
  \mbox
   {
    \renewcommand{\arraystretch}{0}
    \jpaul_ds_duplexsequence:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 }
   }
 }

\cs_new_protected:Nn \jpaul_ds_duplexsequence:nnnnn
 {% #1 is the number on the left
  % #2 is the optional prefix
  % #3 is the number on the right
  % #4 is the optional postfix
  % #5 is the top sequence
  \jpaul_ds_left:nnn { #1 } { #2 } { #3 }
  \tl_map_function:nN { #5 } \jpaul_ds_pair:n
  \jpaul_ds_right:nnn { #3 } { #4 } { #1 }
 }

\cs_new_protected:Nn \jpaul_ds_pair:n
 {
  \begin{tabular}{@{}c@{}}
  \jpaul_ds_top:n { #1 } \\\addlinespace[.6ex]
  $|$ \\\addlinespace[.6ex]
  \jpaul_ds_bottom:n { #1 }
  \end{tabular}
 }

\cs_new_protected:Nn \jpaul_ds_top:n
 {
  \textcolor{top}{#1}
 }
\cs_new_protected:Nn \jpaul_ds_bottom:n
 {
  \textcolor{bottom}
   {
    \str_case:nn { #1 }
     {
      {T}{A}
      {A}{T}
      {C}{G}
      {G}{C}
     }
   }
 }

\cs_new_protected:Nn \jpaul_ds_left:nnn
 {
  \begin{tabular}{@{}r@{}}
  \smash{\textcolor{top}{#1\quad#2}}\vphantom{T}\\\addlinespace[.6ex]
  \phantom{$|$}\\\addlinespace[.6ex]
  \smash{\textcolor{bottom}{#3\quad}}\vphantom{T}
  \end{tabular}
 }
\cs_new_protected:Nn \jpaul_ds_right:nnn
 {
  \begin{tabular}{@{}l@{}}
  \smash{\textcolor{top}{#2\quad#1}}\vphantom{T}\\\addlinespace[.6ex]
  \phantom{$|$}\\\addlinespace[.6ex]
  \smash{\textcolor{bottom}{\quad#3}}\vphantom{T}
  \end{tabular}
 }
\ExplSyntaxOff

\definecolor{top}{RGB}{199,17,34}
\definecolor{bottom}{RGB}{0,39,160}

\begin{document}

\duplexsequence{5$'$}{3$'$}{TGAATCATTAGCATAG}

\bigskip

\duplexsequence{5$'$}[SH-(sp18)-]{3$'$}{TGAATCATTAGCATAG}

\bigskip

\duplexsequence{5$'$}{3$'$}[-(sp18)-SH]{TGAATCATTAGCATAG}

\bigskip

\duplexsequence{5$'$}[SH-(sp18)-]{3$'$}[-(sp18)-SH]{TGAATCATTAGCATAG}

\end{document}

ここに画像の説明を入力してください

関連情報