7

Inspired by this question chemfig and lego-style molecule construction, I decided to make a generic method of drawing peptides...that's a series of amino acids bonded together to the uninitiated.

I made a generic backbone for the $\alpha$-amino acid chain with replaceable substituents. I also had two versions of each chain depending of positioning peptide (aa1 in position 1, aa2 in position2, aa1 in position 3, aa2 in position 4, i.e. odd number backbone in odd number positions etc)

I can make my sub molecules, I can derive submolecules but I can't put them together!

(Forgive the cut and paste from lego-style answer and minimal formatting....)

What simple thing am I doing wrong? Commenting out all but one of the submolecules in the last \chemfig environment, just produces that molecule, but all commented gives nada.

\documentclass{minimal}
\usepackage{chemfig,xstring,chemmacros}
\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}{<[::-60]rt1}
\definesubmol{rt2}{<:[::60]rt2}

\definesubmol{aa1}
{
N(-[::90,0.3,,,draw=none]H)-[::-30](!{rt1})-[::60](=[::60]O)-[::-60]
}
\definesubmol{aa2}
{
N(-[::-90,0.3,,,draw=none]H)-[::30](!{rt2})-[::-60](=[::-60]O)-[::60]
}


\def\drawhline{\medbreak\hrulefill\medbreak}
\begin{document}

\chemfig{!{aa1}} \quad\quad The $\alpha$-amino acid template\quad\quad\chemfig{!{aa2}}

\drawhline%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\derivesubmol{ala1}{aa1}{!{rt1}}{<[::-60]CH_3}
\chemfig{!{ala1}} \quad\quad In Alanine, substituent rt1 is replaced by \ch{CH3}



\derivesubmol{ala2}{aa2}{!{rt2}}{<:[::60]CH_3}
\chemfig{!{ala2}}\quad\quad rotated
\drawhline

\derivesubmol{gly1}{aa1}{!{rt1}}{}
\chemfig{!{gly1}} \quad\quad In Glycine, substituent rt1 is replaced by nothing
\quad\quad

\derivesubmol{gly2}{aa2}{!{rt2}}{}
\chemfig{!{gly2}}\quad\quad rotated
\drawhline

\drawhline%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\derivesubmol{Val1}{aa1}{!{rt1}}{<[::-60](-[::-60]CH_3)(-[::60]CH_3)}
\chemfig{!{Val1}} \quad\quad In Val, substituent rt1 is replaced by \ch{CH(CH3)2)}
\quad\quad Valine

\quad\quad
\derivesubmol{Val2}{aa2}{!{rt2}}{<:[::60](-[::-60]CH_3)(-[::60]CH_3)}
\chemfig{!{Val2}}\quad\quad rotated
\drawhline

\drawhline%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\derivesubmol{Phe1}{aa1}{!{rt1}}{<[::-60]CH2-[::0]Ph}
\chemfig{!{Phe1}} \quad\quad In Phe, substituent rt1 is replaced by \ch{CH2Ph}

\quad\quad Phenylanaline

\quad\quad

\derivesubmol{Phe2}{aa2}{!{rt2}}{<:[::60]CH2-[::0]Ph}
\chemfig{!{Phe2}}\quad\quad rotated
\drawhline
\chemfig{
!{Val1} 
!{ala2}
!{Phe1}
!{Phe2}
!{gly1}
}


\end{document}

1 Answer 1

6

A straightforward solution is to "bind" the submolecules, i.e.,

replace your code:

\chemfig{
!{Val1} 
!{ala2}
!{Phe1}
!{Phe2}
!{gly1}
}

by for example (some tweaking would be probably necessary):

\chemfig{
!{Val1}-[,0.3,,,draw=none]
!{ala2}-[,0.3,,,draw=none]
!{Phe1}-[,0.3,,,draw=none]
!{Phe2}-[,0.3,,,draw=none]
!{gly1}
}
1
  • no tweaking required!!! Works great.
    – Leeser
    Commented Nov 21, 2014 at 11:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .