summaryrefslogtreecommitdiff
path: root/graphics/mcf2graph/mcf2graph.mf
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/mcf2graph/mcf2graph.mf')
-rw-r--r--graphics/mcf2graph/mcf2graph.mf436
1 files changed, 249 insertions, 187 deletions
diff --git a/graphics/mcf2graph/mcf2graph.mf b/graphics/mcf2graph/mcf2graph.mf
index 0ebece8405..4a3f4a766a 100644
--- a/graphics/mcf2graph/mcf2graph.mf
+++ b/graphics/mcf2graph/mcf2graph.mf
@@ -1,5 +1,5 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% mcf2graph ver 4.57 Copyright (c) 2013-2021 Akira Yamaji
+% mcf2graph ver 4.58 Copyright (c) 2013-2021 Akira Yamaji
%
% Permission is hereby granted, free of charge, to any person obtaining a copy of this software
% and associated documentation files (the "Software"), to deal in the Software without restriction,
@@ -37,29 +37,55 @@
% Set to use plain.mp (label,arrow,atom) : mpost -s labeloffset=2 FILENAME
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tracingstats:=1;
-message "* This is mcf2graph ver 4.57 2021.02.11";
+message "* This is mcf2graph ver 4.58 2021.02.21";
%-------------------------------------------------------------------------------------------------
newinternal cntA,cntB,cntM,minX,minY,maxX,maxY,sftX,sftY,com,par,envT,envB,lenT,lineT,angT,rotT,
- crR,nA,nB,nC,nD,nE,nF,nN,nP,nU,nP,nL,nR,nS,nW,xpos,ypos,markA,markB,saveA,saveB,bondL;
+ crR,nA,nB,nC,nD,nE,nF,nS,nL,nR,nU,nP,xpos,ypos,markA,markB,saveA,saveB,bondL;
numeric save_num[],comD[][],parD[][],adrD[][],cntD[],tbl_atom[],tbl_group[][],f_char[],
tbl_atom_wt[],tbl_atom_mi[],tbl_char_wd[],tbl_char_ht[],addA[],add_rot[],chargeA[],
com_group[][],par_group[][],cnt_group[],colorA[],colorB[],sumA[],bondC[],hideH[],
lineB[],sB[],eB[],angB[],angA[],lenB[],angX[],numS[],wdM[],htM[],wdA[],dxA[];
-string info[],save_str[],tbl_atom_str[],strD[],tag[],out_file_name,out_file_aux,
- out_file_rep,out_file_mpc,aux_delimiter,atomfont,mpfont,s_tag,s_var,
- cal_FM,cal_MW,cal_MI,inf_NO,inf_EN,inf_JN,inf_FM,inf_CAS,inf_USE,inf_EXA,inf_EXB,inf_MW;
+string info[],mc[],save_str[],tbl_atom_str[],strD[],tag[],out_file_name,out_file_aux,
+ out_file_rep,out_file_mpc,aux_delimiter,atomfont,mpfont,s_tag,s_var,cal_FM,cal_MW,cal_MI,
+ inf_NO,inf_EN,inf_JN,inf_FM,inf_CAS,inf_USE,inf_EXA,inf_EXB,inf_MW,mc,blank_str;
pair save_pair[],posA[],posM[][],msize,mposition,fsize,fmargin,save_mposition,posBs,posBe;
picture mol_stru[],atom_picture,save_picture,temp_picture;
path arrow_path,dottedline_path,line_path,arrow_head;
%-------------------------------------------------------------------------------------------------
char_num:=str_cnt:=tbl_cnt:=proc_end:=mangle:=sw_calc:=sw_ext_all:=0;
sw_numberA:=sw_numberB:=sw_aux_out:=sw_expand:=sw_fframe:=sw_mframe:=sw_aframe:=sw_trimming:=0;
-sw_rep_out:=sw_mol_out:=sw_group_off:=sw_single:=sw_arrow_emu:=0;
+sw_rep_out:=sw_mol_out:=sw_group_off:=sw_single:=sw_arrow_emu:=sw_indent_off:=0;
numberA_start:=numberB_start:=1; numberA_end:=numberB_end:=4095;
%-------------------------------------------------------------------------------------------------
aux_max:=max_inf_num:=20;
aux_delimiter:=";";
for i=1 upto aux_max: tag[i]:=""; endfor
+blank_str:= " ";
+%-------------------------------------------------------------------------------------------------
+a_paren_s:=ASCII("("); a_paren_e:=ASCII(")"); a_brace_s:=ASCII("{"); a_brace_e:=ASCII("}");
+a_bracket_s:=ASCII("["); a_bracket_e:=ASCII("]"); a_comma:=ASCII(","); a_equal:=ASCII("=");
+a_colon:=ASCII(":"); a_atmark:=ASCII("@"); a_zero:=ASCII("0"); a_nine:=ASCII("9");
+%--------------------------------------------------------------------------------------------------
+let DIV= /; let MUL= *; let LT= <; let GT= >; let AND= &; let :: = : ; let == = =; let ef=elseif;
+def ]]]=] ] ] enddef;
+%--------------------------------------------------------------------------------------------------
+primarydef a at b = fat(a,b) enddef;
+def fat(expr a,b)= mposition:=b; a enddef;
+def ext(text TXT)= sw_ext_all:=1; def EXT_ALL = TXT enddef; enddef;
+def ext_clear= sw_ext_all:=0; def EXT_ALL = enddef; enddef;
+%--------------------------------------------------------------------------------------------------
+vardef iif(expr a,b,c)=if a: b else: c fi enddef;
+vardef subc(expr i,s)= substring(i-1,i) of s enddef;
+vardef sfrt(expr a,b,c)= a shifted ((b,0) rotated c) enddef;
+def wpcs expr n= withpen pencircle scaled n enddef;
+def ppcs expr n= pickup pencircle scaled n enddef;
+def sbp(expr m,n)expr p=subpath(m*length(p),n*length(p)) of p enddef;
+%-------------------------------------------------------------------------------------------------
+vardef fsr(expr n)(expr s)= (substring(0,n-length(s)) of blank_str)&s enddef;
+vardef fsl(expr n)(expr s)= s&(substring(0,n-length(s)) of blank_str) enddef;
+vardef fdr(expr n)(expr s)= fsr(n)(decimal(s)) enddef;
+vardef fdl(expr n)(expr s)= fsl(n)(decimal(s)) enddef;
+def warning(expr s)= message "% "&decimal(char_num)&fdr(3)(incr warning_cnt)&")"&s; enddef;
%=================================================================================================
if (known green)and(known ahlength):
f_MP:=1;
@@ -74,8 +100,8 @@ if (known green)and(known ahlength):
def out_file_mol= jobname&"-"&fit_zero(char_num)&"-"&inf_EN&".mol" enddef;
%--default ahangle=45---------------------------------------------------------------------
if ahangle=0: outputformat:="eps"; % eps format(.mps)
- elseif ahangle=1: outputformat:="png"; hppp:=vppp:=0.12; % png format(600dpi)
elseif ahangle=11: outputformat:="png"; hppp:=vppp:=0.24; % png format(300dpi)
+ elseif ahangle=1: outputformat:="png"; hppp:=vppp:=0.12; % png format(600dpi)
elseif ahangle=12: outputformat:="png"; hppp:=vppp:=0.10; % png format(720dpi)
elseif ahangle=13: outputformat:="png"; hppp:=vppp:=0.06; % png format(1200dpi)
elseif ahangle=14: outputformat:="png"; hppp:=vppp:=0.04; % png format(1800dpi)
@@ -154,13 +180,6 @@ if f_MP=1:
message "* defaultfont="&defaultfont;
fi
%--------------------------------------------------------------------------------------------------
-let DIV= /; let MUL= *; let LT= <; let GT= >; let AND= &; let :: = : ; let == = =; let ef=elseif;
-%--------------------------------------------------------------------------------------------------
-primarydef a at b = fat(a,b) enddef;
-def fat(expr a,b)= mposition:=b; a enddef;
-def ext(text TXT)= sw_ext_all:=1; def EXT_ALL = TXT enddef; enddef;
-def ext_clear= sw_ext_all:=0; def EXT_ALL = enddef; enddef;
-%--------------------------------------------------------------------------------------------------
?3:=?20:=Ph:=Ph1:=Ph2:=hz:=0; vt:=1;
ratio_chain_ring:=0.66; ratio_atom_bond:=0.36; ratio_thickness_bond:=0.015;
ratio_thickness_char:=0.1; ratio_char_bond:=1.5; ratio_bondgap_bond:=0.15;
@@ -190,14 +209,14 @@ parts_int_start:=3000; % 3001 => 4000 for internal parts (max 1000)
def def_com(expr n)(text tx)= nA:=n; forsuffixes list=tx:: list:=nA; nA:=nA+1; endfor enddef;
def_com(-4090)(_com,_jp_atom,_jp_absA,_jp_bond,_cyc,_cyc_sB,_cyc_eB,_set_line,_tmp_line,
_chg_len,_get_len,_ring_len,_tmp_len,_rot_ang,_adj_ang,_chg_env,_tmp_env,_set_colorA,_set_colorB,
- _group_si,_set_adr,_mk_bond,_set_atom,_arg_ang,_chg_atom,_tmp_rot,_fuse,_size_atom,_numeric,
+ _group_si,_set_adr,_mk_bond,_set_atom,_arrange_ang,_chg_atom,_tmp_rot,_fuse,_size_atom,_numeric,
_jump_at,_set_add,_chg_add,_nop,_mark,_moff,_term,_len_s,_len_e,_len_ss,_len_ee,
_group_s,_group_e,_rest,_charge,
- si,dl,dr,db,dm,tm,wf,wb,bd,bz,zf,zb,dt,wv,nl,vf,vb,nb,si_,dl_,dr_,dm_,wf_,wb_,zf_,zb_,wv_,bd_);
+ si,dl,dl_,dr,dr_,db,dm,dm_,tm,wf,wb,bd,bz,zf,zb,dt,wv,nl,vf,vb,nb,si_,wf_,wb_,zf_,zb_,wv_,bd_);
%--------------------------------------------------------------------------------------------------
def parameter_list=
sw_rep_out,sw_numberA,sw_numberB,sw_mframe,sw_aux_out,sw_expand,sw_mol_out,sw_calc,
- sw_single,sw_ext_all,sw_aframe,sw_fframe,sw_group_off,sw_trimming,sw_arrow_emu,
+ sw_single,sw_ext_all,sw_aframe,sw_fframe,sw_group_off,sw_trimming,sw_arrow_emu,sw_indent_off,
ratio_atom_bond,ratio_thickness_bond,ratio_char_bond,ratio_chain_ring,ratio_bondgap_bond,
ratio_zebra_black,ratio_zebragap_bond,ratio_thickness_char,ratio_wedge_bond,ratio_atomgap_atom,
lonepairdiam,lonepairspace,blength,offset_atom,offset_wedge,max_blength,offset_zebra_gap,
@@ -207,14 +226,6 @@ def parameter_list=
Me,Et,CH3,NH,NH2,NO,NO2,OH,CHO,COOH,CN,SH,!CH3,!NH2,!NO2,!OH,!CHO,!COOH,!CN,!SH
enddef;
%--------------------------------------------------------------------------------------------------
-def ]]]=] ] ] enddef;
-vardef iif(expr a,b,c)=if a: b else: c fi enddef;
-vardef subc(expr i,s)= substring(i,i+1) of s enddef;
-vardef sfrt(expr a,b,c)= a shifted ((b,0) rotated c) enddef;
-def wpcs expr n= withpen pencircle scaled n enddef;
-def ppcs expr n= pickup pencircle scaled n enddef;
-def sbp(expr m,n)expr p=subpath(m*length(p),n*length(p)) of p enddef;
-%--------------------------------------------------------------------------------------------------
def init_par(text t)=
nA:=nB:=nC:=0;
for list=t:
@@ -247,29 +258,42 @@ enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def beginfont(text s)=
begingroup
- save ',f_beginchar,f_ext,blen,ext,add,ang_br;
+ save ',f_beginchar,f_ext,blen,ext,add,ang_br,s_fw,s_bw,s_len,at_colon;
%------------------------------------------------------------------------------------------------
def ext=ext_to_font enddef;
def add=add_to_molecule enddef;
- vardef '(text TXT)== read_mcf(incr parts_cnt)((_com,_mark),TXT,(_com,_rest)); parts_cnt enddef;
+ def '=read_ud enddef;
%------------------------------------------------------------------------------------------------
inf_NO:=inf_EN:=inf_JN:=inf_MW:=inf_FM:=inf_CAS:=inf_USE:=inf_EXA:=inf_EXB:="-";
- cal_MW:=cal_MI:=cal_FM:="";
+ mc:=cal_MW:=cal_MI:=cal_FM:="";
%------------------------------------------------------------------------------------------------
parts_cnt:=parts_usr_start;
parts_int:=parts_int_start;
%------------------------------------------------------------------------------------------------
char_num:=char_num+1;
store_par(parameter_list);
- for i:=1 upto max_inf_num: info[i]:=":"; endfor
- f_ext:=inf_num:=cntM:=0;
+ for i:=1 upto max_inf_num: info[i]:=":"; mc[i]:=""; endfor
+ f_ext:=inf_num:=cntM:=mc_low:=0;
for list=s: inf_num:=inf_num+1; info[inf_num]:=list; endfor
%------------------------------------------------------------------------------------------------
for j=1 upto inf_num:
- nA:=0; for i=0 upto length(info[j]): if subc(i,info[j])=":": nA:=i; fi exitif nA>0; endfor
- if nA>0:
- s_tag:=substring (0,nA) of info[j];
- s_var:=substring (nA+1,length(info[j])) of info[j];
+ at_colon:=0;
+ for i=1 upto 9: if subc(i,info[j])=":": at_colon:=i; fi exitif at_colon>0; endfor
+ s_len:=length(info[j]);
+ if at_colon=1:
+ s_fw:=0; for k=2 upto s_len: if subc(k,info[j])<>" ": s_fw:=k; fi exitif s_fw>0; endfor
+ s_bw:=0; for k=s_len downto 2: if subc(k,info[j])<>" ": s_bw:=k; fi exitif s_bw>0; endfor
+ mc_low:=mc_low+1;
+ if sw_indent_off=0:
+ mc[mc_low]:=substring (2,s_len) of info[j];
+ mc:=mc&substring (s_fw-1,s_bw) of info[j];
+ else:
+ mc[mc_low]:=substring (s_fw-1,s_len) of info[j];
+ mc:=mc&mc[mc_low];
+ fi
+ ef at_colon>=1:
+ s_tag:=substring (0,at_colon-1) of info[j];
+ s_var:=substring (at_colon,s_len) of info[j];
if known scantokens("inf_"&s_tag): scantokens("inf_"&s_tag):=s_var; fi
fi
endfor
@@ -278,35 +302,46 @@ def beginfont(text s)=
enddef;
%==================================================================================================
def endfont=
- if sw_ext_all=1: ext_to_font(EXT_ALL); fi
- if sw_trimming>=1:
- nA:=nC:=4095; nB:=nD:=-4095;
- for i=1 upto cntM:
- if xpart(posM[1][i])<nA: nA:=xpart(posM[1][i]); fi
- if xpart(posM[2][i])>nB: nB:=xpart(posM[2][i]); fi
- if ypart(posM[1][i])<nC: nC:=ypart(posM[1][i]); fi
- if ypart(posM[2][i])>nD: nD:=ypart(posM[2][i]); fi
- endfor
- font_wd:=nB-nA+2margin_lr;
- font_ht:=nD-nC+2margin_tb;
- fsize:=(font_wd,font_ht);
+ if cntM>=1:
+ %-----------------------------------------------------------------------------------------
+ if sw_ext_all=1: ext_to_font(EXT_ALL); fi
+ if sw_trimming>=1:
+ nA:=nC:=4095; nB:=nD:=-4095;
+ for i=1 upto cntM:
+ if xpart(posM[1][i])<nA: nA:=xpart(posM[1][i]); fi
+ if xpart(posM[2][i])>nB: nB:=xpart(posM[2][i]); fi
+ if ypart(posM[1][i])<nC: nC:=ypart(posM[1][i]); fi
+ if ypart(posM[2][i])>nD: nD:=ypart(posM[2][i]); fi
+ endfor
+ font_wd:=nB-nA+2margin_lr;
+ font_ht:=nD-nC+2margin_tb;
+ fsize:=(font_wd,font_ht);
+ for i=1 upto cntM:
+ posM[0][i]:=posM[0][i]+(margin_lr-nA,margin_tb-nC);
+ posM[1][i]:=posM[1][i]+(margin_lr-nA,margin_tb-nC);
+ endfor
+ fi
+ %----------------------------------------------------------------------------------------
+ if f_MP=0: beginchar(char_num,font_wd/bp*bp#,font_ht/bp*bp#,0)
+ else: beginfig(char_num) w:=charwd:=font_wd; h:=charht:=font_ht; chardp:=0;
+ fi
+ if (sw_fframe=1)or(sw_fframe=3): ext(draw_frame((0,0),w,h,thickness_fframe);) fi
+ if (sw_fframe=2)or(sw_fframe=3): ext(draw_frame(p0,w0,h0,thickness_fframe);) fi
+ if sw_fframe=4: ext(draw_corner((0,0),w,h,0.2bp);) fi
for i=1 upto cntM:
- posM[0][i]:=posM[0][i]+(margin_lr-nA,margin_tb-nC);
- posM[1][i]:=posM[1][i]+(margin_lr-nA,margin_tb-nC);
+ addto currentpicture also mol_stru[i] shifted posM[0][i]; mol_stru[i]:=nullpicture;
+ if sw_mframe=1: ext(draw_frame(p[i],w[i],h[i],thickness_mframe)) fi
endfor
+ if f_ext=1: addto currentpicture also mol_stru[0]; mol_stru[0]:=nullpicture; fi
+ %-----------------------------------------------------------------------------------------
+ else:
+ font_wd:=xpart(fsize); font_ht:=ypart(fsize);
+ if f_MP=0: beginchar(char_num,font_wd/bp*bp#,font_ht/bp*bp#,0)
+ else: beginfig(char_num) w:=charwd:=font_wd; h:=charht:=font_ht;
+ fi
+ draw (0,h)--(0,0)--(w,0)--(w,h)--(0,h)--(w,0) wpcs 0.2bp;
fi
- %-----------------------------------------------------------------------------------------------
- if f_MP=0: beginchar(char_num,font_wd/bp*bp#,font_ht/bp*bp#,0)
- else: beginfig(char_num) w:=charwd:=font_wd; h:=charht:=font_ht; chardp:=0;
- fi
- if (sw_fframe=1)or(sw_fframe=3): ext(draw_frame((0,0),w,h,thickness_fframe);) fi
- if (sw_fframe=2)or(sw_fframe=3): ext(draw_frame(p0,w0,h0,thickness_fframe);) fi
- if sw_fframe=4: ext(draw_corner((0,0),w,h,0.2bp);) fi
- for i=1 upto cntM:
- addto currentpicture also mol_stru[i] shifted posM[0][i]; mol_stru[i]:=nullpicture;
- if sw_mframe=1: ext(draw_frame(p[i],w[i],h[i],thickness_mframe)) fi
- endfor
- if f_ext=1: addto currentpicture also mol_stru[0]; mol_stru[0]:=nullpicture; fi
+ %-----------------------------------------------------------------------------------------
endchar;
clearit;
restore_par(parameter_list);
@@ -321,28 +356,36 @@ enddef;
def set_def_MC=
save /,//,/*,*/,**,*/*,~,^,',`,<,>,&,:,=,\,\\,*\,\*,*\*,@,$,&,#,##,{,},|,||,_,inside_def_MC;
inside_def_MC:=1;
- _:=Me;
- tertiarydef a=b == if (known a)and(known b):: change_bond(a,b) else:: _nop fi enddef;
- tertiarydef a:b == if (known a)and(known b):: change_atom(a,b) else:: _nop fi enddef;
- def { == read_number( enddef; let } == ); def <primary n == (_rot_ang,n) enddef;
- tertiarydef a^b == if known b:: (_tmp_rot,b),a else:: _nop,a fi enddef;
- tertiarydef a`b == if known b:: (_tmp_len,b),a else:: _nop,a fi enddef;
- tertiarydef a~b == if known b:: (_tmp_line,b),a else:: _nop,a fi enddef;
- tertiarydef a>b == if known b:: (_tmp_env,b),a else:: _nop,a fi enddef;
- def @primary n == (_jp_atom,n) enddef; def &primary n == (_cyc,n) enddef;
- def \ == 0 enddef; def \\ == \~dm enddef; def *\ == \~wf enddef; def \* == \~zf enddef;
- def *\* == \~wv enddef;
- def | == (_com,_mark) enddef; def || == (_com,_moff) enddef;
- def #primary n == (_com,_len_s),(_chg_len,n) enddef; def ## == (_com,_len_e) enddef;
- def /secondary n == if known n:: (_group_si,n) else:: _nop fi enddef;
- def //secondary n == /n~dm enddef; def */secondary n == /n~wf enddef;
- def /*secondary n == /n~zf enddef; def */*secondary n == /n~wv enddef;
- def **secondary n == /n~nb enddef; vardef $primary a == a-4095 enddef;
- vardef '(text TXT)==read_mcf(incr parts_cnt)(|,#crR,TXT,##,(_com,_rest)); parts_cnt enddef;
+ pair |,||,##;
+ | :=(_com,_mark); || := (_com,_moff); ##:=(_com,_len_e);
+ _:=Me; \:=0; \\:=zero_dm; *\:=zero_wf; \*:=zero_zf; *\*:=zero_wv;
+ let = ==op_equ; let : ==op_col; let ^ ==op_hat; let ~ ==op_til; let > ==op_lt; let ` ==op_bq;
+ def { == read_number( enddef; let } == ); def '==read_id enddef;
+ def < == rot_angle enddef; def @ == jump_atom enddef; def & == cyc_atom enddef;
+ def # == chg_length enddef; def $ == abs_adress enddef;
+ def / == group_si enddef; def // == group_dm enddef; def */ == group_wf enddef;
+ def /* == group_zf enddef; def */* == group_wv enddef; def ** == group_nb enddef;
enddef;
%-------------------------------------------------------------------------------------------------
-def CP == com_par enddef; def CPe == com_par_ex(0) enddef; def CPx == com_par_ex(1) enddef;
vardef '(text TXT)= parts_cnt:=parts_cnt+1; read_mcf(parts_cnt)(TXT); parts_cnt enddef;
+vardef read_id(text TXT)=read_mcf(incr parts_cnt)(|,#crR,TXT,##,(_com,_rest)); parts_cnt enddef;
+vardef read_ud(text TXT)=read_mcf(incr parts_cnt)(|,TXT,(_com,_rest)); parts_cnt enddef;
+tertiarydef a op_equ b = if (known a)and(known b):: change_bond(a,b) else:: _nop fi enddef;
+tertiarydef a op_col b = if (known a)and(known b):: change_atom(a,b) else:: _nop fi enddef;
+tertiarydef a op_hat b = if known b:: (_tmp_rot,b),a else:: _nop,a fi enddef;
+tertiarydef a op_til b = if known b:: (_tmp_line,b),a else:: _nop,a fi enddef;
+tertiarydef a op_lt b = if known b:: (_tmp_env,b),a else:: _nop,a fi enddef;
+tertiarydef a op_bq b = if known b:: (_tmp_len,b),a else:: _nop,a fi enddef;
+def rot_angle primary n = (_rot_ang,n) enddef; def jump_atom primary n = (_jp_atom,n) enddef;
+def cyc_atom primary n = (_cyc,n) enddef;
+def chg_length primary n = (_com,_len_s),(_chg_len,n) enddef;
+def group_si secondary n == if known n:: (_group_si,n) else:: _nop fi enddef;
+def group_dm secondary n == /n~dm enddef; def group_wf secondary n == /n~wf enddef;
+def group_zf secondary n == /n~zf enddef; def group_wv secondary n == /n~wv enddef;
+def group_nb secondary n == /n~nb enddef;
+vardef abs_adress primary n == n-4095 enddef;
+%-------------------------------------------------------------------------------------------------
+def CP = com_par enddef; def CPe = com_par_ex(0) enddef; def CPx = com_par_ex(1) enddef;
%=================================================================================================
def read_mcf(expr n)(text TXT)=
begingroup
@@ -362,12 +405,8 @@ def read_mcf(expr n)(text TXT)=
else:: nCP:=nCP+1; comD[n][nCP]:=_mk_bond; parD[n][nCP]:=list;
fi
elseif string list::
- if (list=="+")or(list=="-")::
- nCP:=nCP+1; comD[n][nCP]:=_set_add; parD[n][nCP]:=ASCII(list);
- else::
- str_cnt:=str_cnt+1; strD[str_cnt]:=list;
- nCP:=nCP+1; comD[n][nCP]:=_set_atom; parD[n][nCP]:=str_cnt;
- fi
+ str_cnt:=str_cnt+1; strD[str_cnt]:=list;
+ nCP:=nCP+1; comD[n][nCP]:=_set_atom; parD[n][nCP]:=str_cnt;
fi
else:: message "unknown command in "AND decimal(n);
fi
@@ -378,20 +417,20 @@ enddef;
%-------------------------------------------------------------------------------------------------
vardef read_number(text TXT)=
parts_int:=parts_int+1;
- nN:=0;
+ nA:=0;
for list==TXT::
if known list::
if numeric list::
if list==_nop:: message "unknown command in "AND decimal(parts_int);
- else:: nN:=nN+1; comD[parts_int][nN]:=_numeric; parD[parts_int][nN]:=list;
+ else:: nA:=nA+1; comD[parts_int][nA]:=_numeric; parD[parts_int][nA]:=list;
fi
elseif pair list::
- nN:=nN+1; comD[parts_int][nN]:=xpart(list); parD[parts_int][nN]:=ypart(list);
+ nA:=nA+1; comD[parts_int][nA]:=xpart(list); parD[parts_int][nA]:=ypart(list);
fi
else:: message "unknown command in "AND decimal(parts_int);
fi
endfor
- cntD[parts_int]:=nN;
+ cntD[parts_int]:=nA;
parts_int %------- Retern value -------
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -465,9 +504,10 @@ vardef change_atom(expr a,b)=
CP(_tmp_line,dm) CP(_tmp_rot,-35) CPx(a)(_group_si,O) CP(_com,_group_e)
ef b==SO:: CPe(a)(_chg_atom,S) CP(_com,_group_s) CP(_tmp_line,dm)
CPx(a)(_group_si,O) CP(_com,_group_e)
+ ef b==n_:: CP(_com,_group_s) CP(_set_add,ASCII("-")) CP(_chg_add,a) CP(_com,_group_e)
+ ef b==p_:: CP(_com,_group_s) CP(_set_add,ASCII("+")) CP(_chg_add,a) CP(_com,_group_e)
fi
ef pair b:: CP(_com,_group_s) CPx(a)(xpart(b),ypart(b)) CP(_com,_group_e)
- ef string b:: CP(_com,_group_s) CP(_set_add,ASCII(b)) CP(_chg_add,a) CP(_com,_group_e)
ef color b:: color_list[incr cntC]:=b; CPe(a)(_set_colorA,cntC)
fi
cntD[parts_int]:=nCP;
@@ -495,13 +535,13 @@ def puts(expr POS)(expr STR)=
temp_p:=POS;
nC:=defaultscale*defaultsize;
if (defaultfont="draw")or(f_MP=0):
- for i=0 upto length(STR)-1:
+ for i=1 upto length(STR):
temp_c:=subc(i,STR);
draw_char(temp_c,temp_p,nC,ratio_thickness_char*nC,0);
temp_p:=temp_p+(nC*tbl_char_wd[ASCII(temp_c)],0);
endfor
else:
- for i=0 upto length(STR)-1:
+ for i=1 upto length(STR):
temp_c:=subc(i,STR);
temp_picture:=temp_c infont defaultfont scaled defaultscale;
addto currentpicture also temp_picture shifted temp_p;
@@ -554,11 +594,11 @@ def add_to_molecule(text TXT)=
lonepairspace:=.7aw;
circlediam:=.6aw;
circlepen:=.2bp;
- for i=1 upto An:
+ for i=1 upto cntA:
A[i]:=posA[i]; A[i]ang:=angX[i]; A[i]up:=dir(angX[i]);
A[i]left:=dir(angX[i]+90); A[i]right:=dir(angX[i]-90); A[i]down:=dir(angX[i]+180);
endfor
- for i=1 upto Bn:
+ for i=1 upto cntB:
B[i]s:=posA[sB[i]]; B[i]e:=posA[eB[i]]; B[i]m:=0.5[B[i]s,B[i]e];
B[i]:=B[i]s--B[i]e;
B[i]ang:=angB[i]; B[i]up:=dir(angB[i]);
@@ -652,18 +692,18 @@ vardef lone_pair_add expr ANG=
enddef;
%--------------------------------------------------------------------------------------------------
vardef label_emu@#(expr OBJ,POS) = %% modified 'thelabel@#(expr s,z)' of plain.mp
- save oft,fx,fy,wds,pA,pB,pC,pD,sC;
+ save oft,fx,fy,wd_s,wd_c,pA,pB,pC,pD,sC;
pair oft,oft.lft,oft.rt,oft.top,oft.bot,oft.ulft,oft.llft,oft.urt,oft.lrt,pA,pB,pC,pD;
- wds:=0;
- nC:=defaultscale*defaultsize;
+ wd_s:=0;
+ wd_c:=defaultscale*defaultsize;
%---------------------------------------------------------------
if string OBJ:
if (defaultfont="draw")or(f_MP=0):
- for i=0 upto length(OBJ)-1: wds:=wds+nC*tbl_char_wd[ASCII(subc(i,OBJ))]; endfor
+ for i=1 upto length(OBJ): wd_s:=wd_s+wd_c*tbl_char_wd[ASCII(subc(i,OBJ))]; endfor
else:
- for i=0 upto length(OBJ)-1:
+ for i=1 upto length(OBJ):
temp_picture:=subc(i,OBJ) infont defaultfont scaled defaultscale;
- wds:=wds+xpart(lrcorner temp_picture-llcorner temp_picture);
+ wd_s:=wd_s+xpart(lrcorner temp_picture-llcorner temp_picture);
endfor
fi
fi
@@ -679,7 +719,7 @@ vardef label_emu@#(expr OBJ,POS) = %% modified 'thelabel@#(expr s,z)' of plain.m
oft.lrt:= ( .7,-.7); fx.lrt:=0; fy.lrt:=1;
%---------------------------------------------------------------
if string OBJ:
- puts(POS+(labeloffset*oft@#)-(wds*fx@#,nC*fy@#))(OBJ);
+ puts(POS+(labeloffset*oft@#)-(wd_s*fx@#,wd_c*fy@#))(OBJ);
elseif picture OBJ:
pA:=llcorner(OBJ);
pB:=urcorner(OBJ);
@@ -730,8 +770,8 @@ enddef;
def MC(text TXT)=
begingroup
save f_bra,strAT,cnt_group,temp_lenE,temp_lenF,temp_cntB,f_term,f_at,f_lineT,f_rotT,
- f_lenT,f_envT,sA,factor,m_wd,m_ht,temp_p,defaultsize,defaultscale;
- string sA;
+ f_lenT,f_envT,temp_c,factor,m_wd,m_ht,temp_p,defaultsize,defaultscale;
+ string temp_c;
pair temp_p;
%-----------------------------------------------------------------------------------------------
if (sw_numberA>=1)or(sw_numberB>=1): ratio_atom_bond:=0.25; fi
@@ -775,13 +815,13 @@ def MC(text TXT)=
%-draw add to atom------------------------------------------------------------------------------
for i=1 upto cntA:
if addA[i]<>0:
- sA:=char(addA[i]); nA:=angX[i]+add_rot[i]; nC:=nA mod 90;
- if sA="+": chargeA[i]:=1; elseif sA="-": chargeA[i]:=-1; else: chargeA[i]:=0; fi
+ temp_c:=char(addA[i]); nA:=angX[i]+add_rot[i]; nC:=nA mod 90;
+ if temp_c="+": chargeA[i]:=1; elseif temp_c="-": chargeA[i]:=-1; else: chargeA[i]:=0; fi
if numS[i]=0: nB:=.5atom_wd;
else: nB:=.85wdA[i]+iif(nC<45,sind(nC),cosd(nC))*.5wdA[i];
fi
temp_p:=sfrt(posA[i]-(.35atom_wd,.35atom_wd),nB,nA);
- draw_char(sA,temp_p,atom_wd,bond_pen_wd*ratio_char_bond,0);
+ draw_char(temp_c,temp_p,atom_wd,bond_pen_wd*ratio_char_bond,0);
else: chargeA[i]:=0;
fi
endfor
@@ -885,8 +925,10 @@ def draw_corner(expr PS,LX,LY,PN)=
enddef;
%-------------------------------------------------------------------------------------------------
def proc_size_setup=
- if (blen*ratio_atom_bond+offset_atom)<.8blen: atom_wd:=blen*ratio_atom_bond+offset_atom;
- else: atom_wd:=.8blen; ratio_chain_ring:= .5;
+ if (blen*ratio_atom_bond+offset_atom)<.8blen:
+ atom_wd:=blen*ratio_atom_bond+offset_atom;
+ else:
+ atom_wd:=.8blen; ratio_chain_ring:= .5;
fi
wedge_wd:= blen*ratio_wedge_bond+offset_wedge;
zebra_gap:= blen*ratio_zebragap_bond+offset_zebra_gap;
@@ -902,11 +944,11 @@ def proc_scaling=
ypos:=ypart(posA[i]);
if numS[i]<>0:
nU:=nD:=nP:=nL:=nR:=0;
- for j=0 upto length(strD[numS[i]])-1:
- sA:=subc(j,strD[numS[i]]);
- if (sA="^"): nU:=.5atom_wd;
- elseif (sA="_"): nD:=.5atom_wd;
- elseif (sA<>"{")and(sA<>"}"): nP:=nP+atom_wd*tbl_char_wd[ASCII(sA)];
+ for j=1 upto length(strD[numS[i]]):
+ temp_c:=subc(j,strD[numS[i]]);
+ if (temp_c="^"): nU:=.5atom_wd;
+ elseif (temp_c="_"): nD:=.5atom_wd;
+ elseif (temp_c<>"{")and(temp_c<>"}"): nP:=nP+atom_wd*tbl_char_wd[ASCII(temp_c)];
fi
endfor
if (angX[i]<=90)or(angX[i]>=270): nR:=nP; else: nL:=nP; fi
@@ -923,12 +965,11 @@ enddef;
%-------------------------------------------------------------------------------------------------
def char_use_check=
for i=1 upto 128: f_char[i]:=0; endfor
- if (sw_numberA<>0)or(sw_numberB<>0):
- for j=ASCII("0") upto ASCII("9"): f_char[j]:=1; endfor
+ if (sw_numberA<>0)or(sw_numberB<>0): for j=a_zero upto a_nine: f_char[j]:=1; endfor
else:
for i=1 upto cntA:
if numS[i]<>0:
- for j=0 upto length(strD[numS[i]])-1: f_char[ASCII(subc(j,strD[numS[i]]))]:=1; endfor
+ for j=1 upto length(strD[numS[i]]): f_char[ASCII(subc(j,strD[numS[i]]))]:=1; endfor
fi
endfor
fi
@@ -1012,10 +1053,9 @@ def proc_skeleton(expr a)=
ef com=_jp_atom: termB; adrT:=getA(par); posBs:=posA[adrT]; angT:=angX[adrT]; f_bra:=1; rotT:=0;
ef com=_jp_absA: adrT:=par; posBs:=posA[adrT];
angT:=angX[adrT]; f_bra:=1; rotT:=0; temp_cntB:=cntB;
- ef com=_adj_ang: if (angT<40)or(angT>320): angT:=0;
- ef angT<140: angT:=90; ef angT<220: angT:=180; else: angT:=270; fi
- ef com=_rot_ang: angT:=(angT+par) mod 360;
- ef com=_tmp_rot: rotT:=par;
+ ef com=_adj_ang: angT:=adjust_ang(angT);
+ ef com=_rot_ang: angT:=(angT+par) mod 360;
+ ef com=_tmp_rot: rotT:=par;
ef com=_group_si: rotT:=0;
ef com=_chg_env: envB:=par;
ef com=_tmp_env: envT:=par;
@@ -1028,7 +1068,7 @@ def proc_skeleton(expr a)=
enddef;
%-------------------------------------------------------------------------------------------------
def add_bond(expr ROT,FLG)=
- if ROT=_arg_ang: nA:=arrange_ang(angT mod 360); else: nA:=ROT; fi
+ if ROT=_arrange_ang: nA:=arrange_ang(angT mod 360); else: nA:=ROT; fi
if f_bra=0:
adrT:=cntA:=cntA+1; posA[cntA]:=posBs; angA[cntA]:=angT;
angX[cntA]:=(angT+nA/2+iif(nA>=0,-90,90)) mod 360;
@@ -1052,12 +1092,14 @@ vardef arrange_ang(expr n)=
if cntB=0: angT:=(angT-180) mod 360; 180
else:
if envB>=parts_emb_start: parD[envB][cntB-temp_cntB+2]
- else: if envB=hz: if n=0: 60 ef n<=90:-60 ef n<=180: 60 ef n<270: -60 else: 60 fi
- ef envB=vt: if n=0:-60 ef n<90: 60 ef n<=180:-60 ef n<=270: 60 else:-60 fi
+ else: if envB=hz: if n=0: 60 ef n<=90: -60 ef n<=180: 60 ef n<270: -60 else: 60 fi
+ ef envB=vt: if n=0: -60 ef n<90: 60 ef n<=180: -60 ef n<=270: 60 else: -60 fi
ef abs(envB)<=180: envB fi
fi
fi
enddef;
+%-------------------------------------------------------------------------------------------------
+vardef adjust_ang(expr n)= if (n<40)or(n>320): 0 ef n<140: 90 ef n<220: 180 else: 270 fi enddef;
%=================================================================================================
vardef getA(expr n)= if n>=0: markA+n ef n>=-999: cntA+n+1 else: n+4095 fi enddef;
vardef getB(expr n)= if n>=0: markB+n ef n>=-999: cntB+n+1 else: n+4095 fi enddef;
@@ -1085,44 +1127,45 @@ enddef;
def draw_atom(expr NUM)=
begingroup
if numS[NUM]<>0:
- save slen,f_wd,f_ht,r_ff,pA,pB,sA,sB,dx;
- string sA,sB;
- pair pA,pB;
+ save slen,f_wd,f_ht,r_ff,pos_a,pos_c,temp_c,temp_s,dir_str;
+ string temp_c,temp_s;
+ pair pos_a,pos_c;
%-------------------------------------------------------
- sA:=strD[numS[NUM]]; slen:=length(sA)-1; nA:=angX[NUM];
- dxA[NUM]:=dx:=iif((nA<=90)or(nA>=270),1,-1);
- wdA[NUM]:=nC:=0; pB:=(0,0);
- pA:=posA[NUM]-(.5atom_wd*dx,.5atom_wd);
+ temp_s:=strD[numS[NUM]]; slen:=length(temp_s); nA:=angX[NUM];
+ dxA[NUM]:=dir_str:=iif((nA<=90)or(nA>=270),1,-1);
+ wdA[NUM]:=nC:=0; pos_c:=(0,0);
+ pos_a:=posA[NUM]-(.5atom_wd*dir_str,.5atom_wd);
if (atomfont<>"draw")and(f_MP=1):
atom_picture:="C" infont atomfont;
r_ff:=atom_wd/(ypart(ulcorner atom_picture)-ypart(llcorner atom_picture));
fi
- for i=0 upto slen:
+ for i=1 upto slen:
if nC=0:
- sB:=subc(i,sA);
- if (dx=-1)and(sB="{"):
- nD:=i+1; nC:=0; for j=nD upto slen: nC:=nC+1; exitif subc(j,sA)="}"; endfor
+ temp_c:=subc(i,temp_s);
+ if (dir_str=-1)and(temp_c="{"):
+ nD:=i; nC:=0; for j=nD upto slen: nC:=nC+1; exitif subc(j,temp_s)="}"; endfor
fi
- else: nC:=nC-1; sB:=subc(nD+nC,sA);
+ else: nC:=nC-1; temp_c:=subc(nD+nC,temp_s);
fi
- if sB="_": pB:=iif(pB=(0,0),(0,-.5atom_wd),(0,0));
- elseif sB="^": pB:=iif(pB=(0,0),(0, .5atom_wd),(0,0));
- elseif (sB<>"{")and(sB<>"}"):
+ if temp_c="_": pos_c:=iif(pos_c=(0,0),(0,-.5atom_wd),(0,0));
+ elseif temp_c="^": pos_c:=iif(pos_c=(0,0),(0, .5atom_wd),(0,0));
+ elseif (temp_c<>"{")and(temp_c<>"}"):
if (atomfont="draw")or(f_MP=0):
- f_wd:=atom_wd*tbl_char_wd[ASCII(sB)];
- if dx=-1: pA:=pA-(f_wd,0); fi
- draw_char(sB,pA+pB,atom_wd,bond_pen_wd*ratio_char_bond,NUM);
- if sw_aframe=1: draw_frame(pA+pB,f_wd,atom_wd,thickness_aframe); fi
- if dx=1: pA:=pA+(f_wd,0); fi
+ f_wd:=atom_wd*tbl_char_wd[ASCII(temp_c)];
+ if dir_str=-1: pos_a:=pos_a-(f_wd,0); fi
+ draw_char(temp_c,pos_a+pos_c,atom_wd,bond_pen_wd*ratio_char_bond,NUM);
+ if sw_aframe=1: draw_frame(pos_a+pos_c,f_wd,atom_wd,thickness_aframe); fi
+ if dir_str=1: pos_a:=pos_a+(f_wd,0); fi
else:
- atom_picture:=sB infont atomfont;
+ atom_picture:=temp_c infont atomfont;
f_wd:=(xpart(lrcorner atom_picture)-xpart(llcorner atom_picture))*r_ff;
f_ht:=(ypart(urcorner atom_picture)-ypart(llcorner atom_picture))*r_ff;
- if dx=-1: pA:=pA-(f_wd,0); fi
+ if dir_str=-1: pos_a:=pos_a-(f_wd,0); fi
addto currentpicture also atom_picture scaled (r_ff*(1-2ratio_atomgap_atom))
- shifted (pA+pB+(f_wd*ratio_atomgap_atom,f_ht*ratio_atomgap_atom)) Cp(colorA[NUM]);
- if sw_aframe=1: draw_frame(pA+pB,f_wd,f_ht,thickness_aframe); fi
- if dx=1: pA:=pA+(f_wd,0); fi
+ shifted (pos_a+pos_c+(f_wd*ratio_atomgap_atom,f_ht*ratio_atomgap_atom))
+ Cp(colorA[NUM]);
+ if sw_aframe=1: draw_frame(pos_a+pos_c,f_wd,f_ht,thickness_aframe); fi
+ if dir_str=1: pos_a:=pos_a+(f_wd,0); fi
fi
wdA[NUM]:=wdA[NUM]+f_wd;
fi
@@ -1219,7 +1262,7 @@ vardef frame_str(expr NUM)=
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def char_size_set(expr WD)(expr HT)(expr STR)=
- for j=0 upto length(STR)-1:
+ for j=1 upto length(STR):
nA:=ASCII(subc(j,STR)); tbl_char_wd[nA]:=WD; tbl_char_ht[nA]:=HT;
endfor
enddef;
@@ -1227,7 +1270,7 @@ enddef;
char_size_set( 1)( 1)("CGHMNOQW");
char_size_set( .9)( 1)("ABDFIJKPRSTUVXY/><#\%@");
char_size_set( .8)( 1)("ELZ&");
-char_size_set( .7)( 1)(" ()[]0123456789nh=tfg?~^");
+char_size_set( .7)( 1)(" ()[]{}0123456789nh=tfg?~^");
char_size_set( .7)( .9)("$");
char_size_set( .7)( .7)("-+*_");
char_size_set(.45)(.95)("l");
@@ -1254,10 +1297,10 @@ def dwvs (expr n)expr p=
def dwh expr p=draw (p) withpen penrazor rotated 90 scaled fP shifted pos Cp(colorA[NUM]) enddef;
def cdw expr p=cutdraw (p) shifted pos Cp(colorA[NUM]) enddef;
%-------------------------------------------------------------------------------------------------
-sC:=CHR; fP:=PEN; hP:=0.5fP; nW:=WD;
-aW:=nW*tbl_char_wd[ASCII(sC)]*(1-2ratio_atomgap_atom);
-aH:=nW*tbl_char_ht[ASCII(sC)]*(1-2ratio_atomgap_atom);
-pos:=POS+(nW*ratio_atomgap_atom,nW*ratio_atomgap_atom);
+sC:=CHR; fP:=PEN; hP:=0.5fP;
+aW:=WD*tbl_char_wd[ASCII(sC)]*(1-2ratio_atomgap_atom);
+aH:=WD*tbl_char_ht[ASCII(sC)]*(1-2ratio_atomgap_atom);
+pos:=POS+(WD*ratio_atomgap_atom,WD*ratio_atomgap_atom);
%-------------------------------------------------------------------------------------------------
fW:=aW-hP; hW:=.5aW; fH:=aH-hP; hH:=.5aH;
Z01:=( 0,hP); Z02:=(hP, 0); Z03:=(hP,hP); Z04:=(aW,hP); Z05:=(fW, 0); Z06:=(hW,aH); Z07:=(hW, 0);
@@ -1350,8 +1393,10 @@ ef sC="(": dw Z19...Z09...Z14;
ef sC=")": dw Z19...Z10...Z14;
ef sC="[": dwv Z07--Z06; dwh Z14--Z22; dwh Z19--Z21;
ef sC="]": dwv Z07--Z06; dwh Z14--Z13; dwh Z03--Z19;
-ef sC="<": cdw Z01--Z17--Z12;
-ef sC=">": cdw Z16--Z08--Z04;
+ef sC="{": dw Z19..(.3aW,.2aH)..(.3aW,.45aH)..(.2aW,.5aH)..(.3aW,.55aH)..(.3aW,.8aH)..Z14;
+ef sC="}": dw Z19..(.7aW,.2aH)..(.7aW,.45aH)..(.8aW,.5aH)..(.7aW,.55aH)..(.7aW,.8aH)..Z14;
+ef sC="<": cdw Z16--Z08--Z04;
+ef sC=">": cdw Z01--Z17--Z12;
ef sC="-": dwh Z09--Z10;
ef sC="=": dwh (hP,.3aH)--(fW,.3aH); dwh (hP,.6aH)--(fW,.6aH);
ef sC="/": dw Z22..Z01;
@@ -1372,31 +1417,24 @@ ef sC="&": cdw Z21..(hW,.35aH)..(.25aW,.75aH)..(hW,.fH)..(.75aW,.75fH)..(hP,.3aH
ef sC="@": cdw sbp(0,.7)zO; dwv (fW,hH)--(fW,0);
dw (fW,.45aH)..(.7aW,.75aH)..(.3aW,.45aH)..(.7aW,.15aH)..cycle;
ef sC="_": dwh Z01--Z04;
-ef sC="^": dwv (hP,.6aH)..(.5aW,.7aH)..(fW,.6aH);
+ef sC="^": dw (hP,.6aH)--(.5aW,fH)--(fW,.6aH);
else:
fi
endgroup
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-def blank_str:= " " enddef;
-vardef fixed_r(expr n)(expr s)= (substring(0,n-length(s)) of blank_str)&s enddef;
-vardef fixed_l(expr n)(expr s)= s&(substring(0,n-length(s)) of blank_str) enddef;
-vardef fdr(expr n)(expr s)=fixed_r(n)(decimal(s)) enddef;
-vardef fdl(expr n)(expr s)=fixed_l(n)(decimal(s)) enddef;
-def warning(expr s)= message "% "&decimal(char_num)&fdr(3)(incr warning_cnt)&")"&s; enddef;
-%-------------------------------------------------------------------------------------------------
def warning_bond(expr a)=
if addA[a]=0:
- warning("A"&decimal(a)&" ( "&fixed_l(8)(strD[numS[a]])&") has"&fdr(2)(bond_cnt)&" bonds");
+ warning("A"&decimal(a)&" ( "&fsl(8)(strD[numS[a]])&") has"&fdr(2)(bond_cnt)&" bonds");
fi
enddef;
%-------------------------------------------------------------------------------------------------
-vardef cut_paren(expr ATOM)=
+vardef erase_brace(expr ATOM)=
save temp_c,temp_s;
string temp_c,temp_s;
temp_s:="";
if (length(ATOM)>=4)and(ATOM<>"COOH"):
- for i=0 upto length(ATOM)-1:
+ for i=1 upto length(ATOM):
temp_c:=subc(i,ATOM);
if (temp_c<>"{")and(temp_c<>"}")and(temp_c<>"_")and(temp_c<>"^")
and(temp_c<>"+")and(temp_c<>"-"):
@@ -1417,11 +1455,11 @@ def proc_calc=
knownA:=bond_cnt:=0;
nS:=numS[i];
for j=1 upto cntB:
- if (lineB[j]>=dl)and(lineB[j]<=dm): bondC[j]:=2;
- ef lineB[j]=tm: bondC[j]:=3;
- ef (lineB[j]=vf)or(lineB[j]=vb): bondC[j]:=0;
- ef lineB[j]=0: bondC[j]:=0;
- else: bondC[j]:=1;
+ if (lineB[j]>=dl)and(lineB[j]<=dm_): bondC[j]:=2;
+ ef lineB[j]=tm: bondC[j]:=3;
+ ef (lineB[j]=vf)or(lineB[j]=vb): bondC[j]:=0;
+ ef lineB[j]=0: bondC[j]:=0;
+ else: bondC[j]:=1;
fi
if (sB[j]=i)or(eB[j]=i): bond_cnt:=bond_cnt+bondC[j]; fi
endfor
@@ -1464,15 +1502,13 @@ def proc_calc=
if (tbl_atom_max=1)and(sumA[2]>0): tbl_atom_max:=2; fi
for i=1 upto tbl_atom_max:
if sumA[i]>=1:
- nA:=tbl_atom_wt[i]/100*sumA[i];
- nB:=tbl_atom_mi[i]/100*sumA[i];
- cen_MW:=cen_MW+nA;
- cen_MI:=cen_MI+nB;
+ nA:=tbl_atom_wt[i]/100*sumA[i]; nB:=tbl_atom_mi[i]/100*sumA[i];
+ cen_MW:=cen_MW+nA; cen_MI:=cen_MI+nB;
if (cen_MW<40)and(cen_MI<40):
num_MW:= num_MW+tbl_atom_wt[i]*sumA[i];
num_MI:= num_MI+tbl_atom_mi[i]*sumA[i];
fi
- cal_FM:=cal_FM&cut_paren(tbl_atom_str[i]) if sumA[i]>=2: &decimal(sumA[i]) fi;
+ cal_FM:=cal_FM&erase_brace(tbl_atom_str[i]) if sumA[i]>=2: &decimal(sumA[i]) fi;
fi
endfor
%-------------------------------------------------------------------------------------
@@ -1520,6 +1556,7 @@ def proc_auxfile_out=
ef tag[i]="USE": & inf_USE
ef tag[i]="EXA": & inf_EXA
ef tag[i]="EXB": & inf_EXB
+ ef tag[i]="MC": & inf_MC
fi
endfor
if sw_aux_out=3: for i=1 upto inf_num: &aux_delimiter&info[i] endfor; fi
@@ -1544,7 +1581,7 @@ def proc_report_out=
printf "------------------------------------------------------------------";
printf "< NO. ><atom(s) >( x axis , y axis )<bond><hideH><chg>";
for i=1 upto cntA:
- printf " A"&fdl(6)(i)&fixed_l(8)(cut_paren(strD[numS[i]]))&
+ printf " A"&fdl(6)(i)&fsl(8)(erase_brace(strD[numS[i]]))&
" ("&fdr(10)(round_auto(xpart(posA[i])/blen))&" , "&
fdr(10)(round_auto(ypart(posA[i])/blen))&" ) "&fdr(4)(Bcnt[i])&
iif(hideH[i]>0,fdr(6)(hideH[i])," ")
@@ -1567,14 +1604,14 @@ def proc_report_out=
if sumA[i]>=1:
nA:=tbl_atom_wt[i]/100*sumA[i]; nB:=tbl_atom_mi[i]/100*sumA[i];
printf " "&
- fixed_l(5)(cut_paren(tbl_atom_str[i]))&
+ fsl(5)(erase_brace(tbl_atom_str[i]))&
"("&fdr(9)(tbl_atom_wt[i])&")"&"["&fdr(9)(tbl_atom_mi[i])&"]"&" * "&fdr(4)(sumA[i])
if nA<40: &fdr(15)(tbl_atom_wt[i]*sumA[i])&"["&fdr(12)(tbl_atom_mi[i]*sumA[i])&"]";
else: &fdr(11)(nA)&"*100"&"["&fdr(9)(nB)&"*100"&"]";
fi
fi
endfor
- printf " Molecular Weight [Mono Isotopic] = "&fixed_r(12)(cal_MW)&"["&fixed_r(12)(cal_MI)&"]";
+ printf " Molecular Weight [Mono Isotopic] = "&fsr(12)(cal_MW)&"["&fsr(12)(cal_MI)&"]";
printf "------------------------------------------------------------------";
printf " Weight Calc: " &cal_MW &" / Input: "
if inf_MW<>"-": &inf_MW &" / weight gap= " &decimal(num_MW-scantokens(inf_MW)) fi;
@@ -1588,11 +1625,11 @@ def proc_mol_out=
out_file_name:=out_file_mol;
%-V2000---------------------------------------------------------------------------------------
if sw_mol_out=1:
- printf ""; printf " -MCFtoMOL- "&fixed_l(20)(info[1]); printf "";
+ printf ""; printf " -MCFtoMOL- "&fsl(20)(info[1]); printf "";
printf fdr(3)(cntA)&fdr(3)(cntB)&" 0 0 0 0 0 0 0 0999 V2000";
for i=1 upto cntA:
printf fdr(10)(xpart(posA[i])/blen)& fdr(10)(ypart(posA[i])/blen)&fdr(10)(0)&" "&
- fixed_l(2)(cut_paren(strD[numS[i]]))&" 0"&fdr(3)(bond_charge(chargeA[i]))&" 0 0";
+ fsl(2)(erase_brace(strD[numS[i]]))&" 0"&fdr(3)(bond_charge(chargeA[i]))&" 0 0";
endfor
for i=1 upto cntB:
if lineB[i]<>0:
@@ -1603,13 +1640,13 @@ def proc_mol_out=
printf "M END";
%-V3000---------------------------------------------------------------------------------------
elseif sw_mol_out=2:
- printf ""; printf " -MCFtoMOL- "&fixed_l(20)(info[1]); printf "";
+ printf ""; printf " -MCFtoMOL- "&fsl(20)(info[1]); printf "";
printf " 0 0 0 0 0 999 V3000";
printf "M V30 BEGIN CTAB";
printf "M V30 COUNTS "&decimal(cntA)&" "&decimal(cntB)&" 0 0 0";
printf "M V30 BEGIN ATOM";
for i=1 upto cntA:
- printf "M V30 "&decimal(i)&" "&cut_paren(strD[numS[i]])&" "&
+ printf "M V30 "&decimal(i)&" "&erase_brace(strD[numS[i]])&" "&
decimal(xpart(posA[i])/blen)&" "&decimal(ypart(posA[i])/blen)&" 0 0"
if chargeA[i]<>0: &" CHG="&decimal(chargeA[i]) fi;
endfor
@@ -1697,11 +1734,13 @@ parts_atom_end:=parts_cnt;
for i==3 upto 20: ?[i]:='((_com,_len_ss),(_get_len,_ring_len),<((-180 DIV i)-90)
for j==2 upto i:: ,(360 DIV i) endfor,(_cyc_sB,1-i),(_com,_len_ee)); endfor
Ph:=Ph1:='(?6,-2=dl,-4=dl,-6=dl); Ph2:='(?6,-1=dl,-3=dl,-5=dl);
-!:=!1:='((_mk_bond,_arg_ang)); !!:='(!~db); !!!:='(!~tm);
+!:=!1:='((_mk_bond,_arrange_ang)); !!:='(!~db); !!!:='(!~tm);
for i==2 upto 20:
![i]:='((_com,_len_ss),(_get_len,_tmp_len),! for j==2 upto i::,! endfor ,(_com,_len_ee));
endfor
Me:='(); Et:='(!); iPr:=?!:='(/_,!); tBu:=??!:='(/_,/_^60,60); !?!:='(!,?!); !??!:='(!,??!);
+n_:='((_set_add,ASCII("-"))); p_:='((_set_add,ASCII("+")));
+zero_wf:='(0~wf); zero_zf:='(0~zf); zero_dm:='(0~dm); zero_wv:='(0~wv);
%-------------------------------------------------------------------------------------------------
NH:='(N,/H~nl); N!:='(N,/_); N!2:='(N,/!); SO:='(S,//O); SOO:='(S,//O^-35,//O^35);
O!:='(O,!); O!2:='(O,!,!); O!3:='(O,!,!,!); O!?!:='(O,!,?!); O!??!:='(O,!,??!);
@@ -1744,4 +1783,27 @@ def expand_set=
!CH3:='(!,CH3); !OH:='(!,OH); !NH2:='(!,NH2); !CHO:='(!,CHO); !COOH:='(!,COOH); !CN:='(!,CN);
!SH:='(!,SH); !NO2:='(!,NO2);
enddef;
-%-------------------------------------------------------------------------------------------------
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+vardef check_mc(expr s)= %%%%% prototype version %%%%%%
+ save mc_char,mc_char,temp_c,err_cnt,char_cnt;
+ string temp_c;
+ numeric mc_char[];
+ err_cnt:=char_cnt:=nA:=nB:=nC:=nD:=nE:=nF:=0;
+ %-----------------------------------------------------------------------------------------------
+ for i=1 upto length(s):
+ temp_c:=subc(i,s); if temp_c<>" ": char_cnt:=char_cnt+1; mc_char[char_cnt]:=ASCII(temp_c); fi
+ endfor
+ %-- check brackets -----------------------------------------------------------------------------
+ for i=1 upto char_cnt:
+ if mc_char[i]=a_paren_s: nA:=nA+1; ef mc_char[i]=a_paren_e: nB:=nB+1;
+ ef mc_char[i]=a_brace_s: nC:=nC+1; ef mc_char[i]=a_brace_e: nD:=nD+1;
+ ef mc_char[i]=a_bracket_s: nE:=nE+1; ef mc_char[i]=a_bracket_e: nF:=nF+1;
+ fi
+ endfor
+ if nA<>nB: err_cnt:=err_cnt+1; fi if nC<>nD: err_cnt:=err_cnt+1; fi
+ if nE<>nF: err_cnt:=err_cnt+1; fi
+ %-----------------------------------------------------------------------------------------------
+ if err_cnt>=1: message "* "&decimal(err_cnt)&"fatal error"; fi
+ err_cnt
+enddef;
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%