summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/mcf2graph/mcf_mplib_exa.tex
blob: be3e077f28c3449c2da4e41ce2c1dc876d438c8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Example of  MCF typest with LuaLaTeX(luamplib)    by A.Yamaji    2022.02.27
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ** mcf2graph.mp must be version 4.81
% ** use mcf_data_base.mcf
\documentclass{article}
%------------------------------------------------------------------------------
\usepackage{luamplib}%
\usepackage[T1]{fontenc}%
\usepackage{textcomp,verbatim}%
\mplibcodeinherit{enable}%
\mplibverbatim{enable}%
\mplibnumbersystem{double}%
\mpliblegacybehavior{disabled}%
\everymplib{%
  if unknown Ph1: input mcf2graph; fi
  outputformat:="eps";
  sw_output:=Fig+Calc;
  tag1:="J"; tag2:="C"; tag3:="fm"; tag4:="mw"; tag5:="EN"; tag6:="MW";
  max_blength:=4.5mm;
  defaultsize:=8;
  defaultscale:=1;
}%
%------------------------------------------------------------------------------
\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}
%------------------------------------------------------------------------------------
\section{MCF example}
\noindent%
%------------------------------------------------------------------------------------
 use molecular data base file 'mcf\_exa\_data.mcf' \\
{{\tt FM(fm) :} molecular formula (calculated) \\
{{\tt MW(mw) :} molecular weight (calculated)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Erythromycin}
\noindent%
%----------------------------------------------------------------------------
( pass mcf to MC() )
\begin{verbatim}
beginfigm("EN:Erythromycin","MW:733.93")
  fsize:=(120mm,30mm);
  MC(<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',4,6^-35,8,10',12^35}:/*_,
      {6^35,11,12^-35}:*/OH,
      @$3,\*,O,30~zb,|,?6`.7,6:O,#.5,{5~wf,3^35}:/_,4:/*OH,3^-35:/*O!,##,
      @$5,\*^30`1.7,O,!~zb,|,?6`.7,6:O,#.5,5:/*_,2:*/OH,3:/*N?!)
  ext(defaultscale:=0.8; label.lrt("fm: "&cal_FM,(0,h-5mm));
      label.lrt("mw: "&cal_MW,(0,h-9mm)); label.lrt("MW: "&inf_MW,(0,h-13mm));)
endfigm;
\end{verbatim}
%----------------------------------------------------------------------------
\begin{mplibcode}
beginfigm("EN:Erythromycin","MW:733.93")
  fsize:=(120mm,30mm);
  MC(<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',4,6^-35,8,10',12^35}:/*_,
      {6^35,11,12^-35}:*/OH,
      @$3,\*,O,30~zb,|,?6`.7,6:O,#.5,{5~wf,3^35}:/_,4:/*OH,3^-35:/*O!,##,
      @$5,\*^30`1.7,O,!~zb,|,?6`.7,6:O,#.5,5:/*_,2:*/OH,3:/*N?!)
  ext(defaultscale:=0.8; label.lrt("fm: "&cal_FM,(0,h-5mm));
      label.lrt("mw: "&cal_MW,(0,h-9mm)); label.lrt("MW: "&inf_MW,(0,h-13mm));)
endfigm;
\end{mplibcode}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Paclitaxel}
\noindent%
( pass mcf to beginfigm() )
\begin{verbatim}
beginfigm("EN:Paclitaxel","MW:853.918",
  %---------------------------------------------------------------------
  ": ?6,5=dl,@3,#1,36,45,45,45,45,##,&5,-4=?6,-4=?4,-1=wb,-3=wf,-1:O, ",
  ": 4:??,6:/_,{3^-60,15}:*/OH,8:/*H^-60,9:*/_^60,10://O,             ",
  ": @1,\,O,!,//O,!,*/OH,!,/Ph,60~wf,NH,-60,//O,60,Ph,                ",
  ": @7,\*,O,-45,//O,60,Ph,11:*/OCO!>rl,12:/*OCO!^-15>lr              ")
  %---------------------------------------------------------------------
  fsize:=(140mm,30mm);
  if check(mc)=0:       MCat(0,0.5)(scantokens(mc))
    sw_numbering:=Atom; MCat(0.6,0.5)(scantokens(mc))
    sw_numbering:=Bond; MCat(1,0.5)(scantokens(mc))
  fi
endfigm
\end{verbatim}
%----------------------------------------------------------------------------
\begin{mplibcode}
beginfigm("EN:Paclitaxel","MW:853.918",
  %---------------------------------------------------------------------
  ": ?6,5=dl,@3,#1,36,45,45,45,45,##,&5,-4=?6,-4=?4,-1=wb,-3=wf,-1:O, ",
  ": 4:??,6:/_,{3^-60,15}:*/OH,8:/*H^-60,9:*/_^60,10://O,             ",
  ": @1,\,O,!,//O,!,*/OH,!,/Ph,60~wf,NH,-60,//O,60,Ph,                ",
  ": @7,\*,O,-45,//O,60,Ph,11:*/OCO!>rl,12:/*OCO!^-15>lr              ")
  %---------------------------------------------------------------------
  fsize:=(140mm,30mm);
  if check(mc)=0:       MCat(0,0.5)(scantokens(mc))
    sw_numbering:=Atom; MCat(0.6,0.5)(scantokens(mc))
    sw_numbering:=Bond; MCat(1,0.5)(scantokens(mc))
  fi
endfigm
\end{mplibcode}
%----------------------------------------------------------------------------
\newpage
\subsection{Chlorophyll a}
\noindent%
( read data-base file )
\begin{verbatim}
beginfigm("f:mcf_data_base.mcf","t:EN","v:Chlorophyll a","NO:-")
  sw_output:=Fig+Calc+Mcode;                 %%%% output temp-mc.aux %%%%
  fsize:=(100mm,30mm);
  if check(mc)=0:
    MC(scantokens(mc))
    VerbatimTeX("\gdef\EN{"&inf_EN&"}\gdef\MW{"&inf_MW&"}");
    VerbatimTeX("\gdef\mw{"&cal_MW&"}\gdef\fm{"&cal_FM&"}");
  fi
endfigm
\end{mplibcode}
\verbatiminput{temp-mc.aux}            %%%% input temp-mc.aux %%%%
{\tt ** EN:\EN \quad mw:\MW \quad MW:\mw \quad fm:\fm}%
\end{verbatim}
%------------------------------------------------------------------------------------
\begin{mplibcode}
beginfigm("f:mcf_data_base.mcf","t:EN","v:Chlorophyll a","NO:-")
  sw_output:=Fig+Calc+Mcode; fsize:=(100mm,30mm);
  if check(mc)=0:
    MC(scantokens(mc))
    VerbatimTeX("\gdef\EN{"&inf_EN&"}\gdef\MW{"&inf_MW&"}");
    VerbatimTeX("\gdef\mw{"&cal_MW&"}\gdef\fm{"&cal_FM&"}");
  fi
endfigm
\end{mplibcode}
\verbatiminput{temp-mc.aux}            %%%% input temp-mc.aux %%%%
{\tt ** EN:\EN \quad mw:\MW \quad MW:\mw \quad fm:\fm}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Dinophysistoxin-1}
\noindent%
( read data-base file + pass mcf to beginfigm() )
\begin{verbatim}
beginfigm("t:EN","v:Okadaic acid","EN:Dinophysistoxin-1",
          "MW:819",":,38:*/_,65=red")  %%%% add methyl group (color red) %%%%
  sw_output:=Fig+Calc+Mcode;           %%%% output temp-mc.aux %%%%
  fsize:=(120mm,20mm);
  if check(mc)=0: MC(scantokens(mc))
    VerbatimTeX("\gdef\EN{"&inf_EN&"}\gdef\MW{"&inf_MW&"}");
    VerbatimTeX("\gdef\mw{"&cal_MW&"}\gdef\fm{"&cal_FM&"}");
  fi
endfigm;
\end{mplibcode}
\verbatiminput{temp-mc.aux}            %%%% input temp-mc.aux %%%%
{\tt ** EN:\EN \quad mw:\MW \quad MW:\mw \quad fm:\fm}%
\end{verbatim}
%----------------------------------------------------------------------------
\begin{mplibcode}
beginfigm("t:EN","v:Okadaic acid","EN:Dinophysistoxin-1",
          "MW:819",":,38:*/_,65=red")  %%%% add methyl group (color red) %%%%
  sw_output:=Fig+Calc+Mcode;           %%%% output temp-mc.aux %%%%
  fsize:=(120mm,20mm);
  if check(mc)=0: MC(scantokens(mc))
    VerbatimTeX("\gdef\EN{"&inf_EN&"}\gdef\MW{"&inf_MW&"}");
    VerbatimTeX("\gdef\mw{"&cal_MW&"}\gdef\fm{"&cal_FM&"}");
  fi
endfigm;
\end{mplibcode}
\verbatiminput{temp-mc.aux}            %%%% input temp-mc.aux %%%%
{\tt ** EN:\EN \quad mw:\MW \quad MW:\mw \quad fm:\fm}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage
%----------------------------------------------------------------------------
\subsection{Maitotoxin}
\noindent%
( read data-base file )
%--------------------------------------------------------------------------------
\begin{verbatim}
%--------------------------------------------------------------------------------
\begin{mplibcode}
  beginfigm("t:EN","v:Maitotoxin")
    sw_output:=Fig+Calc+Mcode;         %%%% output temp-mc.aux %%%%
    fsize:=(120mm,60mm); fmargin:=(0,3mm); sw_frame:=Outside;
    if check(mc)=0: MC(scantokens(mc))
      VerbatimTeX("\gdef\EN{"&inf_EN&"}\gdef\MW{"&inf_MW&"}");
      VerbatimTeX("\gdef\mw{"&cal_MW&"}\gdef\fm{"&cal_FM&"}");
    fi
  endfigm
\end{mplibcode}
\verbatiminput{temp-mc.aux}            %%%% input temp-mc.aux %%%%
{\tt ** EN:\EN \quad mw:\MW \quad MW:\mw \quad fm:\fm}%
%--------------------------------------------------------------------------------
\end{verbatim}
%--------------------------------------------------------------------------------
\begin{mplibcode}
  beginfigm("t:EN","v:Maitotoxin")
    sw_output:=Fig+Calc+Mcode;
    fsize:=(120mm,60mm); fmargin:=(0,3mm); sw_frame:=Outside;
    if check(mc)=0: MC(scantokens(mc))
      VerbatimTeX("\gdef\EN{"&inf_EN&"}\gdef\MW{"&inf_MW&"}");
      VerbatimTeX("\gdef\mw{"&cal_MW&"}\gdef\fm{"&cal_FM&"}");
    fi
  endfigm
\end{mplibcode}
\verbatiminput{temp-mc.aux}
{\tt ** EN:\EN \quad mw:\MW \quad MW:\mw \quad fm:\fm}%
%--------------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage
\subsection{TCA cycle}
\noindent%
\begin{mplibcode}
beginfigm("EN:TCA cycle")
fsize:=(160mm,75mm);
max_blength:=5mm;
%--------------------------------------------------------------------------------
COOH:='(//O,!,OH);
HOCO:='(OH,!,//O,);
MCat(0.33,   1)(<30,HOCO,!,//O,!2,COOH)                    % Oxaloacetate
MCat(0.66,   1)(<30,HOCO,!4,COOH,@-4`1,\,COOH,4:/OH^-165)  % Citrate
MCat(1,      1)(<30,HOCO,!2,!~dr,!,COOH,@-4`1,\,COOH)      % cis-Aconitate
MCat(1,   0.58)(<30,HOCO,!4,COOH,@-4,\`1,COOH,5:/OH)       % Isocitrate
MCat(1,   0.05)(<30,HOCO,!3,//O,!,COOH,@-4,\`1,COOH)       % Oxalosuccinate
MCat(0.66,0.05)(<30,HOCO,!3,//O,!,COOH)                    % alfa-Ketoglutarate
MCat(0.33,0.05)(<30,HOCO,!3,//O,!,"{S-CoA}")               % Succinyl-CoA
MCat(0,   0.05)(<30,HOCO,!3,COOH)                          % Succinate
MCat(0,   0.55)(<30,HOCO,!,!~dr,!,COOH)                    % Fumarate
MCat(0,      1)(<30,HOCO,!3,COOH,3:/OH)                    % L-Malate
%--------------------------------------------------------------------------------
ext(
defaultfont:="uhvr8r";
defaultscale:=0.75;
ext_setup;
def sel_dir(expr rot)=
  save tx; nA:=rot; if nA>=360: nA:=nA-360; fi
  if     (nA<30)or(nA>330):   def tx=top enddef; elseif (nA>=30)and(nA<=150):  def tx=lft enddef;
  elseif (nA>150)and(nA<210): def tx=bot enddef; elseif (nA>=210)and(nA<=330): def tx=rt enddef; fi
enddef;
def reaction_arrow(expr a)(expr r)(expr p)(expr sa,la)(expr sb,lb)(expr sc,lc)(expr sd,ld)=
  drawarrow ((0,0)..(a,0)) rotated r shifted p;
  if sa<>"": draw ((0.5a,0){dir 180}..{dir 90}(0,.5a*la)) rotated r shifted p;
             sel_dir(r); label.tx(sa,p+((0,0.5a*la) rotated r)); fi
  if sb<>"": draw ((0.5a,0){dir 0}..{dir 90}(a,.5a*lb)) rotated r shifted p;
             sel_dir(r); label.tx(sb,p+((a,0.5a*lb) rotated r)); fi
  if sc<>"": draw ((0.5a,0){dir 180}..{dir -90}(0,-.5a*lc)) rotated r shifted p;
             sel_dir(r+180); label.tx(sc,p+((0,-0.5a*lc) rotated r)); fi
  if sd<>"": draw ((0.5a,0){dir 0}..{dir -90}(a,-.5a*ld)) rotated r shifted p;
             sel_dir(r+180); label.tx(sd,p+((a,-0.5a*ld) rotated r)); fi
enddef;
def r_arrow(expr a)(expr r)(expr p)(expr sc,lc)(expr sd,ld)=
   reaction_arrow(a)(r)(p)("",0)("",0)(sc,lc)(sd,ld)
enddef;
%------------------------------------------------------------------------
save dx; pair dx; dx:=(12mm,0);
label.bot("Oxaloacetate",p1+dx);   label.bot("Citrate",p2+dx);
label.bot("cis-Aconitate",p3+dx);  label.bot("Isocitrate",p4+dx);
label.bot("Oxalosuccinate",p5+dx); label.bot("alfa-Ketoglutarate",p6+dx);
label.bot("Succinyl-CoA",p7+dx);   label.bot("Succinate",p8+dx);
label.bot("Fumarate",p9+dx);       label.bot("L-Malate",p10+dx);
sw_label_emu:=1;
ext_setup;
r_arrow(10mm)(  0)(p1+ ( 1.1w1, 0.3h1))("Acetyl-CoA",1.5)(" CoA-SH",1);
r_arrow(10mm)(  0)(p2+ ( 1.1w2, 0.4h2))("",0)("H2O",1);
r_arrow( 8mm)(270)(p3+ ( 0.5w3,-0.4h3))("H2O",1)("",0);
r_arrow( 8mm)(270)(p4+ ( 0.5w4,-0.4h4))("NAD+",1)("NADH2+",1);
r_arrow(10mm)(180)(p5+ (-0.1w5, 0.4h5))("",0)("CO2",1);
r_arrow(10mm)(180)(p6+ (-0.1w6, 0.5h6))("NAD+,CoA-SH",1.7)("NADH2+,CO2",1);
r_arrow(10mm)(180)(p7+ (-0.1w7, 0.5h7))("GDP,Pi",1.7)("GTP,CoA-SH",1);
r_arrow( 8mm)( 90)(p8+ ( 0.4w8, 1.2h8))("FAD",1)("FADH2",1);
r_arrow( 8mm)( 90)(p9+ ( 0.4w9, 1.2h9))("H2O",1)("",0);
r_arrow(10mm)(  0)(p10+( 1.1w10,0.3h10))("NAD+",1)("NADH2+",1.5);
defaultscale:=1.5;
label("TCA-cycle",(0.5w,0.5h));
)
endfigm
\end{mplibcode}
%------------------------------------------------------------------------
\begin{verbatim}
beginfigmy"EN:TCA cycle")
fsize:=(160mm,75mm);
max_blength:=5mm;
COOH:='(//O,!,OH);
HOCO:='(OH,!,//O,);
MCat(0.33,   1)(<30,HOCO,!,//O,!2,COOH)                    % Oxaloacetate
MCat(0.66,   1)(<30,HOCO,!4,COOH,@-4`1,\,COOH,4:/OH^-165)  % Citrate
MCat(1,      1)(<30,HOCO,!2,!~dr,!,COOH,@-4`1,\,COOH)      % cis-Aconitate
MCat(1,   0.58)(<30,HOCO,!4,COOH,@-4,\`1,COOH,5:/OH)       % Isocitrate
MCat(1,   0.05)(<30,HOCO,!3,//O,!,COOH,@-4,\`1,COOH)       % Oxalosuccinate
MCat(0.66,0.05)(<30,HOCO,!3,//O,!,COOH)                    % alfa-Ketoglutarate
MCat(0.33,0.05)(<30,HOCO,!3,//O,!,"{S-CoA}")               % Succinyl-CoA
MCat(0,   0.05)(<30,HOCO,!3,COOH)                          % Succinate
MCat(0,   0.55)(<30,HOCO,!,!~dr,!,COOH)                    % Fumarate
MCat(0,      1)(<30,HOCO,!3,COOH,3:/OH)                    % L-Malate
ext(
defaultfont:="uhvr8r";
defaultscale:=0.75;
ext_setup;
save dx; pair dx; dx:=(12mm,0);
label.bot("Oxaloacetate",p1+dx);   label.bot("Citrate",p2+dx);
label.bot("cis-Aconitate",p3+dx);  label.bot("Isocitrate",p4+dx);
label.bot("Oxalosuccinate",p5+dx); label.bot("alfa-Ketoglutarate",p6+dx);
label.bot("Succinyl-CoA",p7+dx);   label.bot("Succinate",p8+dx);
label.bot("Fumarate",p9+dx);       label.bot("L-Malate",p10+dx);
sw_label_emu:=1;
ext_setup;
r_arrow(10mm)(  0)(p1+ ( 1.1w1, 0.3h1))("Acetyl-CoA",1.5)(" CoA-SH",1);
r_arrow(10mm)(  0)(p2+ ( 1.1w2, 0.4h2))("",0)("H2O",1);
r_arrow( 8mm)(270)(p3+ ( 0.5w3,-0.4h3))("H2O",1)("",0);
r_arrow( 8mm)(270)(p4+ ( 0.5w4,-0.4h4))("NAD+",1)("NADH2+",1);
r_arrow(10mm)(180)(p5+ (-0.1w5, 0.4h5))("",0)("CO_2_",1);
r_arrow(10mm)(180)(p6+ (-0.1w6, 0.5h6))("NAD+,CoA-SH",1.7)("NADH2+,CO2",1);
r_arrow(10mm)(180)(p7+ (-0.1w7, 0.5h7))("GDP,Pi",1.7)("GTP,CoA-SH",1);
r_arrow( 8mm)( 90)(p8+ ( 0.4w8, 1.2h8))("FAD",1)("FADH2",1);
r_arrow( 8mm)( 90)(p9+ ( 0.4w9, 1.2h9))("H2O",1)("",0);
r_arrow(10mm)(  0)(p10+( 1.1w10,0.3h10))("NAD+",1)("NADH2+",1.5);
defaultscale:=1.5;
label("TCA-cycle",(0.5w,0.5h));
)
endfigm
\end{verbatim}
%----------------------------------------------------------------------------
\end{document}