%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Example of  MCF typest with LuaLaTeX(luamplib)     by A.Yamaji    2017.08.13
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% mcf2graph.mf it must be version 4.26 or later
\documentclass{article}
%------------------------------------------------------------------------------
\usepackage{luamplib}%
\usepackage[T1]{fontenc}%
\usepackage{textcomp}%
\mplibcodeinherit{enable}%
\mplibverbatim{enable}%
\everymplib{if unknown Ph1:
              input mcf2graph.mf;
              sw_auxout:=1;
              sw_label_emu:=1;
              sw_font_frame:=4;
              max_bond_length:=4.5mm;
              defaultfont:="uhvr8r";
              defaultsize:=8bp;
              defaultscale:=0.7;
            fi}%
%------------------------------------------------------------------------------
\pagestyle{empty}
\topmargin=-20mm
\oddsidemargin=0mm
\textwidth=170mm
\textheight=280mm
\unitlength=1mm
%------------------------------------------------------------------------------------
\begin{document}
\begin{center}
 {\Huge\sf MCF example for luamplib(Lua\LaTeX)}\vspace{5mm}\\
 Author : Akira Yamaji \quad Date : \today\\
 Located at : http://www.ctan.org/pkg/mcf2graph\vspace{2mm}\\
\end{center}
\noindent%
%------------------------------------------------------------------------------------
{{\small {\tt FM(C) :} molecular formula calculated by mcf2graph}\\
{{\small {\tt MW(C) :} molecular weight calculated by mcf2graph}\\
{{\small {\tt MW(D) :} molecular weight from literature data}\vspace{5mm}\\
\begin{mplibcode}
  font_wd:=80mm; font_ht:=40mm;
  beginfont("NO:1","EN:Chlorophyll a","MW:893.49")
    MCa(1,0.5)(<54,
     |<,``1,?5,{2,5}=dl,4:N,3:\,54~dl,|,?5,{2,4}=dl,5:N,
     -2:\,54~dl,|,?5,2=dl,5:N,-2:\~dl,54,|,?5,5=dl,5:N,-2:\~dl,&#5,
     -1:@,24,/*COO!^15,72,//O,&#1,>|,
     4:\`1.45,Mg,&17,-1:@,&11~vb,-1:@,&23~vb,
     {2,9,15,20~zf}:/_,8:/!,14:\,!!,
     21:@,-6~wf,!2,//O,!,O,!2,!!,|,!13,{1,5,9,13}:/_,
    )
    EXT(
      label.lrt("("&inf_EN&")",(0,h));
      label.lrt("FM(C): "&cal_FM,(0,h-4mm));
      label.lrt("FM(C): "&cal_MW,(0,h-8mm));
      label.lrt("FM(D): "&inf_MW,(0,h-12mm));
    )
  endfont
\end{mplibcode}
\begin{minipage}[b]{85mm}
\begin{verbatim}
|<,``1,?5,{2,5}=dl,4:N,3:\,54~dl,
|,?5,{2,4}=dl,5:N,
-2:\,54~dl,|,?5,2=dl,5:N,
-2:\~dl,54,|,?5,5=dl,5:N,-2:\~dl,&#5,
-1:@,24,/*COO!^15,72,//O,&#1,>|,
4:\`1.45,Mg,&17,-1:@,&11~vb,-1:@,&23~vb,
{2,9,15,20~zf}:/_,8:/!,14:\,!!,
21:@,-6~wf,!2,//O,!,O,!2,!!,
|,!13,{1,5,9,13}:/_,

\end{verbatim}
\end{minipage}
\vspace{0mm}\\
%----------------------------------------------------------------------------
\begin{mplibcode}
  font_wd:=80mm; font_ht:=30mm;
  beginfont("NO:2","EN:Limonin","MW:470.51")
  MCa(.6,0.5)(<30,
    ?6,{-3,-4}=?6,-5=?3,-2=wf,-1=wb,6=?5,-4=?6,-5=wf,
      {13,15,17,20}:O,{3,12,21}://O,
      {4~wf^60,8~zf^60,18^35,18^-35}:/_,{1^60,5^180,16^60}:/*H,
      14:\*,|,?5,{1,4}=dl,3:O
     )
    EXT(
      label.lrt("("&inf_EN&")",(0,h));
      label.lrt("FM(C): "&cal_FM,(0,h-4mm));
      label.lrt("FM(C): "&cal_MW,(0,h-8mm));
      label.lrt("FM(D): "&inf_MW,(0,h-12mm));
    )
  endfont
\end{mplibcode}
\begin{minipage}[b]{85mm}
\begin{verbatim}
<30,?6,{-3,-4}=?6,-5=?3,
-2=wf,-1=wb,6=?5,-4=?6,-5=wf,
{13,15,17,20}:O,{3,12,21}://O,
{4~wf^60,8~zf^60,18^35,18^-35}:/_,
{1^60,5^180,16^60}:/*H,
14:\*,|,?5,{1,4}=dl,3:O

\end{verbatim}
\end{minipage}
\vspace{5mm}\\%
%----------------------------------------------------------------------------
\begin{mplibcode}
font_wd:=80mm; font_ht:=20mm;
beginfont("NO:4","EN:Gibberellin A3","MW:346.37");
  MCa(.6,0.5)(
   <18,?5,3=?7,5=?6[12],8:@,160`1.3,&3,13=dl,6=wf,8=wb,
   5:@,40~zf`1,O,60,//O^180,&14~zb,
   2:/COOH,7://_,13:*/OH,8:/*OH,14:*/_,{1^60,4^60}:*/H)
    EXT(
      label.lrt("("&inf_EN&")",(0,h));
      label.lrt("FM(C): "&cal_FM,(0,h-4mm));
      label.lrt("FM(C): "&cal_MW,(0,h-8mm));
      label.lrt("FM(D): "&inf_MW,(0,h-12mm));
    )
endfont;
\end{mplibcode}
\begin{minipage}[b]{85mm}
\begin{verbatim}
<18,?5,3=?7,5=?6[12],8:@,160`1.3,&3,
13=dl,6=wf,8=wb,
5:@,40~zf`1,O,60,//O^180,&14~zb,
2:/COOH,7://_,13:*/OH,8:/*OH,
14:*/_,{1^60,4^60}:*/H)
\end{verbatim}
\end{minipage}
\vspace{6mm}\\
%----------------------------------------------------------------------------
\begin{mplibcode}
font_wd:=80mm; font_ht:=35mm;
beginfont("NO:5","EN:Erythromycin","MW:733.93");
  MCa(.6,0.5)(
    <30,|<,``1,<-120,60,60,60,-60,60,60,-60,60,60,60,-60,60,60,>|,&1,
     14:O,13:/*Et,{1,9}://O,{2,10}:*/_,{4,6^-35,8,12^35}:/*_,
     {6^35,11,12^-35}:*/OH,
     #3:\*,O,30,|,?6`.7,2:O,{3,5^35}:/_,4:/OH,5^-35:/O!,
     #5:\*^30`1.7,O,!,|,?6`.7,6:O,5:/_,2:/OH,3:/NMeMe
     )
    EXT(
      label.lrt("("&inf_EN&")",(0,h));
      label.lrt("FM(C): "&cal_FM,(0,h-4mm));
      label.lrt("FM(C): "&cal_MW,(0,h-8mm));
      label.lrt("FM(D): "&inf_MW,(0,h-12mm));
    )
  endfont;
\end{mplibcode}
\begin{minipage}[b]{85mm}
\begin{verbatim}
<30,|<,``1,<-120,60,60,60,-60,60,
60,-60,60,60,60,-60,60,60,>|,&1,
14:O,13:/*Et,{1,9}://O,{2,10}:*/_,
{4,6^-35,8,12^35}:/*_,
{6^35,11,12^-35}:*/OH,
#3:\*,O,30,|,?6`.7,2:O,
{3,5^35}:/_,4:/OH,5^-35:/O!,
#5:\*^30`1.7,O,!,|,?6`.7,6:O,
5:/_,2:/OH,3:/NMeMe
\end{verbatim}
\end{minipage}
\vspace{5mm}\\
%----------------------------------------------------------------------------
\begin{mplibcode}
font_wd:=80mm; font_ht:=65mm;
beginfont("NO:6","EN:Vancomycin","MW:1449.25");
  MCa(0.5,0)(
    <30,
    |<,``1,!12,{1,3,12}=zf,7=wf,/H^-60,60,*/OH,60,
    Ph,-4:/Cl,-3:\,O,!,Ph,-4:\,O,!,Ph,-1^15:/Cl,-3:\,/*OH,*/H^-60,&#1,
    #7:@,&#26,#1:@,120,//O,60,NH,60,/*H,*/COOH^180,-60,
    Ph,{-2,-4}:/OH,-1:\,Ph,-5:/OH,-2:@,&#4,>|,
    {3^40,6,9,12}://O,{2,5,8,11}:NH,
    {1^180,4^180}:*/H,{7^-60,10^60,14^60}:/*H,
    #10:*\^-60,60,//O,!,NH2,
    #13:*\,NH,!,//O,!,/!iPr^-35>60,*/H^60,!~zf,NH,!,
    #23:\,O,!,|,?6`.7,2:O,3^10:/!OH,{4,5}:/OH,
    -1:\,O,!,|,?6`.7,6:O,{3^35,5}:/_,3^-35:/NH2,4:/OH
    )
    EXT(
      label.lrt("("&inf_EN&")",(0,h));
      label.lrt("FM(C): "&cal_FM,(0,h-4mm));
      label.lrt("FM(C): "&cal_MW,(0,h-8mm));
      label.lrt("FM(D): "&inf_MW,(0,h-12mm));
    )
endfont;
\end{mplibcode}
\begin{minipage}[b]{85mm}
\begin{verbatim}
<30,|<,``1,!12,{1,3,12}=zf,7=wf,
/H^-60,60,*/OH,60,Ph,-4:/Cl,
-3:\,O,!,Ph,-4:\,O,!,Ph,-1^15:/Cl,
-3:\,/*OH,*/H^-60,&#1,
#7:@,&#26,#1:@,120,//O,60,NH,60,
 /*H,*/COOH^180,-60,
Ph,{-2,-4}:/OH,-1:\,Ph,-5:/OH,-2:@,&#4,>|,
{3^40,6,9,12}://O,{2,5,8,11}:NH,
{1^180,4^180}:*/H,
{7^-60,10^60,14^60}:/*H,
#10:*\^-60,60,//O,!,NH2,#13:*\,NH,!,//O,!,
 /!iPr^-35>60,*/H^60 ,!~zf,NH,!,
#23:\,O,!,|,?6`.7,2:O,3^10:/!OH,{4,5}:/OH,
-1:\,O,!,|,?6`.7,6:O,
{3^35,5}:/_,3^-35:/NH2,4:/OH
\end{verbatim}
\end{minipage}
\vspace{0mm}\\%
%----------------------------------------------------------------------------
\begin{mplibcode}
  font_wd:=170mm; font_ht:=80mm;
  beginfont("NO:7","EN:Maitotoxin","MW:3425.86")
  MCf(
    <55.8,?6,-4=?7 ,{-4,-3,-3,-3}=?6,-3:\,!3,?6,{-4,-3,-3,-3}=?6,
    -3:\,?6,-3=?6,-3:\,!3,60,<-30,?6,-3=?6,
    -3:@,30,<30,?6,{-3,-3}=?6,-3=?7,{-4,-3,-3}=?6,
    -2:\,?6,-3=?6,-3=?7,{-3,-3}=?6,-3=?8,-3=dl,{-5,-3,-3,-3}=?6,
    {5,7,15,16,23,24,32,40,41,48,49,58,59,72,73,82,83,90,91,99,
      100,107,113,114,122,123,130,131,140,141,148,149}:O,
    {1^60,2,26,28,29,51,54,61,63,68,75^60,78,109}:*/OH,
    {11,20,35,45,52,55,65,69,86}:/*OH,{47,57,71}:/*H^60,
    {3,8,13,17,21,33,38,42,56,70,84,92,101,106,111,128,138,142,146,150}:/*H^-60,
    {4,14,22,34,39,43,81,89,98,102,116,121,125,129,133}:*/H^60,
    {6,46,50,53,60,67,74}:*/H^-60,
    {9,18,85,93,112,139,143,147}:*/_`1^60,
    {80,88,97,115,120,124}:/*_`1^-60,108:*/_`1^-60,
    #6:\,|,!11,60~dr,-60,60,OH,2:/*OH,{7,10}:*/OH,{1,3}:*/_,{8~zf,11~dm,12}:/_,
              6:\,O,30,SOO,30,"O{Na}",
    #36:@,-45~zf,O,30,SOO,30,"O{Na}",
    #150:\,|,!7,{1,2}:/*OH,4:*/_,5:/*_,7=dl
    )
    EXT(
      label.lrt("("&inf_EN&")",(0,.8h));
      label.lrt("FM(C): "&cal_FM,(0,.8h-4mm));
      label.lrt("FM(C): "&cal_MW,(0,.8h-8mm));
      label.lrt("FM(D): "&inf_MW,(0,.8h-12mm));
    )
  endfont
\end{mplibcode}
\begin{verbatim}
   <55.8,?6,-4=?7 ,{-4,-3,-3,-3}=?6,-3:\,!3,?6,{-4,-3,-3,-3}=?6,
   -3:\,?6,-3=?6,-3:\,!3,60,<-30,?6,-3=?6,
   -3:@,30,<30,?6,{-3,-3}=?6,-3=?7,{-4,-3,-3}=?6,
   -2:\,?6,-3=?6,-3=?7,{-3,-3}=?6,-3=?8,-3=dl,{-5,-3,-3,-3}=?6,
   {5,7,15,16,23,24,32,40,41,48,49,58,59,72,73,82,83,90,91,99,
    100,107,113,114,122,123,130,131,140,141,148,149}:O,
   {1^60,2,26,28,29,51,54,61,63,68,75^60,78,109}:*/OH,
   {11,20,35,45,52,55,65,69,86}:/*OH,{47,57,71}:/*H^60,
   {3,8,13,17,21,33,38,42,56,70,84,92,101,106,111,128,138,142,146,150}:/*H^-60,
   {4,14,22,34,39,43,81,89,98,102,116,121,125,129,133}:*/H^60,
   {6,46,50,53,60,67,74}:*/H^-60,{9,18,85,93,112,139,143,147}:*/_`1^60,
   {80,88,97,115,120,124}:/*_`1^-60,108:*/_`1^-60,
   #6:\,|,!11,60~dr,-60,60,OH,2:/*OH,{7,10}:*/OH,{1,3}:*/_,{8~zf,11~dm,12}:/_,
     6:\,O,30,SOO,30,"O{Na}",
   #36:@,-45~zf,O,30,SOO,30,"O{Na}",#150:\,|,!7,{1,2}:/*OH,4:*/_,5:/*_,7=dl
\end{verbatim}
\vspace{8mm}%
%----------------------------------------------------------------------------
{\LARGE\bf TCA-cycle}\\
\begin{mplibcode}
  beginfont("EN:TCA cycle")
  save a;
  %------------------------------------------------------------------------
  font_wd:=100mm;
  font_ht:=100mm;
  max_bond_length:=5mm;
  %------------------------------------------------------------------------
  sw_label_emu:=1;
  defaultscale:=0.75;
  %------------------------------------------------------------------------
  a:=12mm;
  Om:='("{O^-^}");
  MCa(0.5,1)(<30,Om,!0,//O,!,//O,!2,//O,!,Om)
  MCa(1,  1)(<30,Om,!0,//O,!,!,!,!,//O,!,Om,-4`1:\,//O,!,Om,4:/OH^-165)
  MCa(1,.66)(<30,Om,!0,//O,!,!,!~dr,!,//O,!,Om,-4`1:\,//O,!,Om)
  MCa(1,.35)(<30,Om,!0,//O,!,!,!,!,//O,!,Om,-4:\`1,//O,!,Om)
  MCa(1,  0)(<30,Om,!0,//O,!,!,!,//O,!,//O,!,Om,-4:\`1,//O,!,Om)
  MCa(0.5,0)(<30,Om,!0,//O,!,!,!,//O,!,//O,!,Om)
  MCa(0,  0)(<30,Om,!0,//O,!,!,!,//O,!,"{S-CoA}")
  MCa(0,0.4)(<30,Om,!0,//O,!,!,!,//O,!,Om)
  MCa(0,0.7)(<30,Om,!0,//O,!,!~dr,!,//O,!,Om)
  MCa(0,  1)(<30,Om,!0,//O,!,!,!,//O,!,Om,3:/OH)
  %------------------------------------------------------------------------
  EXT(
    p10:=(.58w,.9h);
    drawarrow p10..p10+(a,0);
    drawarrow p10+(.2a,-.8a){dir90}..{dir 0}(p10+(.5a,0)){dir0}..{dir-90}p10+(.8a,-.5a);
    label.bot("Acetyl-CoA",p10+(.2a,-.8a));
    label.bot("CoA-SH",p10+(.8a,-.5a)+(em,0));
    p10:=(.9w,.83h);
    drawdblarrow p10..p10+(0,-a);
    draw p10+(0,-0.5a){dir -90}..{dir 180}p10+(-0.5a,-.8a);
    label.lft("H_2_O",p10+(-0.5a,-.8a));
    p10:=(.9w,.56h);
    drawdblarrow p10..p10+(0,-a);
    draw p10+(-0.5a,-0.2a){dir 0}..{dir -90}p10+(0,-.5a);
    label.lft("H_2_O",p10+(-0.5a,-.2a));
    p10:=(.9w,.30h);
    drawdblarrow p10..p10+(0,-a);
    drawarrow p10+(-.5a,-.2a){dir 0}..{dir-90}p10+(0,-.5a){dir-90}..{dir180}p10+(-.5a,-.8a);
    label.lft("NAD^+",p10+(-0.5a,-.2a));
    label.lft("NADH2^+",p10+(-0.5a,-.8a));
    p10:=(.73w,0.1h);
    drawarrow p10..p10+(-a,0);
    drawarrow p10+(-0.05w,0){dir -180}..{dir 90}p10+(-0.08w,0.05h);
    label.top("CO_2_",p10+(-0.8a,0.53a));
    p10:=(.40w,.1h);
    drawarrow  p10..p10+(-a,0);
    drawarrow p10+(-.2a,0.8a){dir -90}..p10+(-0.5a,0){dir -180}..
                 {dir 90}p10+(-0.8a,0.5a);
    label.top("NAD^+^,CoA-SH",p10+(em,0.8a));
    label.top("NADH2^+^,CO_2_",p10+(-0.8a-em,0.5a));
    p10:=(.10w,.22h);
    drawdblarrow p10..p10+(0,a);
    drawdblarrow p10+(.5a,.2a){dir-180}..{dir90}p10+(0,.5a){dir90}..{dir0}p10+(.5a,.8a);
    label.rt("GDP,Pi",p10+(0.5a,0.2a));
    label.rt("GTP,CoA-SH",p10+(0.5a,0.8a));
    p10:=(.10w,.5h);
    drawdblarrow p10..p10+(0,a);
    drawdblarrow p10+(.5a,.2a){dir-180}..{dir 90}p10+(0,.5a){dir90}..{dir0}p10+(.5a,.8a);
    label.rt("FAD",p10+(0.5a,0.2a));
    label.rt("FADH2",p10+(0.5a,0.8a));
    p10:=(.10w,.74h);
    drawdblarrow p10..p10+(0,a);
    draw p10+(0.05w,0.2a){dir -180}..{dir 90}p10+(0,.5a);
    label.rt("H_2_O",p10+(0.5a,0.2a));
    p10:=(.25w,.9h);
    drawdblarrow p10..p10+(a,0);
    drawdblarrow p10+(.2a,-.5a){dir90}..{dir0}p10+(.5a,0){dir0}..{dir-90}p10+(.8a,-.8a);
    label.bot("NAD^+",p10+(.2a,-.5a));
    label.bot("NADH2^+",p10+(.8a,-.8a));
  )
  endfont
\end{mplibcode}
%----------------------------------------------------------------------------
\end{document}
