Chemfig 中的 DNA,骨架

Chemfig 中的 DNA,骨架

我想使用 chemfig 环境来制作化学分子,以创建 DNA。但是,我只希望包含糖骨架而不包含任何碱基。我尝试修改此链接上的源代码:

chemfig 和乐高风格的分子结构

以便找到它,但我不太擅长,一半的时间我都不知道代码是什么意思。有人能帮助我吗?

答案1

以下代码基本上是已发布代码的简化版本这里应该产生您想要达到的数字。

\documentclass{minimal}
\usepackage{chemfig,xstring}
\makeatletter

% "\derivesubmol" defines the new #1 submol, obtained by replacing all the
%  occurrences of "#3" by "#4" in the code of #2 submol

% arguments: #1 = new submol name, #2 = old submol name,
%            #3 = old substring, #4 = new substring
\newcommand*\derivesubmol[4]{%
    \saveexpandmode\saveexploremode\expandarg\exploregroups
    \csname @\ifcat\relax\noexpand#2first\else second\fi oftwo\endcsname
        {\expandafter\StrSubstitute\@car#2\@nil}
        {\expandafter\StrSubstitute\csname CF@@#2\endcsname}
    {\@empty#3}{\@empty#4}[\temp@]%
    \csname @\ifcat\relax\noexpand#1first\else second\fi oftwo\endcsname
        {\expandafter\let\@car#1\@nil}
        {\expandafter\let\csname CF@@#1\endcsname}\temp@
    \restoreexpandmode\restoreexploremode
}
\makeatother

\setatomsep{2.5em}
\setcrambond{2pt}{}{}

\definesubmol{rt1}{-[2]rt1}
\definesubmol{rt2}{-[6,.6]rt2}

\definesubmol{ribose}{%
    -[:-90,2]%
        (%
            -[:25,1.176]O%
            -[:-25,1.176]%
        )%
    <[:-45,0.8]%
        (%
          -[0,,,,line width=2pt,shorten <=-.5pt,shorten >=-.5pt]%
              (!{rt2})%
          >[:45,0.8]%
              (!{rt1})%
         )%
}

\definesubmol{phosphate}{-[6,.6]O-[6,1.5]P(-[4,.8]HO)(=[6,0.8]O)-[,1.5]O}


\begin{document}

\derivesubmol{deoxyribose}{ribose}{(!{rt2})}{}% replace "(!{rt2})" by nothing
\derivesubmol{rt1}{rt1}{rt1}{base}
\chemfig{
      !{deoxyribose}
      !{phosphate}
      !{deoxyribose}
      !{phosphate}
      }

\end{document}

首先,使用 定义构建块“核糖”和“磷酸” \defsubmol。rt1 和 rt2 是锚点或占位符,可以用 定义的任何内容替换\derivesubmol。正如原始示例已经指出的那样,rt2 被“无”替换以获得脱氧核糖,而 rt1 可以用相应碱基的代码替换(如原始示例中所做的那样)或仅用单词“碱基”替换,就像我在上面的示例中所做的那样。

更新

正如 Marco Froelich 在评论中所述,脱氧核糖分子 5' 端的 CH2 基团缺失。以下 MWE 也包含此基团并产生下图。

\documentclass{minimal}
\usepackage{chemfig,xstring}
\makeatletter

% "\derivesubmol" defines the new #1 submol, obtained by replacing all the
%  occurrences of "#3" by "#4" in the code of #2 submol

% arguments: #1 = new submol name, #2 = old submol name,
%            #3 = old substring, #4 = new substring
\newcommand*\derivesubmol[4]{%
    \saveexpandmode\saveexploremode\expandarg\exploregroups
    \csname @\ifcat\relax\noexpand#2first\else second\fi oftwo\endcsname
        {\expandafter\StrSubstitute\@car#2\@nil}
        {\expandafter\StrSubstitute\csname CF@@#2\endcsname}
    {\@empty#3}{\@empty#4}[\temp@]%
    \csname @\ifcat\relax\noexpand#1first\else second\fi oftwo\endcsname
        {\expandafter\let\@car#1\@nil}
        {\expandafter\let\csname CF@@#1\endcsname}\temp@
    \restoreexpandmode\restoreexploremode
}
\makeatother

\setatomsep{2.5em}
\setcrambond{2pt}{}{}

\definesubmol{rt1}{-[2]rt1}
\definesubmol{rt2}{-[6,.6]rt2}

\definesubmol{ribose}{%
    -[:-30,1]%
    -[:-90,1]%
        (%
            -[:25,1.176]O%
            -[:-25,1.176]%
        )%
    <[:-45,0.8]%
        (%
          -[0,,,,line width=2pt,shorten <=-.5pt,shorten >=-.5pt]%
              (!{rt2})%
          >[:45,0.8]%
              (!{rt1})%
         )%
}

\definesubmol{phosphate}{-[6,.6]O-[6,1.5]P(-[4,.8]HO)(=[6,0.8]O)-[,1.5]O}


\begin{document}

\derivesubmol{deoxyribose}{ribose}{(!{rt2})}{}% replace "(!{rt2})" by nothing
\derivesubmol{rt1}{rt1}{rt1}{base}
\chemfig{
      !{deoxyribose}
      !{phosphate}
      !{deoxyribose}
      !{phosphate}
      }

\end{document}

在此处输入图片描述

我的改变:我基本上只是添加了以下行-[:-30,1]%来绘制 CH2 组,并在以下行中将键长从 2 缩短到 1 -[:-90,1]%:。

相关内容