summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-02-11 22:54:29 +0000
committerKarl Berry <karl@freefriends.org>2021-02-11 22:54:29 +0000
commitfcf03a2973004ba816be26780ea00d9b790948fc (patch)
tree179db9baabfb9210036516a5833d48054d87c626 /Master/texmf-dist/metapost
parentc7d381cb401ac7ed825998d0ebdb163d1bb26c5d (diff)
mcf2graph (11feb21)
git-svn-id: svn://tug.org/texlive/trunk@57714 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost')
-rw-r--r--Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf330
1 files changed, 142 insertions, 188 deletions
diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf
index af136209e34..0ebece8405f 100644
--- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf
+++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf
@@ -1,5 +1,5 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% mcf2graph ver 4.56 Copyright (c) 2013-2021 Akira Yamaji
+% mcf2graph ver 4.57 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,12 +37,12 @@
% Set to use plain.mp (label,arrow,atom) : mpost -s labeloffset=2 FILENAME
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tracingstats:=1;
-message "* This is mcf2graph ver 4.56 2021.01";
+message "* This is mcf2graph ver 4.57 2021.02.11";
%-------------------------------------------------------------------------------------------------
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;
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[],andA[],and_rot[],chargeA[],
+ 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,
@@ -191,8 +191,8 @@ def def_com(expr n)(text tx)= nA:=n; forsuffixes list=tx:: list:=nA; nA:=nA+1; e
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,
- _jump_at,_connect_at,_set_and,_chg_and,_nop,_mark,_moff,_term,_len_s,_len_e,_len_ss,_len_ee,
- _group_s,_group_e,_rest,
+ _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_);
%--------------------------------------------------------------------------------------------------
def parameter_list=
@@ -319,38 +319,29 @@ def endfont=
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def set_def_MC=
- save /,//,/*,*/,**,*/*,~,^,',`,``,<,>,&,:,=,\,\\,*\,\*,*\*,@,#,@#,$,
- {,},|,||,|||,|=,=|,|<,>|,|<<,>>|,:|,_,d,w,z,CP,CPe,CPx,inside_def_MC;
+ save /,//,/*,*/,**,*/*,~,^,',`,<,>,&,:,=,\,\\,*\,\*,*\*,@,$,&,#,##,{,},|,||,_,inside_def_MC;
inside_def_MC:=1;
- _:=Me; d:=db; w:=wf; z:=zf;
+ _:=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 s == (_set_and,ASCII(s)) enddef;
- vardef $primary a == a-4095 enddef;
- def <primary n == (_rot_ang,n) enddef;
- def ``primary n == (_chg_len,n) 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 # == _connect_at enddef; def @ == _jump_at enddef; primarydef a@#b == a:@,b:# enddef;
- def \ == @,0 enddef; def \\ == \~dm enddef; def *\ == \~wf enddef; def \* == \~zf 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 ||| == (_com,_term) enddef;
- def |< == (_com,_len_s) enddef; def >| == (_com,_len_e) enddef;
- def |<< == (_com,_len_ss) enddef; def >>| == (_com,_len_ee) enddef;
- def |=primary n == |<,(_chg_len,n) enddef; def =| == >| enddef; def :| == (_com,_rest) 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 '(text TXT)== read_mcf(incr parts_cnt)(|,``crR,TXT,:|); parts_cnt enddef;
- def CP == com_par enddef;
- def CPe == com_par_ex(0) enddef;
- def CPx == com_par_ex(1) 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;
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;
%=================================================================================================
def read_mcf(expr n)(text TXT)=
@@ -371,8 +362,12 @@ def read_mcf(expr n)(text TXT)=
else:: nCP:=nCP+1; comD[n][nCP]:=_mk_bond; parD[n][nCP]:=list;
fi
elseif string list::
- str_cnt:=str_cnt+1; strD[str_cnt]:=list;
- nCP:=nCP+1; comD[n][nCP]:=_set_atom; parD[n][nCP]:=str_cnt;
+ 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
fi
else:: message "unknown command in "AND decimal(n);
fi
@@ -440,8 +435,6 @@ vardef change_bond(expr a,b) =
CP(_set_adr,-4) CP(_set_line,dl)
elseif b==Ph2:: fuse_ring(a,6) CP(_set_adr,-1) CP(_set_line,dl)
CP(_set_adr,-3) CP(_set_line,dl) CP(_set_adr,-5) CP(_set_line,dl)
- elseif b==_jump_at:: CP(_jp_bond,a)
- elseif b==_connect_at:: CP(_cyc_sB,a)
elseif comD[b][1]==_fuse::
if comD[b][2]<=6:: fuse_ring_bonds(a,parD[b][1],comD[b][2])
elseif (comD[b][2]>=11)and(comD[b][2]<=15):: fuse_ring_size(a,parD[b][1],comD[b][2])
@@ -461,7 +454,7 @@ vardef change_atom(expr a,b)=
nCP:=0;
if numeric b::
if (b GT parts_emb_start)and(b<=parts_atom_end):: CPe(a)(_chg_atom,b)
- ef b==NH:: CPe(a)(_chg_atom,N) CP(_tmp_line,nl)
+ ef b==NH:: CPe(a)(_chg_atom,N) if NH<>xNH:: CP(_tmp_line,nl) fi
CP(_com,_group_s) CPx(a)(_group_si,H) CP(_com,_group_e)
ef b==N!:: CPe(a)(_chg_atom,N) CP(_com,_group_s) CPx(a)(_group_si,_) CP(_com,_group_e)
ef b==N!2:: CPe(a)(_chg_atom,N) CP(_com,_group_s) CPx(a)(_group_si,!) CP(_com,_group_e)
@@ -472,14 +465,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==_jump_at:: CP(_jp_atom,a)
- ef b==_connect_at:: CP(_cyc,a)
- fi
- ef pair b::
- if xpart(b)==_set_and:: CP(_set_and,ypart(b)) CP(_chg_and,a)
- else:: CP(_com,_group_s) CPx(a)(xpart(b),ypart(b)) CP(_com,_group_e)
fi
- ef color b:: color_list[incr cntC]:=b; CPe(a)(_set_colorA,cntC)
+ 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;
parts_int %------- Retern value -------
@@ -740,21 +729,21 @@ enddef;
%-------------------------------------------------------------------------------------------------
def MC(text TXT)=
begingroup
- save f_bra,strAT,cnt_group,temp_lenE,temp_lenF,temp_cntB,f_end,f_term,f_at,f_lineT,f_rotT,
+ 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;
pair temp_p;
%-----------------------------------------------------------------------------------------------
if (sw_numberA>=1)or(sw_numberB>=1): ratio_atom_bond:=0.25; fi
- if (sw_expand=1)or(sw_mol_out>=1): expand_set; fi
- cntA:=cntB:=cnt_group:=cntC:=0; strD[0]:="C"; str_cnt:=2000; crR:=-ratio_chain_ring;
+ if (sw_expand=1)or(sw_mol_out>=1): expand_set; crR:=1; else: crR:=-ratio_chain_ring; fi
+ cntA:=cntB:=cnt_group:=cntC:=0; strD[0]:="C"; str_cnt:=2000;
%-----------------------------------------------------------------------------------------------
font_wd:=xpart(fsize);
font_ht:=ypart(fsize);
margin_lr:=xpart(fmargin);
margin_tb:=ypart(fmargin);
%===============================================================================================
- read_mcf(0)(TXT,|||);
+ read_mcf(0)(TXT,(_com,_term));
proc_bond_atom(0)(1);
if (cnt_group>0)and(sw_group_off=0): read_group(0)(1); fi
char_use_check;
@@ -777,28 +766,24 @@ def MC(text TXT)=
else: factor:=((font_wd-2margin_lr)*xpart(msize))/mol_wd;
fi
fi
- exitif (factor>=1-eps)and(factor<=1+eps);
- blen:=blen*factor;
- proc_size_setup;
+ exitif (factor>=1-eps)and(factor<=1+eps); blen:=blen*factor; proc_size_setup;
endfor
- if blen>max_blength:
- blen:=max_blength; proc_size_setup; proc_skeleton(0); proc_scaling;
- fi
+ if blen>max_blength: blen:=max_blength; proc_size_setup; proc_skeleton(0); proc_scaling; fi
fi
- %-draw atom--------------------------------------------------------------------------------------
+ %-draw atom-------------------------------------------------------------------------------------
if (sw_numberA=0)and(sw_numberB=0): for i=1 upto cntA: draw_atom(i); endfor fi
- %-draw charge------------------------------------------------------------------------------------
+ %-draw add to atom------------------------------------------------------------------------------
for i=1 upto cntA:
- if andA[i]<>0:
- sA:=char(andA[i]); nA:=angX[i]+and_rot[i]; nC:=nA mod 90;
+ 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
if numS[i]=0: nB:=.5atom_wd;
- else: nB:=.85atom_wd+iif(nC<45,sind(nC),cosd(nC))*.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);
- else: sA:="";
+ else: chargeA[i]:=0;
fi
- if sA="+": chargeA[i]:=1; elseif sA="-": chargeA[i]:=-1; else: chargeA[i]:=0; fi
endfor
%-draw bond-------------------------------------------------------------------------------------
for i=1 upto cntB: if lineB[i]<si_ : draw_bond(i); fi endfor
@@ -950,12 +935,12 @@ def char_use_check=
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def proc_bond_atom(expr a)(expr n)=
- f_bra:=f_end:=f_term:=rotT:=f_lineT:=f_rotT:=f_lenT:=f_envT:=envT:=envB:=strAT:=f_at:=0;
+ f_bra:=f_term:=rotT:=f_lineT:=f_rotT:=f_lenT:=f_envT:=envT:=envB:=strAT:=f_at:=0;
bondL:=crR; lenT:=crR; sB[0]:=0; eB[0]:=1; lineT:=si;
- andAT:=markA:=markB:=saveA:=saveB:=0;
+ addAT:=markA:=markB:=saveA:=saveB:=0;
%-----------------------------------------------------------------------------------------------
for i=n upto cntD[a]: com:=comD[a][i]; par:=parD[a][i];
- if com=_mk_bond: if (par=0)and(rotT<>0): rotT:=0; fi add_atom;
+ if com=_mk_bond: if (par=0)and(rotT<>0): rotT:=0; fi add_atom(0);
ef com=_set_adr: adrT:=par;
ef com=_com: if par=_mark: saveA:=markA; saveB:=markB; markA:=cntA; markB:=cntB;
ef par=_rest: markA:=saveA; markB:=saveB;
@@ -982,28 +967,29 @@ def proc_bond_atom(expr a)(expr n)=
ef com=_set_line: lineB[getB(adrT)]:=par;
ef com=_tmp_line: lineT:=par;
ef com=_tmp_rot: rotT:=par;
- ef com=_cyc: f_end:=getA(par); check_adrA(f_end); add_atom;
- ef com=_cyc_eB: f_end:=eB[getB(par)]; add_atom;
- ef com=_cyc_sB: f_end:=sB[getB(par)]; add_atom;
+ ef com=_cyc: check_adrA(getA(par)); add_atom(getA(par));
+ ef com=_cyc_eB: add_atom(eB[getB(par)]);
+ ef com=_cyc_sB: add_atom(sB[getB(par)]);
ef com=_chg_env: envB:=par;
ef com=_tmp_env: envT:=par;
ef com=_set_colorA: colorA[getA(adrT)]:=par;
ef com=_set_colorB: colorB[getB(adrT)]:=par;
- ef com=_set_and: andAT:=par;
- ef com=_chg_and: andA[getA(par)]:=andAT; andAT:=0; if rotT<>0: and_rot[getA(par)]:=rotT; fi
+ ef com=_set_add: addAT:=par;
+ ef com=_chg_add: addA[getA(par)]:=addAT; addAT:=0; if rotT<>0: add_rot[getA(par)]:=rotT; fi
else:
fi
endfor
enddef;
%-------------------------------------------------------------------------------------------------
-def add_atom=
+def add_atom(expr n)=
cntB:=cntB+1; lineB[cntB]:=lineT; lineT:=si;
if lenT=crR: lenB[cntB]:=bondL; else: lenB[cntB]:=lenT; lenT:=crR; fi
if f_bra=0: cntA:=cntA+1; sB[cntB]:=cntA; numS[cntA]:=strAT;
- andA[cntA]:=andAT; andAT:=strAT:=and_rot[cntA]:=0;
- if rotT<>0: and_rot[cntA]:=rotT; rotT:=0; fi
- if f_MP=1: colorA[cntA]:=colorB[cntA]:=0; fi else: f_bra:=0; fi
- if f_end=0: eB[cntB]:=cntA+1; f_term:=0; else: eB[cntB]:=f_end; f_end:=0; f_term:=1; fi
+ addA[cntA]:=addAT; addAT:=strAT:=add_rot[cntA]:=0;
+ if rotT<>0: add_rot[cntA]:=rotT; rotT:=0; fi
+ if f_MP=1: colorA[cntA]:=colorB[cntA]:=0; fi
+ else: f_bra:=0; fi
+ if n=0: eB[cntB]:=cntA+1; f_term:=0; else: eB[cntB]:=n; f_term:=1; fi
enddef;
%--------------------------------------------------------------------------------------------------
def check_adrA(expr n)=
@@ -1012,20 +998,20 @@ enddef;
def check_adrB(expr n)= if (n>cntB)or(n<=0): errmessage("cntB=[ "&decimal(n)&" ]"); fi enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def proc_skeleton(expr a)=
- markA:=markB:=cntA:=cntB:=f_end:=f_bra:=rotT:=f_term:=0;
+ markA:=markB:=cntA:=cntB:=f_bra:=rotT:=f_term:=0;
envT:=envB:=f_lineT:=f_rotT:=f_lenT:=f_envT:=0; lineT:=si; angT:=mangle;
angA[0]:=angB[0]:=angX[0]:=0; posA[0]:=posBs:=posBe:=(0,0);
%-----------------------------------------------------------------------------------------------
for i=1 upto cntD[a]: com:=comD[a][i]; par:=parD[a][i];
- if com=_mk_bond: if (par=0)and(rotT<>0):par:=rotT; rotT:=0; fi add_bond(par);
+ if com=_mk_bond: if (par=0)and(rotT<>0):par:=rotT; rotT:=0; fi add_bond(par,1);
ef com=_com: if par=_mark: saveA:=markA; saveB:=markB; markA:=cntA; markB:=cntB;
ef par=_rest: markA:=saveA; markB:=saveB;
ef par=_moff: markA:=markB:=0; ef par=_term: termB;
ef par=_group_e: lineT:=si; lenT:=crR; rotT:=envT:=0; fi
- ef com=_jp_bond: termB; nA:=getB(par); posBs:=posA[sB[nA]]; angT:=angB[nA]; f_bra:=1; rotT:=0;
+ ef com=_jp_bond: termB; nA:=getB(par); posBs:=posA[sB[nA]]; angT:=angB[nA]; f_bra:=1; rotT:=0;
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;
+ 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;
@@ -1033,49 +1019,44 @@ def proc_skeleton(expr a)=
ef com=_group_si: rotT:=0;
ef com=_chg_env: envB:=par;
ef com=_tmp_env: envT:=par;
- ef com=_cyc: f_end:=1; proc_cyc(getA(par));
- ef com=_cyc_sB: f_end:=1; proc_cyc(sB[getB(par)]);
- ef com=_cyc_eB: f_end:=1; proc_cyc(eB[getB(par)]);
+ ef com=_cyc: add_bond(angle(posA[getA(par)]-posBs)-angT,0);
+ ef com=_cyc_sB: add_bond(angle(posA[sB[getB(par)]]-posBs)-angT,0);
+ ef com=_cyc_eB: add_bond(angle(posA[eB[getB(par)]]-posBs)-angT,0);
else:
fi
endfor
enddef;
%-------------------------------------------------------------------------------------------------
-def add_bond(expr ROT)=
- if ROT=_arg_ang:
- if cntB=0: angT:=(angT-180) mod 360; nA:=180;
- else:
- nB:=(angT mod 360);
- if envB>=parts_emb_start: nA:=parD[envB][cntB-temp_cntB+2];
- else:
- if envB=hz:
- if nB=0:nA:= 60;ef nB<=90:nA:=-60;ef nB<=180:nA:= 60;ef nB<270:nA:=-60;else:nA:= 60; fi
- ef envB=vt:
- if nB=0:nA:=-60;ef nB<90: nA:= 60;ef nB<=180:nA:=-60;ef nB<=270:nA:=60;else:nA:=-60; fi
- ef (envB>=-180)and(envB<=180): nA:=envB;
- fi
- fi
- fi
- else: nA:=ROT;
- fi
+def add_bond(expr ROT,FLG)=
+ if ROT=_arg_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;
else: f_bra:=0;
fi
- angB[cntB+1]:=angT:=(angT+nA) mod 360;
- if f_end=0:
- if lenB[cntB+1]=_size_atom: posBe:=sfrt(posBs,atom_wd,angT);
+ cntB:=cntB+1; angB[cntB]:=angT:=(angT+nA) mod 360;
+ if FLG=1:
+ if lenB[cntB]=_size_atom: posBe:=sfrt(posBs,atom_wd,angT);
else:
- nA:=lenB[cntB+1];
+ nA:=lenB[cntB];
if nA<0: nB:=glu_atom(adrT)+glu_atom(cntA+1); nA:=abs(nA); else: nB:=0; fi
posBe:=sfrt(posBs,nA*blen+nB,angT);
fi
posA[cntA+1]:=posBe; f_term:=0;
+ else: f_term:=1;
+ fi
+ posBs:=posBe;
+enddef;
+%-------------------------------------------------------------------------------------------------
+vardef arrange_ang(expr n)=
+ if cntB=0: angT:=(angT-180) mod 360; 180
else:
- f_end:=0; f_term:=1;
+ 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
+ ef abs(envB)<=180: envB fi
+ fi
fi
- cntB:=cntB+1; posBs:=posBe;
enddef;
%=================================================================================================
vardef getA(expr n)= if n>=0: markA+n ef n>=-999: cntA+n+1 else: n+4095 fi enddef;
@@ -1084,8 +1065,8 @@ vardef getB(expr n)= if n>=0: markB+n ef n>=-999: cntB+n+1 else: n+4095 fi endde
def termA=
if f_term=0:
if f_bra=0:
- cntA:=cntA+1; numS[cntA]:=strAT; andAT:=strAT:=and_rot[cntA]:=andA[cntA]:=0;
- if rotT<>0: and_rot[cntA]:=rotT; rotT:=0; fi
+ cntA:=cntA+1; numS[cntA]:=strAT; addA[cntA]:=addAT; add_rot[cntA]:=rotT;
+ addAT:=strAT:=rotT:=0;
if f_MP=1: colorA[cntA]:=0; fi
else: f_bra:=0;
fi
@@ -1094,11 +1075,9 @@ def termA=
enddef;
%-------------------------------------------------------------------------------------------------
def termB=
- if f_term=0: if f_bra=0: cntA:=cntA+1; angX[cntA]:=angT mod 360; else:f_bra:=0; fi f_term:=1; fi
+ if f_term=0: if f_bra=0:cntA:=cntA+1; angX[cntA]:=angT mod 360; else:f_bra:=0; fi f_term:=1; fi
enddef;
%-------------------------------------------------------------------------------------------------
-def proc_cyc(expr n)= add_bond(angle(posA[n]-posBs)-angT); enddef;
-%-------------------------------------------------------------------------------------------------
vardef glu_atom(expr NUM)=
if numS[NUM]<>0: nE:=angT mod 90; nF:=0.5atom_wd;(iif(nE<45,sind(nE),cosd(nE))*nF)++nF else: 0 fi
enddef;
@@ -1407,7 +1386,7 @@ 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 andA[a]=0:
+ if addA[a]=0:
warning("A"&decimal(a)&" ( "&fixed_l(8)(strD[numS[a]])&") has"&fdr(2)(bond_cnt)&" bonds");
fi
enddef;
@@ -1419,7 +1398,9 @@ vardef cut_paren(expr ATOM)=
if (length(ATOM)>=4)and(ATOM<>"COOH"):
for i=0 upto length(ATOM)-1:
temp_c:=subc(i,ATOM);
- if (temp_c<>"{")and(temp_c<>"}")and(temp_c<>"_")and(temp_c<>"^"): temp_s:=temp_s&temp_c; fi
+ if (temp_c<>"{")and(temp_c<>"}")and(temp_c<>"_")and(temp_c<>"^")
+ and(temp_c<>"+")and(temp_c<>"-"):
+ temp_s:=temp_s&temp_c; fi
endfor
temp_s
else: ATOM
@@ -1433,9 +1414,6 @@ def proc_calc=
nE:=parts_emb_start;
for i=1 upto tbl_atom_end: sumA[i]:=0; endfor
for i=1 upto cntA:
- if (numS[i]>str_plus)and(numS[i]<=str_minus): chargeA[i]:=1;
- elseif (numS[i]>str_minus)and(numS[i]<=str_minus_end): chargeA[i]:=-1;
- fi
knownA:=bond_cnt:=0;
nS:=numS[i];
for j=1 upto cntB:
@@ -1502,9 +1480,9 @@ def proc_calc=
else: num_MW:=cen_MW; cal_MW:=fdr(6)(cen_MW)&"*100"; fi
if cen_MI<40: cal_MI:=substring (0,10) of decimal(num_MI);
else: num_MI:=cen_MI; cal_MI:=fdr(8)(cen_MI)&"*100"; fi
- if sw_aux_out>=1: proc_auxfile_out; fi
- if sw_rep_out=1: proc_report_out; fi
- if sw_mol_out>=1: proc_mol_out; fi
+ if (sw_aux_out>=1)and(cntM=1): proc_auxfile_out; fi
+ if (sw_rep_out=1)and(cntM=1): proc_report_out; fi
+ if (sw_mol_out>=1)and(cntM=1): proc_mol_out; fi
endgroup
enddef;
%=================================================================================================
@@ -1606,76 +1584,59 @@ def proc_report_out=
enddef;
%=================================================================================================
def proc_mol_out=
- begingroup
- save chg_cnt,chg_atm,chg_chg;
- nA:=nB:=chg_cnt:=0;
message "["&decimal(char_num)&"]:"&inf_EN;
out_file_name:=out_file_mol;
- if sw_mol_out<=2:
- out_file_name:=out_file_mol;
- if sw_mol_out=1: proc_vdk; elseif sw_mol_out=2: proc_vtk; fi
- fi
- endgroup
-enddef;
-%-V2000------------------------------------------------------------------------------------------
-def proc_vdk=
- printf ""; printf " -MCFtoMOL- "&fixed_l(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 0 0 0";
- if chargeA[i]<>0: chg_atm[incr chg_cnt]:=i; chg_chg[chg_cnt]:=chargeA[i]; fi
- endfor
- for i=1 upto cntB:
- if lineB[i]<>0:
- proc_bond_class(lineB[i]);
- printf fdr(3)(sB[i])&fdr(3)(eB[i])&fdr(3)(nA)&fdr(3)(nB)&" 0 0";
- fi
- endfor
- if chg_cnt>0:
- printf "M CHG"&fdr(3)(chg_cnt)
- for i=1 upto chg_cnt: &fdr(4)(chg_atm[i])&fdr(4)(chg_chg[i]) endfor;
+ %-V2000---------------------------------------------------------------------------------------
+ if sw_mol_out=1:
+ printf ""; printf " -MCFtoMOL- "&fixed_l(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";
+ endfor
+ for i=1 upto cntB:
+ if lineB[i]<>0:
+ printf fdr(3)(sB[i])&fdr(3)(eB[i])&fdr(3)(bond_type(lineB[i]))&
+ fdr(3)(bond_stereo(lineB[i]))&" 0 0";
+ fi
+ endfor
+ printf "M END";
+ %-V3000---------------------------------------------------------------------------------------
+ elseif sw_mol_out=2:
+ printf ""; printf " -MCFtoMOL- "&fixed_l(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]])&" "&
+ decimal(xpart(posA[i])/blen)&" "&decimal(ypart(posA[i])/blen)&" 0 0"
+ if chargeA[i]<>0: &" CHG="&decimal(chargeA[i]) fi;
+ endfor
+ printf "M V30 END ATOM"; printf "M V30 BEGIN BOND";
+ for i=1 upto cntB:
+ if lineB[i]<>0:
+ printf "M V30 "&decimal(i)&" "&decimal(bond_type(lineB[i]))&
+ " "&decimal(sB[i])&" "&decimal(eB[i])
+ if bond_stereo(lineB[i])<>0: &" CFG="&decimal(bond_config(lineB[i])) fi;
+ fi
+ endfor
+ printf "M V30 END BOND"; printf "M V30 END CTAB"; printf "M END";
fi
- printf "M END";
-enddef;
-%-V3000---------------------------------------------------------------------------------------
-def proc_vtk=
- printf ""; printf " -MCFtoMOL- "&fixed_l(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]])&" "&
- decimal(xpart(posA[i])/blen)&" "&decimal(ypart(posA[i])/blen)&" 0 0"
- if chargeA[i]<>0: &" CHG="&decimal(chargeA[i]) fi;
- endfor
- printf "M V30 END ATOM";
- printf "M V30 BEGIN BOND";
- for i=1 upto cntB:
- if lineB[i]<>0:
- proc_bond_class(lineB[i]);
- printf "M V30 "&decimal(i)&" "&decimal(nA)&" "&decimal(sB[i])&" "&decimal(eB[i]);
- fi
- endfor
- printf "M V30 END BOND";
- printf "M V30 END CTAB";
- printf "M END";
enddef;
%-------------------------------------------------------------------------------------------------
vardef fit_zero(expr n)=if n<=9: "00" elseif n<=99: "0" else: "" fi &decimal(n) enddef;
%-------------------------------------------------------------------------------------------------
-def proc_bond_class(expr n)=
- if (n=dl)or(n=dr)or(n=dm): nA:=2;
- ef n=tm: nA:=3;
- ef (n=wf)or(n=zb)or(n=bd): nB:=1;
- ef (n=zf)or(n=wb)or(n=dt): nB:=6;
- ef n=wv: nB:=4;
- else: nA:=1; nB:=0;
- fi
-enddef;
+vardef bond_type(expr n)=
+ if (n=dl)or(n=dr)or(n=dm)or(n=db)or(n=dl_)or(n=dr_)or(n=dm_): 2 ef n=tm: 3 else: 1 fi enddef;
+%-------------------------------------------------------------------------------------------------
+vardef bond_charge(expr n)= if n=2: 1 ef n=1: 3 ef n=-1: 5 ef n=-2: 6 else: 0 fi enddef;
+%-------------------------------------------------------------------------------------------------
+vardef bond_stereo(expr n)=
+ if (n=wf)or(n=zb)or(n=bd): 1 ef (n=zf)or(n=wb)or(n=dt): 6 ef n=wv: 4 else: 0 fi enddef;
+%-------------------------------------------------------------------------------------------------
+vardef bond_config(expr n)=
+ if (n=wf)or(n=zb)or(n=bd): 1 ef (n=zf)or(n=wb)or(n=dt): 3 ef n=wv: 2 else: 0 fi enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
vardef STa(expr ATOM,WT,MI)=
str_cnt:=str_cnt+1; tbl_cnt:=tbl_cnt+1; parts_cnt:=parts_cnt+1;
@@ -1717,10 +1678,10 @@ N:= STa("N" ,14.0067, 14.00307400443); Na:=STa("{Na}",22.98977, 22.989769
Ni:=STa("{Ni}",58.693, 57.93534241); O:= STa("O" ,15.9994, 15.99491461957);
P:= STa("P" ,30.973762, 30.97376199842); Pb:= STa("Pb" ,207.2, 205.974455);
Pd:=STa("Pd" ,106.4, 107.905075);
-S:= STa("S" ,32.065, 31.9720711744); Sb:= STa("Sb" ,121.75, 0.0);
+S:= STa("S" ,32.065, 31.9720711744); Sb:= STa("Sb" ,121.75, 120.90381);
Se:=STa("{Se}",78.971, 79.9165218); Si:=STa("{Si}",28.0855, 27.97692653465);
Sn:=STa("{Sn}",118.71, 119.90220163); Ti:=STa("{Ti}",47.867, 47.94794198);
-U:= STa("U", 238.0289, 238.05079); V:= STa("V", 50.9415, 0.0);
+U:= STa("U", 238.0289, 238.05079); V:= STa("V", 50.9415, 50.943957);
W:= STa("W", 183.85, 181.948225); Zn:=STa("{Zn}",65.409, 63.92914201);
tbl_atom_end:=tbl_cnt;
%-------------------------------------------------------------------------------------------------
@@ -1730,23 +1691,16 @@ NO:=STb("NO")(N,O); NO2:=STb("N{O_2_}")(N,O,O); NH2:=STb("N{H_2_}")(N,H,H);
SO2H:=STb("S{O_2_}H")(S,O,O,H); SO3H:=STb("S{O_3_}H")(S,O,O,O,H);
ONa:=STb("O{Na}")(O,Na); SO3Na:=STb("S{O_3_}{Na}")(S,O,O,O,Na);
%-------------------------------------------------------------------------------------------------
-str_plus:=str_cnt;
-N[1]:=STb("{N^+^}")(N); H[1]:=STb("{H^+^}")(H); Na[1]:=STb("{Na^+^}")(Na); K[1]:=STb("{K^+^}")(K);
-NH3[1]:= STb("{N^+^}{H_3_}")(N,H,H,H); NH4[1]:= STb("{N^+^}{H_4_}")(N,H,H,H,H);
-S[1]:= STb("{S^+^}")(S);
-str_minus:=str_cnt;
-O[-1]:=STb("{O^-^}")(O); COO[-1]:=STb("COO^-^")(C,O,O); SO3[-1]:=STb("S{O_3_}^-^")(S,O,O,O);
-Cl[-1]:=STb("{Cl^-^}")(Cl); Br[-1]:=STb("{Br^-^}")(Br); I[-1]:=STb("{I^-^}")(I);
-%-------------------------------------------------------------------------------------------------
-str_minus_end:=str_cnt;
tbl_group_end:=tbl_cnt;
parts_atom_end:=parts_cnt;
%=================================================================================================
-for i==3 upto 20: ?[i]:='(|<<,(_get_len,_ring_len),<((-180 DIV i)-90)
- for j==2 upto i:: ,(360 DIV i) endfor,(_cyc_sB,1-i),>>|); endfor
+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);
-for i==2 upto 20: ![i]:='(|<<,(_get_len,_tmp_len),! for j==2 upto i::,! endfor ,>>|); endfor
+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); !?!:='(!,?!); !??!:='(!,??!);
%-------------------------------------------------------------------------------------------------
NH:='(N,/H~nl); N!:='(N,/_); N!2:='(N,/!); SO:='(S,//O); SOO:='(S,//O^-35,//O^35);