diff options
-rw-r--r-- | Master/texmf-dist/doc/metapost/mcf2graph/CHANGELOG | 6 | ||||
-rw-r--r-- | Master/texmf-dist/doc/metapost/mcf2graph/README | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/metapost/mcf2graph/mcf_example.pdf | bin | 246539 -> 246546 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/metapost/mcf2graph/mcf_man_soc.mf | 6 | ||||
-rw-r--r-- | Master/texmf-dist/doc/metapost/mcf2graph/mcf_manual.pdf | bin | 424900 -> 425268 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/metapost/mcf2graph/mcf_manual.tex | 10 | ||||
-rw-r--r-- | Master/texmf-dist/doc/metapost/mcf2graph/mcf_mplib_exa.pdf | bin | 122124 -> 122137 bytes | |||
-rw-r--r-- | Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf | 846 |
8 files changed, 451 insertions, 419 deletions
diff --git a/Master/texmf-dist/doc/metapost/mcf2graph/CHANGELOG b/Master/texmf-dist/doc/metapost/mcf2graph/CHANGELOG index 14416e27018..446920fa3c9 100644 --- a/Master/texmf-dist/doc/metapost/mcf2graph/CHANGELOG +++ b/Master/texmf-dist/doc/metapost/mcf2graph/CHANGELOG @@ -1,6 +1,10 @@ ******************************************************************************* - Changelog of mcf2graph software package by Akira Yamaji 2016-10-19 + Changelog of mcf2graph software package by Akira Yamaji 2016-10-23 ******************************************************************************* +[ver. 4.01 / 2016-10-23] + -many fixes for robustness + -update MCF syntax manual + [ver. 4.00 / 2016-10-19] -change solid mode parameter 1:solid ratio,2:solid length diff --git a/Master/texmf-dist/doc/metapost/mcf2graph/README b/Master/texmf-dist/doc/metapost/mcf2graph/README index f15f95db01b..7c064a1881c 100644 --- a/Master/texmf-dist/doc/metapost/mcf2graph/README +++ b/Master/texmf-dist/doc/metapost/mcf2graph/README @@ -1,7 +1,7 @@ ******************************************************************************** mcf2graph : Convert Molecular Coding Format to graphics with METAFONT/METAPOST Author : Akira Yamaji - version : 4.00 2016-10-19 + version : 4.01 2016-10-23 E-mail : mcf2graph@gmail.com Located at : http://www.ctan.org/pkg/mcf2graph ******************************************************************************** diff --git a/Master/texmf-dist/doc/metapost/mcf2graph/mcf_example.pdf b/Master/texmf-dist/doc/metapost/mcf2graph/mcf_example.pdf Binary files differindex 344ff649809..e1842b93b60 100644 --- a/Master/texmf-dist/doc/metapost/mcf2graph/mcf_example.pdf +++ b/Master/texmf-dist/doc/metapost/mcf2graph/mcf_example.pdf diff --git a/Master/texmf-dist/doc/metapost/mcf2graph/mcf_man_soc.mf b/Master/texmf-dist/doc/metapost/mcf2graph/mcf_man_soc.mf index ac215938a39..70380700644 100644 --- a/Master/texmf-dist/doc/metapost/mcf2graph/mcf_man_soc.mf +++ b/Master/texmf-dist/doc/metapost/mcf2graph/mcf_man_soc.mf @@ -419,11 +419,11 @@ beginfont("EN:substituent 3") endfont %*********************************************************************** beginfont("EN:substituent 4") - font_ht#:=15mm#; + font_ht#:=17mm#; sw_clip:=1; margin_top_bottom:=2mm; - sw_numberA:=1; numberA_end:=9; - MCf(<-30,!6,@(2~wf,4~zf,6^-30)/H) + sw_numberA:=1; numberA_end:=7; + MCf(<-30,!6,@(2~wf,4~zf,6^-30)/Me) endfont %*********************************************************************** beginfont("EN:substituent 5") diff --git a/Master/texmf-dist/doc/metapost/mcf2graph/mcf_manual.pdf b/Master/texmf-dist/doc/metapost/mcf2graph/mcf_manual.pdf Binary files differindex 3a928ca1b33..7f52968e2da 100644 --- a/Master/texmf-dist/doc/metapost/mcf2graph/mcf_manual.pdf +++ b/Master/texmf-dist/doc/metapost/mcf2graph/mcf_manual.pdf diff --git a/Master/texmf-dist/doc/metapost/mcf2graph/mcf_manual.tex b/Master/texmf-dist/doc/metapost/mcf2graph/mcf_manual.tex index 8f4e56a582c..f3fc19b2fee 100644 --- a/Master/texmf-dist/doc/metapost/mcf2graph/mcf_manual.tex +++ b/Master/texmf-dist/doc/metapost/mcf2graph/mcf_manual.tex @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Molecular Coding Format manual by Akira Yamaji 2016.10.19 +% Molecular Coding Format manual by Akira Yamaji 2016.10.23 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \documentclass[a4paper]{article} %%%%\usepackage{graphicx} @@ -449,7 +449,7 @@ pk font,PNG,SVG,EPS or MDL MOL file(V2000).\\ ~,^,` : change type,angle,length <-30,!6, - @(2~wf,4~zf,6^-30)/H + @(2~wf,4~zf,6^-30)/Me \end{verbatim} \MCFstructure %----------------------------------------------------------------------------- @@ -1066,7 +1066,7 @@ bye \end{verbatim} \paragraph{(Command line)} \begin{verbatim} - >mpost -s ahangle=0 FILENAME (molecular difinition file) + >mpost -s ahangle=0 FILENAME (molecular definition file) \end{verbatim} \paragraph{(Output)} \begin{verbatim} @@ -1099,7 +1099,7 @@ MW : molecular weight from literature data \end{verbatim} \paragraph{(Command line)} \begin{verbatim} - >mpost -s ahangle=0 -s ahlength=2 FILENAME (molecular difinition file) + >mpost -s ahangle=0 -s ahlength=2 FILENAME (molecular definition file) \end{verbatim} \paragraph{(Output)} \begin{verbatim} @@ -1161,7 +1161,7 @@ MW : molecular weight from literature data \end{verbatim} \paragraph{(Command line)} \begin{verbatim} - >mpost -s ahangle=3 FILENAME (molecular difinition file) + >mpost -s ahangle=3 FILENAME (molecular definition file) \end{verbatim} \paragraph{(Output)} \begin{verbatim} diff --git a/Master/texmf-dist/doc/metapost/mcf2graph/mcf_mplib_exa.pdf b/Master/texmf-dist/doc/metapost/mcf2graph/mcf_mplib_exa.pdf Binary files differindex 58823d3eb6f..c7ab56140a7 100644 --- a/Master/texmf-dist/doc/metapost/mcf2graph/mcf_mplib_exa.pdf +++ b/Master/texmf-dist/doc/metapost/mcf2graph/mcf_mplib_exa.pdf diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf index 2a0146315ab..b3461a03db1 100644 --- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf +++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% mcf2graph ver 4.00 Copyright (c) 2013-2016 Akira Yamaji +% mcf2graph ver 4.01 Copyright (c) 2013-2016 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, @@ -32,13 +32,12 @@ tracingstats:=1; message " This is mcf2graph ver 4.0 2016.10"; %------------------------------------------------------------------------------------------------- -newinternal nA,nB,nC,nD,nE,nF,cntA,cntB,minX,minY,sftX,sftY; +newinternal nA,nB,nC,nD,nE,nF,cntA,cntB,cntP,minX,minY,def_num,def_int,tbl_cnt; pair posB[],posA[]; -numeric angB[],angA[],br_ang[],sB[],eB[],f_char[],char_w[],char_h[],char_d[],strA[],str_wd[], - lineB[],lenB[],ps_com[],ps_adr[],op_com[][],op_par[][],op_cnt[], - comMC[][],parMC[][],cntMC[],tblN[],tblB[][],tblWt[],colorA[],colorB[],stock_para[], - CH[],NH[],NO[],SO[],CCl[],CF[],CBr[],?[],![],Ph[]; -string info[],tblA[],com_str[],var[],tag[],mp_log_name,aux_delimiter; +numeric lineB[],sB[],eB[],angB[],angA[],strA[],str_wd[],lenB[],ang_br[],stock_para[], + tbl_char_wd[],tbl_char_ht[],tbl_char_dp[],tbl_atom[],tbl_subst[][],tbl_atom_wt[], + comMC[][],parMC[][],cntMC[]; +string info[],tbl_atom_str[],com_str[],var[],tag[],mp_log_name,aux_delimiter; picture atom_font[],chem_structure; %------------------------------------------------------------------------------------------------- sw_numberA:=sw_numberB:=sw_mol_frame:=sw_auxout:=sw_solid:=sw_expand:=sw_start_vector:=0; @@ -48,7 +47,8 @@ numberA_start:=numberB_start:=1; numberA_end:=numberB_end:=4095; aux_max:=20; aux_delimiter:=";"; var1:="jobname"; tag1:="F"; var2:="char_num"; tag2:="C"; for i=3 upto aux_max: var[i]:=tag[i]:=""; endfor %================================================================================================= -if known green: f_MP:=1; +if (known green)and(known ahlength): + f_MP:=1; color color_list[]; mp_log_name:=jobname&"-info.aux"; if ahlength=1: proc_end:=1; fi % first molecular only @@ -71,27 +71,30 @@ else: f_MP:=0; fi ahangle:=45; ahlength:=4; clearit; chem_structure:=currentpicture; -%------------------------------------------------------------------------------------------------- +%-------------------------------------------------------------------------------------------------- let DIV= /; let MUL= *; let LT= <; let GT= >; let AND= &; let :: = : ; let == = =; -primarydef a SUB b = a-b enddef; +%-------------------------------------------------------------------------------------------------- ?3:=?20:=Ph:=Ph1:=Ph2:=hz:=0; vt:=1; -first_def_number:=500; user_def_number:=2500; ab_def_number:=3000; margin_left_right:=margin_top_bottom:=0.4mm; ratio_bond_width:=0.1; ratio_chain_ring:= 0.66; ratio_atom_bond:=0.36; ratio_thickness_bond:=0.015; ratio_char_bond:=1.5; ratio_bondgap_bond:=0.15; ratio_zebragap_bond:=0.12; -ratio_zebra_black:=0.4; ratio_wedge_bond:=0.12; ratio_atomgap_atom:=.050; +ratio_zebra_black:=0.4; ratio_wedge_bond:=0.12; ratio_atomgap_atom:=0.050; offset_thickness#:=0.2pt#; offset_bond_gap#:=0.3pt#; offset_zebra_gap#:=0.1pt#; offset_atom#:=0.8pt#; offset_wedge#:=0.4pt#; thickness_font_frame#:=0.2pt#; max_bond_length#:=10mm; bond_len#:=8mm#; -par_s=ASCII("{"); par_e=ASCII("}"); score_u=ASCII("_"); hat=ASCII("^"); max_inf_num:=12; for i:=1 upto max_inf_num: info[i]:=":"; endfor +%-------------------------------------------------------------------------------------------------- +def_emb_start:=500; % 500 => 2499 for embedded definition (max 2000) +def_usr_start:=2500; % 2500 => 2999 for user definition (max 500) +def_int_start:=3000; % 3000 => 4000 for internal definition (max 1000) +%-------------------------------------------------------------------------------------------------- def def_com(expr n)(text tx)= nA:=n; forsuffixes list=tx:: list:=nA; nA:=nA+1; endfor enddef; def_com(-4000)(_term,_jp_atom,_jp_atom_abs,_jp_bond,_cyc,_cyc_sB,_cyc_eB,_set_line,_chg_line, _dl,_N,_O,_S,_H,_tmp_line,_chg_len,_get_len,_ring_len,_tmp_len,_rot_ang,_set_ang,_adj_ang,_chg_env, _tmp_env,_set_colorA,_set_colorB,_postA,_postB,_postC,_postD,_postE,_postF,_set_psA,_stack_reset, _set_clr,_set_adr,_mk_bond,_set_atom,_arg_ang,_chg_atom,_tmp_rot,_fuse,_push,_pop,_size_a); def_com(1)(si,dl,dr,dm,tm,wf,wb,bd,bz,zf,zb,dt,no,ar,vf,vb,wv,nl,si_,wf_,wb_,bd_); -%------------------------------------------------------------------------------------------------- +%-------------------------------------------------------------------------------------------------- def parameter_list= sw_checklist,sw_numberA,sw_numberB,sw_mol_frame,sw_auxout,sw_solid,sw_expand,sw_MOLout, sw_start_vector,sw_atom_frame,sw_font_frame,sw_subst_off,sw_bond_single,sw_clip, @@ -101,7 +104,9 @@ def parameter_list= bond_len#,offset_atom#,offset_wedge#,max_bond_length#,offset_zebra_gap#,offset_bond_gap#, thickness_font_frame#,offset_thickness#,numberA_start,numberA_end,numberB_start,numberB_end enddef; -%------------------------------------------------------------------------------------------------- +%-------------------------------------------------------------------------------------------------- +vardef pic_c(expr i,s)= substring(i,i+1) of s enddef; +%-------------------------------------------------------------------------------------------------- nA:=0; for list=parameter_list: stock_para[incr nA]:=list; endfor def store_par(text t)= nA:=0; for list=t: if stock_para[incr nA]<>list: stock_para[nA]:=list; fi endfor enddef; @@ -113,7 +118,7 @@ def beginfont(text s)= f_beginchar:=inf_num:=0; for list=s: info[incr inf_num]:=list; endfor enddef; -%------------------------------------------------------------------------------------------------- +%-------------------------------------------------------------------------------------------------- def endfont= if (sw_font_frame=1)or(sw_font_frame=3): AUX(0,0)(draw_frame(w,h,(0,0),thickness_font_frame);) fi if (sw_font_frame=2)or(sw_font_frame=3): @@ -126,65 +131,6 @@ def endfont= restore_par(parameter_list); font_wd#:=save_wd#; font_ht#:=save_ht#; if proc_end=1: scantokens("bye"); fi enddef; -%------------------------------------------------------------------------------------------------- -def char_size_set(expr a)(expr b)(expr c)(expr s)= - for j=0 upto length(s)-1: nA:=ASCII(pic_c(j,s)); - if f_char[nA]=1: char_w[nA]#:=atom_wd#*a; char_h[nA]#:=atom_wd#*b; char_d[nA]#:=atom_wd#*c; - define_pixels(char_w[nA],char_h[nA],char_d[nA]); fi - endfor -enddef; -%------------------------------------------------------------------------------------------------- -def mol_size_setup= - if (bond_len#*ratio_atom_bond+offset_atom#)<.8bond_len#: - atom_wd#:=bond_len#*ratio_atom_bond+offset_atom#; - else: atom_wd#:=.8bond_len#; ratio_chain_ring:= .5; fi - wedge_wd#:= bond_len#*ratio_wedge_bond+offset_wedge#; - zebra_gap#:= bond_len#*ratio_zebragap_bond+offset_zebra_gap#; - bondgap#:= bond_len#*ratio_bondgap_bond+offset_bond_gap#; - bond_pen_wd#:= bond_len#*ratio_thickness_bond+offset_thickness#; - char_pen_wd#:= bond_pen_wd#*ratio_char_bond; - define_pixels(bond_len,zebra_gap,wedge_wd,atom_wd,bondgap,bond_pen_wd,char_pen_wd); - char_size_set( 1)( 1)( 0)("CGHMNOQ"); - char_size_set(.9)( 1)( 0)("ABDEFIJKLPRSTUVWXYZ-+/><m"); - char_size_set(.7)( 1)( 0)(" ()0123456789nhj=*bdiltf"); - char_size_set(.7)( 1)(.15)("pqg"); - char_size_set(.7)(.8)( 0)("acekosuvxzwry"); - char_size_set(.4)( 1)( 0)(".,:;'`"); -enddef; -%------------------------------------------------------------------------------------------------- -def mol_scaling= - begingroup - save xpos,ypos,str_len,max_x,max_y; - minX:=minY:= 4095.999; max_x:=max_y:=-4095.999; - for i=1 upto cntA: xpos:=xpart(posA[i]); ypos:=ypart(posA[i]); - if strA[i]<>0: str_len:=nC:=nD:=0; - for j=0 upto length(com_str[strA[i]])-1: - nA:=ASCII(pic_c(j,com_str[strA[i]])); - if (nA=score_u)or(nA=hat)or(nA=par_s)or(nA=par_e): - if (nA=hat)and(nC<.5atom_wd): nC:=.5atom_wd; fi; - if (nA=score_u)and(nD<.5atom_wd): nD:=.5atom_wd; fi; - else: str_len:=str_len+char_w[nA]; fi - endfor - str_ang:=(br_ang[i] mod 360); nF:=str_len; - if (str_ang<=91)or(str_ang>=269): nF:=0; else: str_len:=0; fi - if (xpos-nF+.5atom_wd)<minX: minX:=xpos-nF+.5atom_wd; - elseif (xpos+str_len-.5atom_wd)>max_x: max_x:=xpos+str_len-.5atom_wd; fi - if (ypos-nD-.5atom_wd)<minY: minY:=ypos-nD-.5atom_wd; - elseif (ypos+nC+.5atom_wd)>max_y: max_y:=ypos+nC+.5atom_wd; fi - else: if xpos<minX: minX:=xpos; elseif xpos>max_x: max_x:=xpos; fi - if ypos<minY: minY:=ypos; elseif ypos>max_y: max_y:=ypos; fi fi - endfor - mol_wd:=max_x-minX; mol_ht:=max_y-minY; - endgroup -enddef; -%------------------------------------------------------------------------------------------------- -for i=1 upto 128: f_char[i]:=0; endfor asc0:=ASCII("0"); asc9:=ASCII("9"); -def char_use_check= - for i=1 upto 128: if f_char[i]<>0: f_char[i]:=0; fi endfor - if (sw_numberA>=1)or(sw_numberB>=1): for j=asc0 upto asc9: f_char[j]:=1; endfor - else: for i=1 upto cntA: if strA[i]<>0: for j=0 upto length(com_str[strA[i]])-1: - f_char[ASCII(pic_c(j,com_str[strA[i]]))]:=1; endfor fi endfor fi -enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def set_def_MC= save /,*,//,/*,*/,**,~,~~,^,^^,`,'`,{,},<,>,>>,:>,&,&#,:,=,\,\\,*\,\*,@,$,#,|,||, @@ -210,174 +156,165 @@ def set_def_MC= def **secondary n == (_postE,n) enddef; def */*secondary n == (_postF,n) enddef; enddef; %------------------------------------------------------------------------------------------------- -def PM(expr a,b,c)= comMC[a][incr cntMC[a]]:=b; parMC[a][cntMC[a]]:=c; enddef; -vardef '(text s)= ''(incr mc_num)(s); mc_num enddef; +vardef '(text s)= ''(incr def_num)(s); def_num enddef; def ''(expr k)(text s)= begingroup if unknown inside_def_MC:: set_def_MC fi cntMC[k]:=0; for list==s:: if known list:: - if pair list:: PM(k,xpart(list),ypart(list)) + if pair list:: comMC[k][incr cntMC[k]]:=xpart(list); parMC[k][cntMC[k]]:=ypart(list); elseif numeric list:: - if list>=first_def_number:: - for i==1 upto cntMC[list]:: PM(k,comMC[list][i],parMC[list][i]) endfor - else:: PM(k,_mk_bond,list) fi - elseif string list:: com_str[incr str_cnt]:=list; PM(k,_set_atom,str_cnt) + if list>=def_emb_start:: + for i==1 upto cntMC[list]:: + comMC[k][incr cntMC[k]]:=comMC[list][i]; parMC[k][cntMC[k]]:=parMC[list][i]; + endfor + else:: comMC[k][incr cntMC[k]]:=_mk_bond; parMC[k][cntMC[k]]:=list; fi + elseif string list:: com_str[incr str_cnt]:=list; + comMC[k][incr cntMC[k]]:=_set_atom; parMC[k][cntMC[k]]:=str_cnt; if pic_c(0,list)=="{":: str_wd[str_cnt]:=1.7; else:: str_wd[str_cnt]:=1; fi fi fi endfor endgroup enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def !?(expr a)(expr b) = - PB(_jp_bond,a) PB(_get_len,a) PB(_push,0) - PB(_chg_len,_ring_len) for i==1 upto b-2:: PB(_mk_bond,360 DIV b) endfor PB(_pop,0) - if a>=1:: PB(_cyc_eB,0) elseif a>=-999:: PB(_cyc_eB,a-b+2) else:: PB(_cyc_eB,a) fi + PA(_jp_bond,a) PA(_get_len,a) PA(_push,0) + PA(_chg_len,_ring_len) for i==1 upto b-2:: PA(_mk_bond,360 DIV b) endfor PA(_pop,0) + if a>=1:: PA(_cyc_eB,0) elseif a>=-999:: PA(_cyc_eB,a-b+2) else:: PA(_cyc_eB,a) fi enddef; %------------------------------------------------------------------------------------------------- def !!?(expr a)(expr b)(expr c) = - PB(_jp_bond,xpart(a)) PB(_push,0) - if b==6:: PB(_chg_len,0) for i==1 upto c-1:: PB(_mk_bond,60) endfor - elseif b==5:: if c==2:: PB(_chg_len,1.25) PB(_mk_bond,80) - elseif c==3:: PB(_chg_len,1.1) PB(_mk_bond,78) PB(_mk_bond,72) fi - elseif b==4:: PB(_chg_len,1.225) PB(_mk_bond,105) fi - PB(_pop,0) if ypart(a)<=0:: PB(_cyc_eB,ypart(a)-c+1) else:: PB(_cyc_eB,ypart(a)) fi + PA(_jp_bond,xpart(a)) PA(_push,0) + if b==6:: PA(_chg_len,0) for i==1 upto c-1:: PA(_mk_bond,60) endfor + elseif b==5:: if c==2:: PA(_chg_len,1.25) PA(_mk_bond,80) + elseif c==3:: PA(_chg_len,1.1) PA(_mk_bond,78) PA(_mk_bond,72) fi + elseif b==4:: PA(_chg_len,1.225) PA(_mk_bond,105) fi + PA(_pop,0) if ypart(a)<=0:: PA(_cyc_eB,ypart(a)-c+1) else:: PA(_cyc_eB,ypart(a)) fi enddef; %------------------------------------------------------------------------------------------------- -def fuse_large(expr a)(expr b)(expr c) = +def !??(expr a)(expr b)(expr c) = if b==5:: - PB(_jp_bond,a) PB(_push,0) PB(_chg_len,c DIV 10) PB(_mk_bond,72-((c-9) MUL 1.5)) - PB(_mk_bond,72+(c-9)) PB(_mk_bond,72+(c-9)) PB(_pop,0) - if a>=1:: PB(_cyc_eB,0) else:: PB(_cyc_eB,list) fi + PA(_jp_bond,a) PA(_push,0) PA(_chg_len,c DIV 10) PA(_mk_bond,72-((c-9) MUL 1.5)) + PA(_mk_bond,72+(c-9)) PA(_mk_bond,72+(c-9)) PA(_pop,0) + if a>=1:: PA(_cyc_eB,0) else:: PA(_cyc_eB,list) fi elseif b==6:: - PB(_jp_bond,a) PB(_push,0) PB(_chg_len,c DIV 10) PB(_mk_bond,60-(c-8)) - PB(_mk_bond,60+((c-8) DIV 2)) PB(_mk_bond,60+((c-8) DIV 2)) PB(_mk_bond,60+((c-8) DIV 2)) - PB(_pop,0) if a>=1:: PB(_cyc_eB,0) else:: PB(_cyc_eB,list) fi + PA(_jp_bond,a) PA(_push,0) PA(_chg_len,c DIV 10) PA(_mk_bond,60-(c-8)) + PA(_mk_bond,60+((c-8) DIV 2)) PA(_mk_bond,60+((c-8) DIV 2)) PA(_mk_bond,60+((c-8) DIV 2)) + PA(_pop,0) if a>=1:: PA(_cyc_eB,0) else:: PA(_cyc_eB,list) fi elseif b==7:: - PB(_jp_bond,a) PB(_push,0) PB(_chg_len,c DIV 10) PB(_mk_bond,(360 DIV 7)-(c-8)) - PB(_mk_bond,360 DIV 7+((c-8) DIV 2.5)) PB(_mk_bond,360 DIV 7+((c-8) DIV 2.5)) - PB(_mk_bond,360 DIV 7+((c-8) DIV 2.5)) PB(_mk_bond,360 DIV 7+((c-8) DIV 2.5)) - PB(_pop,0) if a>=1:: PB(_cyc_eB,0) else:: PB(_cyc_eB,list) fi + PA(_jp_bond,a) PA(_push,0) PA(_chg_len,c DIV 10) PA(_mk_bond,(360 DIV 7)-(c-8)) + PA(_mk_bond,360 DIV 7+((c-8) DIV 2.5)) PA(_mk_bond,360 DIV 7+((c-8) DIV 2.5)) + PA(_mk_bond,360 DIV 7+((c-8) DIV 2.5)) PA(_mk_bond,360 DIV 7+((c-8) DIV 2.5)) + PA(_pop,0) if a>=1:: PA(_cyc_eB,0) else:: PA(_cyc_eB,list) fi elseif b==8:: - PB(_jp_bond,a) PB(_push,0) PB(_chg_len,c DIV 10) PB(_mk_bond,45-(c-8)) - PB(_mk_bond,45+((c-8) DIV 3)) PB(_mk_bond,45+((c-8) DIV 3)) PB(_mk_bond,45+((c-8) DIV 3)) - PB(_mk_bond,45+((c-8) DIV 3)) PB(_mk_bond,45+((c-8) DIV 3)) - PB(_pop,0) if a>=1:: PB(_cyc_eB,0) else:: PB(_cyc_eB,list) fi + PA(_jp_bond,a) PA(_push,0) PA(_chg_len,c DIV 10) PA(_mk_bond,45-(c-8)) + PA(_mk_bond,45+((c-8) DIV 3)) PA(_mk_bond,45+((c-8) DIV 3)) PA(_mk_bond,45+((c-8) DIV 3)) + PA(_mk_bond,45+((c-8) DIV 3)) PA(_mk_bond,45+((c-8) DIV 3)) + PA(_pop,0) if a>=1:: PA(_cyc_eB,0) else:: PA(_cyc_eB,list) fi fi enddef; -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -def PB(expr a,b)= cntBS:=cntBS+1; comMC[ab_num][cntBS]:=a; parMC[ab_num][cntBS]:=b; enddef; -def $$(text t)(expr e) = - begingroup save cntBS; cntBS:=0; ab_num:=ab_num+1; +%================================================================================================== +vardef $$(text t)(expr e) = + nA:=0; def_int:=def_int+1; if known e:: if numeric e:: - if (e>=si)and(e<=bd_):: if e==dl:: for list==t:: PB(_dl,list) endfor - else:: for list==t:: PB(_set_adr,list) PB(_set_line,e) endfor fi + if (e>=si)and(e<=bd_):: if e==dl:: for list==t:: PA(_dl,list) endfor + else:: for list==t:: PA(_set_adr,list) PA(_set_line,e) endfor fi elseif (e>=?3)and(e<=?20):: for list==t:: !?(list)(e-?3+3) endfor - elseif e==Ph1:: !?(t)(6) PB(_dl,-2) PB(_dl,-4) - elseif e==Ph2:: !?(t)(6) PB(_dl,-1) PB(_dl,-3) PB(_dl,-5) + elseif e==Ph1:: !?(t)(6) PA(_dl,-2) PA(_dl,-4) + elseif e==Ph2:: !?(t)(6) PA(_dl,-1) PA(_dl,-3) PA(_dl,-5) elseif comMC[e][1]==_fuse:: if comMC[e][2]<=6:: for list==t:: !!?(list)(parMC[e][1])(comMC[e][2]) endfor elseif (comMC[e][2]>=11)and(comMC[e][2]<=15):: - for list==t:: fuse_large(list)(parMC[e][1])(comMC[e][2]) endfor + for list==t:: !??(list)(parMC[e][1])(comMC[e][2]) endfor fi fi elseif color e:: color_list[incr cntC]:=e; - for list==t:: PB(_set_adr,list) PB(_set_colorB,cntC) endfor fi fi - cntMC[ab_num]:=cntBS; - ab_num %--- Retern value ------- - endgroup -enddef; -%------------------------------------------------------------------------------------------------- -def PA(expr a,b)= cntAS:=cntAS+1; comMC[ab_num][cntAS]:=a; parMC[ab_num][cntAS]:=b; enddef; -def PAs(text t)= for list==t:: PA(xpart(list),ypart(list)) endfor enddef; -def @@(text t)(expr s)= - begingroup - save cntAS,xs,ys; cntAS:=0; ab_num:=ab_num+1; - if known s:: if numeric s:: - if (s>=H)and(s<=U):: - for list==t:: - if s==N:: PA(_N,list) elseif s==O:: PA(_O,list) elseif s==S:: PA(_S,list) - else:: PA(_set_adr,list) PA(_chg_atom,s) fi endfor - elseif s==NH:: for list==t:: if numeric list:: PAs((_N,list),~~no,'`_size_a,(_H,list)) - elseif pair list:: PAs(list) fi endfor - elseif s==SOO:: for list==t:: PAs((_S,list),(_set_adr,list), - ^^35,~~dm,(_set_psA,O),^^-35,~~dm,(_set_psA,O)) endfor - elseif s==SO:: for list==t:: - if numeric list:: PAs((_S,list),(_set_adr,list),~~dm,(_set_psA,O)) - elseif pair list:: PAs(list) fi endfor - fi - elseif pair s:: xs:=xpart(s); ys:=ypart(s); PA(_set_clr,1) - for list==t:: - if numeric list:: - if xs==_postA:: elseif xs==_postB:: PAs(~~dm) - elseif xs==_postC:: PAs(~~wf) elseif xs==_postD:: PAs(~~zf) - elseif xs==_postE:: PAs(~~nl) elseif xs==_postF:: PAs(~~no) fi - PA(_set_adr,list) PA(_set_psA,ys) - elseif pair list:: PAs(list) fi - endfor - PA(_set_clr,0) - elseif color s:: color_list[incr cntC]:=s; - for list==t:: PA(_set_adr,list) PA(_set_colorA,cntC) endfor fi fi - cntMC[ab_num]:=cntAS; - ab_num %--- Retern value ------- - endgroup -enddef; -%------------------------------------------------------------------------------------------------- -def PP(expr a,b)= op_com[cntP][incr op_cnt[cntP]]:=a; op_par[cntP][op_cnt[cntP]]:=b; enddef; -def ps_put(expr n,p)= - ps_adr[incr cntP]:=n; ps_com[cntP]:=p; op_cnt[cntP]:=0; - if lineT<>0: PP(_tmp_line,lineT) fi if rotT<>0: PP(_rot_ang,rotT) fi - if lenT<>crR: PP(_chg_len,lenT) fi if envT<>hz: PP(_chg_env,envT) fi - if lineT=nl: PP(_tmp_len,0) elseif lineT=no: PP(_adj_ang,0) fi PP(_mk_bond,0) - if f_lineT=0: lineT:=si; fi if f_lenT=0: lenT:=crR; fi - if f_rotT=0: rotT:=0; fi if f_envT=0: envT:=hz; fi + for list==t:: PA(_set_adr,list) PA(_set_colorB,cntC) endfor + fi fi + cntMC[def_int]:=nA; + def_int %------- Retern value ------- enddef; %------------------------------------------------------------------------------------------------- -def PG(expr a,b)= comMC[0][incr cntMC[0]]:=a; parMC[0][cntMC[0]]:=b; enddef; -def ps_get(expr n)= - cntC:=cntMC[0]; cntPS:=cntP; - for i=n upto cntP: - PG(_jp_atom_abs,ps_adr[i]) PG(_push,1) - for j=1 upto op_cnt[i]: PG(op_com[i][j],op_par[i][j]) endfor - for j=1 upto cntMC[ps_com[i]]: PG(comMC[ps_com[i]][j],parMC[ps_com[i]][j]) endfor - PG(_pop,1) PG(_term,0) - endfor - proc_bond_atom(cntC+1); if cntP>cntPS: ps_get(cntPS+1); fi +vardef @@(text t)(expr s)= + nA:=0; def_int:=def_int+1; + if known s:: if numeric s:: + if (s>=H)and(s<=U):: + for list==t:: + if s==N:: PA(_N,list) elseif s==O:: PA(_O,list) elseif s==S:: PA(_S,list) + else:: PA(_set_adr,list) PA(_chg_atom,s) fi endfor + elseif s==NH:: for list==t:: if numeric list:: PAs((_N,list),~~no,'`_size_a,(_H,list)) + elseif pair list:: PAs(list) fi endfor + elseif s==SOO:: for list==t:: PAs((_S,list),(_set_adr,list), + ^^35,~~dm,(_set_psA,O),^^-35,~~dm,(_set_psA,O)) endfor + elseif s==SO:: for list==t:: + if numeric list:: PAs((_S,list),(_set_adr,list),~~dm,(_set_psA,O)) + elseif pair list:: PAs(list) fi endfor + fi + elseif pair s:: nE:=xpart(s); nF:=ypart(s); PA(_set_clr,1) + for list==t:: + if numeric list:: + if nE==_postA:: elseif nE==_postB:: PAs(~~dm) + elseif nE==_postC:: PAs(~~wf) elseif nE==_postD:: PAs(~~zf) + elseif nE==_postE:: PAs(~~nl) elseif nE==_postF:: PAs(~~no) fi + PA(_set_adr,list) PA(_set_psA,nF) + elseif pair list:: PAs(list) fi + endfor + PA(_set_clr,0) + elseif color s:: color_list[incr cntC]:=s; + for list==t:: PA(_set_adr,list) PA(_set_colorA,cntC) endfor fi fi + cntMC[def_int]:=nA; + def_int %------- Retern value ------- enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def AUX(expr a,b)(text s)=s addto chem_structure also currentpicture shifted(a,b); clearit; enddef; def MCf(text s)= MCd(1,1)(.5,.5)(s); enddef; % MC fill draw +def MCd(expr RW,RH)(expr FW,FH)(text s)= proc_drawing(RW,RH)(FW,FH)(s); enddef; %------------------------------------------------------------------------------------------------- -def MCd(expr RW,RH)(expr FW,FH)(text s)= - mc_num:=user_def_number; ab_num:=ab_def_number; crR:=-ratio_chain_ring; - cntA:=cntB:=cntPS:=cntC:=cntP:=0; com_str[0]:=""; str_cnt:=2000; +def proc_drawing(expr RW,RH)(expr FW,FH)(text s)= + begingroup + save com,par,adrA,adrB,f_bra,envT,envB,lenT,lineT,strAT,stkA,stkB,stkL,stkM,bondL,temp_len, + temp_cntB,f_end,f_term,rotT,adrS,f_lineT,f_rotT,f_lenT,f_envT,PP,angT,tempB,glu,sftX,sftY, + xpos,ypos,str_len,max_x,max_y,par_s,par_e,score_u,hat,f_char,lenB,ps_adr,ps_com,op_com, + op_par,op_cnt,crR,colorA,colorB,PA,PAs,PP,PG; + %----------------------------------------------------------------------------------------------- + def PA(expr a,b)= comMC[def_int][incr nA]:=a; parMC[def_int][nA]:=b; enddef; + def PAs(text t)= for list==t:: PA(xpart(list),ypart(list)) endfor enddef; + def PP(expr a,b)= op_com[cntP][incr op_cnt[cntP]]:=a; op_par[cntP][op_cnt[cntP]]:=b; enddef; + def PG(expr a,b)= comMC[0][incr cntMC[0]]:=a; parMC[0][cntMC[0]]:=b; enddef; + %----------------------------------------------------------------------------------------------- + numeric stkB[],stkA[],stkL[],stkM[],f_char[],ps_adr[],ps_com[],colorA[],colorB[], + op_com[][],op_par[][],op_cnt[]; + %----------------------------------------------------------------------------------------------- if (sw_numberA>=1)or(sw_numberB>=1): ratio_atom_bond:=0.25; fi if (sw_expand=1)or(sw_MOLout=1): expand_set; fi - ''(0)(s,(_term,0)); proc_bond_atom(1); cntA_skeleton:=cntA; cntB_skeleton:=cntB; - if cntP>0: ps_get(1); fi + def_num:=def_usr_start; + def_int:=def_int_start; + par_s=ASCII("{"); par_e=ASCII("}"); score_u=ASCII("_"); hat=ASCII("^"); + cntA:=cntB:=cntP:=cntC:=0; com_str[0]:=""; str_cnt:=2000; crR:=-ratio_chain_ring; + %----------------------------------------------------------------------------------------------- + ''(0)(s,(_term,0)); proc_bond_atom(1); if (cntP>0)and(sw_subst_off=0): ps_get(1); fi define_pixels(font_wd,font_ht,thickness_font_frame); char_use_check; if sw_solid=1: bond_len#:=font_wd#*ratio_bond_width; - mol_size_setup; proc_skeleton; mol_scaling; - elseif sw_solid=2: mol_size_setup; proc_skeleton; mol_scaling; + proc_size_setup; proc_skeleton; proc_scaling; + elseif sw_solid=2: proc_size_setup; proc_skeleton; proc_scaling; else: - bond_len#:=3mm#; mol_size_setup; - for i=1 upto 6: proc_skeleton; mol_scaling; + bond_len#:=3mm#; proc_size_setup; + for i=1 upto 6: proc_skeleton; proc_scaling; if (mol_ht/mol_wd)>(font_ht/font_wd): factor:=(font_ht*RH-2margin_top_bottom)/mol_ht; else: factor:=(font_wd*RW-2margin_left_right)/mol_wd; fi exitif factor=1; - bond_len#:=bond_len#*factor; mol_size_setup; + bond_len#:=bond_len#*factor; proc_size_setup; endfor if bond_len#>max_bond_length#: - bond_len#:=max_bond_length#; mol_size_setup; proc_skeleton; mol_scaling; fi + bond_len#:=max_bond_length#; proc_size_setup; proc_skeleton; proc_scaling; fi fi - char_font_setup(char_pen_wd); - if sw_subst_off=1: cntA:=cntA_skeleton; cntB:=cntB_skeleton; fi - %---------------------------------------------------------------------------------------- + proc_char_setup(char_pen_wd); if f_beginchar=0: if sw_clip=1: font_wd#:=font_wd#*((mol_wd+2margin_left_right)/font_wd); font_ht#:=font_ht#*((mol_ht+2margin_top_bottom)/font_ht); fi - beginchar(char_num,font_wd#,font_ht#,0); f_beginchar:=1; fi + beginchar(char_num,font_wd#,font_ht#,0); f_beginchar:=1; + fi for i=1 upto cntB: if lineB[i]<si_ : draw_bond(i,sB[i],eB[i],angB[i],lineB[i]); fi endfor for i=1 upto cntB: if lineB[i]>=si_: draw_bond(i,sB[i],eB[i],angB[i],lineB[i]); fi endfor for i=1 upto cntA: @@ -388,7 +325,7 @@ def MCd(expr RW,RH)(expr FW,FH)(text s)= if i<10: draw_atom(i,posA[i],0,decimal(nA),1); else: draw_atom(i,posA[i]+(-.2atom_wd,0),0,decimal(nA),1); fi elseif sw_numberB>=1: - else: draw_atom(i,posA[i],br_ang[i],com_str[strA[i]],str_wd[strA[i]]); fi + else: draw_atom(i,posA[i],ang_br[i],com_str[strA[i]],str_wd[strA[i]]); fi endfor sftX:=margin_left_right-minX+(w-mol_wd-2margin_left_right)*FW; sftY:=margin_top_bottom-minY+(h-mol_ht-2margin_top_bottom)*FH; @@ -396,26 +333,87 @@ def MCd(expr RW,RH)(expr FW,FH)(text s)= if sw_start_vector=1: AUX(sftX,sftY)(start_vector) fi addto chem_structure also currentpicture shifted (sftX,sftY); clearit; + endgroup enddef; -%------------------------------------------------------------------------------------------------ +%------------------------------------------------------------------------------------------------- +def ps_put(expr n,p)= + ps_adr[incr cntP]:=n; ps_com[cntP]:=p; op_cnt[cntP]:=0; + if lineT<>0: PP(_tmp_line,lineT) fi if rotT<>0: PP(_rot_ang,rotT) fi + if lenT<>crR: PP(_chg_len,lenT) fi if envT<>hz: PP(_chg_env,envT) fi + if lineT=nl: PP(_tmp_len,0) elseif lineT=no: PP(_adj_ang,0) fi PP(_mk_bond,0) + if f_lineT=0: lineT:=si; fi if f_lenT=0: lenT:=crR; fi + if f_rotT=0: rotT:=0; fi if f_envT=0: envT:=hz; fi +enddef; +%------------------------------------------------------------------------------------------------- +def ps_get(expr n)= + nA:=cntP; nB:=cntMC[0]; + for i=n upto cntP: + PG(_jp_atom_abs,ps_adr[i]) PG(_push,1) + for j=1 upto op_cnt[i]: PG(op_com[i][j],op_par[i][j]) endfor + for j=1 upto cntMC[ps_com[i]]: PG(comMC[ps_com[i]][j],parMC[ps_com[i]][j]) endfor + PG(_pop,1) PG(_term,0) + endfor + proc_bond_atom(nB+1); if cntP>nA: ps_get(nA+1); fi +enddef; +%------------------------------------------------------------------------------------------------- def draw_frame(expr LX,LY,PS,PN)= draw ((PN/2,PN/2)--(LX-PN/2,PN/2)--(LX-PN/2,LY-PN/2)--(PN/2,LY-PN/2)--cycle) shifted PS wpss PN; enddef; +%------------------------------------------------------------------------------------------------- def draw_corner(expr LX,LY,PN)= drawdot (PN/2,PN/2) wpss PN; drawdot (LX-PN/2,PN/2) wpss PN; drawdot (LX-PN/2,LY-PN/2) wpss PN; drawdot (PN/2,LY-PN/2) wpss PN; enddef; +%------------------------------------------------------------------------------------------------- def start_vector= draw (posA[1] shifted (-1mm,0))--(posA[1] shifted (-4mm,0)) withpen penrazor rotated 90 scaled .8mm; fill (posA[1] shifted (-2mm,-1mm))--posA[1]--(posA[1] shifted (-2mm,1mm))--cycle; enddef; +%------------------------------------------------------------------------------------------------- +def proc_size_setup= + if (bond_len#*ratio_atom_bond+offset_atom#)<.8bond_len#: + atom_wd#:=bond_len#*ratio_atom_bond+offset_atom#; + else: atom_wd#:=.8bond_len#; ratio_chain_ring:= .5; fi + wedge_wd#:= bond_len#*ratio_wedge_bond+offset_wedge#; + zebra_gap#:= bond_len#*ratio_zebragap_bond+offset_zebra_gap#; + bondgap#:= bond_len#*ratio_bondgap_bond+offset_bond_gap#; + bond_pen_wd#:= bond_len#*ratio_thickness_bond+offset_thickness#; + char_pen_wd#:= bond_pen_wd#*ratio_char_bond; + define_pixels(bond_len,zebra_gap,wedge_wd,atom_wd,bondgap,bond_pen_wd,char_pen_wd); +enddef; +%------------------------------------------------------------------------------------------------- +def proc_scaling= + minX:=minY:=4095.999; max_x:=max_y:=-4095.999; + for i=1 upto cntA: xpos:=xpart(posA[i]); ypos:=ypart(posA[i]); + if strA[i]<>0: str_len:=nC:=nD:=0; + for j=0 upto length(com_str[strA[i]])-1: + nA:=ASCII(pic_c(j,com_str[strA[i]])); + if (nA=score_u)or(nA=hat)or(nA=par_s)or(nA=par_e): + if (nA=hat)and(nC<.5atom_wd): nC:=.5atom_wd; fi; + if (nA=score_u)and(nD<.5atom_wd): nD:=.5atom_wd; fi; + else: str_len:=str_len+atom_wd*tbl_char_wd[nA]; fi + endfor + str_ang:=(ang_br[i] mod 360); nF:=str_len; + if (str_ang<=91)or(str_ang>=269): nF:=0; else: str_len:=0; fi + if (xpos-nF+.5atom_wd)<minX: minX:=xpos-nF+.5atom_wd; + elseif (xpos+str_len-.5atom_wd)>max_x: max_x:=xpos+str_len-.5atom_wd; fi + if (ypos-nD-.5atom_wd)<minY: minY:=ypos-nD-.5atom_wd; + elseif (ypos+nC+.5atom_wd)>max_y: max_y:=ypos+nC+.5atom_wd; fi + else: if xpos<minX: minX:=xpos; elseif xpos>max_x: max_x:=xpos; fi + if ypos<minY: minY:=ypos; elseif ypos>max_y: max_y:=ypos; fi fi + endfor + mol_wd:=max_x-minX; mol_ht:=max_y-minY; +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 + else: for i=1 upto cntA: if strA[i]<>0: for j=0 upto length(com_str[strA[i]])-1: + f_char[ASCII(pic_c(j,com_str[strA[i]]))]:=1; endfor fi endfor fi +enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def proc_bond_atom(expr n)= - begingroup - save com,par,adrA,adrB,f_bra,f_end,f_term,rotT,adrS,f_lineT,f_rotT,f_lenT,f_envT,envT,env, - lenT,strAT,stkA,stkB,stkL,bondL,temp_len,lineT; - numeric stkB[],stkA[],stkL[]; - f_bra:=f_end:=f_term:=rotT:=adrS:=f_lineT:=f_rotT:=f_lenT:=f_envT:=envT:=env:=strAT:=0; + f_bra:=f_end:=f_term:=rotT:=adrS:=f_lineT:=f_rotT:=f_lenT:=f_envT:=envT:=envB:=strAT:=0; stkL[0]:=bondL:=crR; lenT:=crR; sB[0]:=0; eB[0]:=1; lineT:=si; for i=0 upto 5: stkA[i]:=stkB[i]:=0; endfor for i=n upto cntMC[0]: com:=comMC[0][i]; par:=parMC[0][i]; @@ -452,7 +450,7 @@ def proc_bond_atom(expr n)= elseif com=_cyc: f_end:=getA(par); add_atom; elseif com=_cyc_eB: f_end:=eB[getB(par)]; add_atom; elseif com=_cyc_sB: f_end:=sB[getB(par)]; add_atom; - elseif com=_chg_env: env:=par; + elseif com=_chg_env: envB:=par; elseif com=_tmp_env: envT:=par; elseif com=_set_clr: if par=1: if lineT<>si: f_lineT:=1; fi if rotT<>0: f_rotT:=1; fi @@ -464,7 +462,6 @@ def proc_bond_atom(expr n)= elseif com=_set_colorB: colorB[getB(adrT)]:=par; fi endfor - endgroup enddef; %------------------------------------------------------------------------------------------------- def add_atom= @@ -476,33 +473,29 @@ def add_atom= enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def proc_skeleton= - begingroup - save com,par,adrA,adrB,cntA,cntB,angT,adrS,env,envT,rotT,lineT, - f_end,f_bra,rotT,f_term,f_lineT,f_rotT,f_lenT,f_envT,stkA,stkB,stkM; - numeric stkB[],stkA[],stkM[]; adrA:=adrB:=cntA:=cntB:=angT:=adrS:=f_end:=f_bra:=rotT:=f_term:=0; - envT:=env:=f_lineT:=f_rotT:=f_lenT:=f_envT:=stkM[0]:=0; lineT:=si; - angA[0]:=angB[0]:=br_ang[0]:=0; posA[0]:=posB[0]:=posB[1]:=(0,0); + envT:=envB:=f_lineT:=f_rotT:=f_lenT:=f_envT:=stkM[0]:=0; lineT:=si; + angA[0]:=angB[0]:=ang_br[0]:=0; posA[0]:=posB[0]:=posB[1]:=(0,0); for i=0 upto 5: stkA[i]:=stkB[i]:=0; endfor for i=1 upto cntMC[0]: com:=comMC[0][i]; par:=parMC[0][i]; - if com=_push: if par=1: stkM[adrS]:=env; adrS:=adrS+1; stkA[adrS]:=adrA:=cntA; + if com=_push: if par=1: stkM[adrS]:=envB; adrS:=adrS+1; stkA[adrS]:=adrA:=cntA; stkB[adrS]:=adrB:=cntB; elseif par=0: temp_len:=bondL; fi - elseif com=_pop: if par=1: adrA:=stkA[decr adrS]; adrB:=stkB[adrS]; env:=stkM[adrS]; + elseif com=_pop: if par=1: adrA:=stkA[decr adrS]; adrB:=stkB[adrS]; envB:=stkM[adrS]; elseif par=0: temp_len:=bondL; fi elseif com=_jp_bond: tempB:=getB(par); posB[cntB+1]:=posA[sB[tempB]]; angT:=angB[tempB]-180; f_bra:=1; rotT:=0; elseif com=0or_jp_atom: termB; adrT:=getA(par); posB[cntB+1]:=posA[adrT]; - angT:=br_ang[adrT]; f_bra:=1; rotT:=0; + angT:=ang_br[adrT]; f_bra:=1; rotT:=0; elseif com=_jp_atom_abs: adrT:=par; posB[cntB+1]:=posA[adrT]; - angT:=br_ang[adrT]; f_bra:=1; rotT:=0; temp_cntB:=cntB; + angT:=ang_br[adrT]; f_bra:=1; rotT:=0; temp_cntB:=cntB; elseif com=_adj_ang: if (angT<40)or(angT>320): angT:=0; elseif angT<140: angT:=90; elseif angT<220: angT:=180; else: angT:=270; fi elseif com=_mk_bond: if (par=0)and(rotT<>0):par:=rotT; rotT:=0; fi add_bond(par); elseif com=_rot_ang: angT:=(angT+par) mod 360; elseif com=_tmp_rot: rotT:=par; elseif (com>=_postA)and(com<=_postF): rotT:=0; - elseif com=_chg_env: env:=par; + elseif com=_chg_env: envB:=par; elseif com=_tmp_env: envT:=par; elseif com=_set_clr: f_clr:=par; if par=0: lineT:=si; lenT:=crR; rotT:=envT:=0; fi elseif com=_cyc: f_end:=1; proc_cyc(getA(par)); @@ -512,9 +505,21 @@ def proc_skeleton= elseif com=_stack_reset: stkA[adrS+1]:=0; fi endfor - endgroup enddef; %------------------------------------------------------------------------------------------------- +def add_bond(expr m)= + cntB:=cntB+1; if m=_arg_ang: nA:=proc_env(angT,envB,60,-60); else: nA:=m; fi + if f_bra=0: adrT:=cntA:=cntA+1; posA[cntA]:=posB[cntB]; angA[cntA]:=angT; + if nA>=0: ang_br[cntA]:=angT+nA/2-90; else: ang_br[cntA]:=angT+nA/2+90; fi + else: f_bra:=0; fi + angB[cntB]:=angT:=(angT+nA) mod 360; + if f_end=0: if lenB[cntB]=_size_a: posB[cntB+1]:=sfB(posB[cntB],atom_wd,angT); + else: nA:=lenB[cntB];glu:=0; if nA<0: nA:=-nA; glu_c(adrT);glu_c(cntA+1); fi + posB[cntB+1]:=sfB(posB[cntB],nA*bond_len+glu,angT); fi + posA[cntA+1]:=posB[cntB+1]; f_term:=0; + else: f_end:=0; f_term:=1; fi +enddef; +%================================================================================================== vardef getA(expr n)= if n>=0: stkA[adrS+1]+n elseif n>=-999: cntA+n+1 else: stkA[adrS]+n+4095 fi enddef; vardef getB(expr n)= @@ -523,37 +528,24 @@ enddef; def termA= if f_term=0: if f_bra=0: strA[incr cntA]:=strAT; strAT:=0; if f_MP=1: colorA[cntA]:=0; fi else: f_bra:=0; fi f_term:=1; fi enddef; def termB= - if f_term=0: if f_bra=0: br_ang[incr cntA]:=angT; else: f_bra:=0; fi f_term:=1; fi enddef; + if f_term=0: if f_bra=0: ang_br[incr cntA]:=angT; else: f_bra:=0; fi f_term:=1; fi enddef; def proc_cyc(expr n)= add_bond(angle(posA[n]-posB[cntB+1])-angT); enddef; def glu_c(expr n)= if strA[n]<>0: nB:=angT mod 180; nC:=.5str_wd[strA[n]]*atom_wd; if (nB<45)or(nB>135):glu:=glu+((sind(nB)*nC)++nC); else :glu:=glu+((cosd(nB)*.5atom_wd)++.5atom_wd) fi fi enddef; -%------------------------------------------------------------------------------------------------- -def add_bond(expr m)= - cntB:=cntB+1; if m=_arg_ang: nA:=proc_env(angT,env,60,-60); else: nA:=m; fi - if f_bra=0: adrT:=cntA:=cntA+1; posA[cntA]:=posB[cntB]; angA[cntA]:=angT; - if nA>=0: br_ang[cntA]:=angT+nA/2-90; else: br_ang[cntA]:=angT+nA/2+90; fi - else: f_bra:=0; fi - angB[cntB]:=angT:=(angT+nA) mod 360; - if f_end=0: if lenB[cntB]=_size_a: posB[cntB+1]:=sfB(posB[cntB],atom_wd,angT); - else: nA:=lenB[cntB];glu:=0; if nA<0: nA:=-nA; glu_c(adrT);glu_c(cntA+1); fi - posB[cntB+1]:=sfB(posB[cntB],nA*bond_len+glu,angT); fi - posA[cntA+1]:=posB[cntB+1]; f_term:=0; - else: f_end:=0; f_term:=1; fi -enddef; -%------------------------------------------------------------------------------------------------- vardef proc_env(expr n,m,a,b)= r:=(n mod 360); - if m>=first_def_number: parMC[m][cntB-temp_cntB-1] else: + if m>=def_emb_start: parMC[m][cntB-temp_cntB-1] else: if m=hz:if r=0:a elseif r<=90:b elseif r<=180:a elseif r<270:b else:a fi elseif m=vt:if r=0:b elseif r<90:a elseif r<=180:b elseif r<=271:a else:b fi elseif (m>=-180)and(m<=180): m fi fi enddef; -%------------------------------------------------------------------------------------------------- -def pic_c(expr i,s)= substring(i,i+1) of s enddef; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def draw_atom(expr n,p,r,s,w)= begingroup - save dx,u,j,pairA,pairT; pair pairA,pairT; + save dx,u,j,pairA,pairT,par_s,par_e,score_u,hat; pair pairA,pairT; + par_s=ASCII("{"); par_e=ASCII("}"); score_u=ASCII("_"); hat=ASCII("^"); + %--------------------------------------------------------------------------------------- if ((r mod 360)<=90+1)or((r mod 360)>=270-1): dx:=1; else: dx:=-1; fi pairT:=p-(.5atom_wd*w*dx,.5atom_wd); u:=j:=0; for i=0 upto length(s)-1: nB:=ASCII(pic_c(i,s)); @@ -562,50 +554,24 @@ def draw_atom(expr n,p,r,s,w)= if nB=score_u: if u=0: u:=-.5; else:u:=0; fi; elseif nB=hat: if u=0: u:= .5; else:u:=0; fi; elseif (nB<>par_s)and(nB<>par_e): - nA:=char_w[nB]; pairA:=pairT+(.5*((dx-1)*nA),u*atom_wd); + nA:=atom_wd*tbl_char_wd[nB]; pairA:=pairT+(.5*((dx-1)*nA),u*atom_wd); if sw_atom_frame=1: draw_frame(nA,atom_wd,pairA,0.1pt); fi if (sw_numberA>=1)or(sw_numberB>=1): erase fill unitsquare xscaled nA yscaled atom_wd shifted pairA wpcs 0.01pt; fi - addto currentpicture also atom_font[nB] shifted (pairA-(0,char_d[nB])) Cp(colorA[n]); - pairT:=pairT+(nA*dx,0); fi endfor + addto currentpicture also atom_font[nB] + shifted (pairA-(0,atom_wd*tbl_char_dp[nB])) Cp(colorA[n]); + pairT:=pairT+(nA*dx,0); + fi + endfor endgroup enddef; -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -def wpcs expr n= withpen pencircle scaled n enddef; -def wpss expr n= withpen pensquare scaled n enddef; -def sqr(expr WD,HT)= ((0,0)--(WD,0)--(WD,HT)--(0,HT)--cycle) enddef; -def sfB(expr p,l,r)= p shifted ((l,0) rotated r) enddef; -def wz_put(expr PA,PB,PD,CL)= nC:=length(Le-Ls); - for i=0 upto nC/zebra_gap: - nA:=zebra_gap*i/nC; nD:=(zebra_gap*i+ratio_zebra_black*zebra_gap)/nC; - if nD>((nC-zebra_gap)/nC): nD:=1; fi - fill nA[PB,PA]--nA[PD,PA]--nD[PD,PA]--nD[PB,PA]--cycle Cp(CL); endfor enddef; -def bz_put(expr PA,PB,PC,PD,CL)= nC:=length(Le-Ls); - for i=0 upto nC/zebra_gap: - nA:=zebra_gap*i/nC; nD:=(zebra_gap*i+ratio_zebra_black*zebra_gap)/nC; - fill nA[PB,PA]--nA[PD,PC]--nD[PD,PC]--nD[PB,PA]--cycle Cp(CL); endfor enddef; -def cut_off(expr p,w,h,s)= - p intersectionpoint sqr(1.1w,1.1h) shifted (s-(.5(1.1w),.5(1.1h))); enddef; -def clipping(expr SA,SB,PA,PB,LEN)= - pT:=PA--PB; nA:=0.6atom_wd/LEN; - if (SA=0)and(SB=0): Ls:=PA; Le:=PB; pA:=pB:=pT; pC:=0.1[PA,PB]--0.1[PB,PA]; - elseif SA=0: Ls:=PA; Le:=cut_off(pT,atom_wd*str_wd[SB],atom_wd,PB); - pA:=Ls--Le; pB:=Ls--nA[PB,PA]; pC:=0.1[PA,PB]--Le; - elseif SB=0: Ls:= cut_off(pT,atom_wd*str_wd[SA],atom_wd,PA); Le:=PB; - pA:=Ls--Le; pB:=nA[PA,PB]--Le; pC:=Ls--(0.1)[PB,PA]; - else: Ls:=cut_off(pT,atom_wd*str_wd[SA],atom_wd,PA); - Le:=cut_off(pT,atom_wd*str_wd[SB],atom_wd,PB); - pB:=nA[PA,PB]--nA[PB,PA]; pC:=pA:=Ls--Le; fi -enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -def draw_wv= nB:=3bond_pen_wd; nA:=nB/length(Le-Ls); - draw Le for i=1 upto 1/nA: if odd(i): ..controls(((i-.5)*nA)[sfB(Le,nB,ap),sfB(Ls,nB,ap)]) - else: ..controls(((i-.5)*nA)[sfB(Le,nB,am),sfB(Ls,nB,am)]) fi ..(i*nA)[Le,Ls] endfor ..Ls; -enddef; -%------------------------------------------------------------------------------------------------- def draw_bond(expr n,BP,EP,ANG,LN)= begingroup - save ww,ap,am,hpt,pA,pB,pC,pT,Ls,Le; pair Ls,Le; path pA,pB,pC,pT; + save ww,ap,am,hpt,pA,pB,pC,pT,Ls,Le; + pair Ls,Le; + path pA,pB,pC,pT; + %-------------------------------------------------------------------------------------------- nC:=length(posA[EP]-posA[BP]); if (nC>0)and(LN<>0): ww:=wedge_wd; hpt:=.5bond_pen_wd; ap:=ANG+90; am:=ANG-90; @@ -628,14 +594,14 @@ def draw_bond(expr n,BP,EP,ANG,LN)= elseif LN=wv:draw_wv; elseif LN=vf:draw pA Cp(nB);draw sfB(Le,bondgap,ANG-150)--Le--sfB(Le,bondgap,ANG+150) Cp(nB); elseif LN=vb:draw pA Cp(nB);draw sfB(Ls,bondgap,ANG-30)--Ls--sfB(Ls,bondgap,ANG+30) Cp(nB); - elseif LN=si_:erase draw 0.15[Ls,Le]--0.85[Ls,Le] wpcs .75bondgap; draw pA Cp(nB); + elseif LN=si_:erase draw 0.15[Ls,Le]--0.85[Ls,Le] wpcs 0.8bondgap; draw pA Cp(nB); elseif LN=wf_:erase fill sfB(0.15[Ls,Le],.5ww,ap)--sfB(0.15[Ls,Le],.5ww,am)-- - sfB(0.85[Ls,Le],1.25ww,am)--sfB(0.85[Ls,Le],1.25ww,ap)--cycle; + sfB(0.85[Ls,Le],1.3ww,am)--sfB(0.85[Ls,Le],1.3ww,ap)--cycle; fill Ls--sfB(Le,ww,am)--sfB(Le,ww,ap)--cycle; - elseif LN=wb_:erase fill sfB(0.15[Ls,Le],1.25ww,ap)--sfB(0.15[Ls,Le],1.25ww,am)-- + elseif LN=wb_:erase fill sfB(0.15[Ls,Le],1.3ww,ap)--sfB(0.15[Ls,Le],1.3ww,am)-- sfB(0.85[Ls,Le],.5ww,am)--sfB(0.85[Ls,Le],.5ww,ap)--cycle; fill sfB(Ls,ww,am)--Le--sfB(Ls,ww,ap)--cycle; - elseif LN=bd_:erase draw 0.15[Ls,Le]--0.85[Ls,Le] wpcs 1.5bondgap; + elseif LN=bd_:erase draw 0.15[Ls,Le]--0.85[Ls,Le] wpcs 1.6bondgap; draw pA withpen penrazor rotated ap scaled bondgap Cp(nB); fi if (sw_numberB>=1)and(n>=numberB_start)and(n<=numberB_end): @@ -647,23 +613,40 @@ def draw_bond(expr n,BP,EP,ANG,LN)= endgroup enddef; %------------------------------------------------------------------------------------------------- -vardef fit_zero(expr n)=if n<=9: "00" elseif n<=99: "0" fi enddef; -%------------------------------------------------------------------------------------------------- -def auxtag_out= - for i=1 upto aux_max: exitif tag[i]=""; if i=1: printf tag[1] else: &aux_delimiter&tag[i] fi - endfor +def draw_wv= nB:=3bond_pen_wd; nA:=nB/length(Le-Ls); + draw Le for i=1 upto 1/nA: if odd(i): ..controls(((i-.5)*nA)[sfB(Le,nB,ap),sfB(Ls,nB,ap)]) + else: ..controls(((i-.5)*nA)[sfB(Le,nB,am),sfB(Ls,nB,am)]) fi ..(i*nA)[Le,Ls] endfor ..Ls; enddef; -%------------------------------------------------------------------------------------------------- -def auxfile_out= - for i=1 upto aux_max: exitif tag[i]=""; - if i=1: printf "" else: &aux_delimiter fi if sw_auxfix=0: &tag[i]&":" fi & - if string scantokens(var[i]): scantokens(var[i]) - elseif numeric scantokens(var[i]): decimal(scantokens(var[i])) fi - endfor - if sw_auxfix=0: for i=1 upto inf_num: &aux_delimiter&info[i] endfor; fi +%------------------------------------------------------------------------------------------------ +def wpcs expr n= withpen pencircle scaled n enddef; +def wpss expr n= withpen pensquare scaled n enddef; +def sqr(expr WD,HT)= ((0,0)--(WD,0)--(WD,HT)--(0,HT)--cycle) enddef; +def sfB(expr p,l,r)= p shifted ((l,0) rotated r) enddef; +def wz_put(expr PA,PB,PD,CL)= nC:=length(Le-Ls); + for i=0 upto nC/zebra_gap: + nA:=zebra_gap*i/nC; nD:=(zebra_gap*i+ratio_zebra_black*zebra_gap)/nC; + if nD>((nC-zebra_gap)/nC): nD:=1; fi + fill nA[PB,PA]--nA[PD,PA]--nD[PD,PA]--nD[PB,PA]--cycle Cp(CL); endfor enddef; +def bz_put(expr PA,PB,PC,PD,CL)= nC:=length(Le-Ls); + for i=0 upto nC/zebra_gap: + nA:=zebra_gap*i/nC; nD:=(zebra_gap*i+ratio_zebra_black*zebra_gap)/nC; + fill nA[PB,PA]--nA[PD,PC]--nD[PD,PC]--nD[PB,PA]--cycle Cp(CL); endfor enddef; +def cut_off(expr p,w,h,s)= + p intersectionpoint sqr(1.1w,1.1h) shifted (s-(.5(1.1w),.5(1.1h))); enddef; +def clipping(expr SA,SB,PA,PB,LEN)= + pT:=PA--PB; nA:=0.6atom_wd/LEN; + if (SA=0)and(SB=0): Ls:=PA; Le:=PB; pA:=pB:=pT; pC:=0.1[PA,PB]--0.1[PB,PA]; + elseif SA=0: Ls:=PA; Le:=cut_off(pT,atom_wd*str_wd[SB],atom_wd,PB); + pA:=Ls--Le; pB:=Ls--nA[PB,PA]; pC:=0.1[PA,PB]--Le; + elseif SB=0: Ls:= cut_off(pT,atom_wd*str_wd[SA],atom_wd,PA); Le:=PB; + pA:=Ls--Le; pB:=nA[PA,PB]--Le; pC:=Ls--(0.1)[PB,PA]; + else: Ls:=cut_off(pT,atom_wd*str_wd[SA],atom_wd,PA); + Le:=cut_off(pT,atom_wd*str_wd[SB],atom_wd,PB); + pB:=nA[PA,PB]--nA[PB,PA]; pC:=pA:=Ls--Le; fi enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -mc_num:=first_def_number; +def_num:=def_emb_start; +%------------------------------------------------------------------------------------------------- lr:='(60 for i==1 upto 10:: ,-60,60 endfor); rl:='(-60,lr); def ring expr n= <((-180 DIV n)-90),(_chg_len,0), for i==2 upto n:: ,(360 DIV n) endfor,(_cyc_sB,1-n) enddef; @@ -674,7 +657,7 @@ for i=1 upto 20: ![i]:='({{,(_get_len,0),! for j==2 upto i::,! endfor,}}); end Me:='(); Et:=!; Pr:='(!2); Bu:='(!3); for i=4,5,6: for j=2 upto i-2: ?[i][j]:='((_fuse,i),(j,0)); endfor endfor for i=5,6,7,8: for j=11 upto 15: ?[i][j]:='((_fuse,i),(j,0)); endfor endfor -%------------------------------------------------------------------------------------------------- +%================================================================================================= H :='("H");C:='("C");N:='("N");O:='("O");F:='("F");S:='("S");P:='("P");I:='("I"); Si:='("{Si}");Al:='("{Al}");Mg:='("{Mg}");Zn:='("{Zn}");As:='("{As}");Cu:='("{Cu}"); Ag:='("{Ag}");Au:='("{Au}");Sn:='("{Sn}");Cl:='("{Cl}");Br:='("{Br}");Li:='("{Li}"); @@ -691,130 +674,155 @@ COOtBu:='(COO,!,tBu); NMeMe:='(N,/Me,!); NHCOMe:='(NH,!,//O,!); NHiPr:='(NH,!,iP NHtBu:='(NH,!,tBu);NHH:='(N,/H,!,H); NHMe:='(NH,!); NHEt:='(NH,!,Et); CF2:='(/F,60,F); CCl2:='(/Cl,60,Cl); CBr2:='(/Br,60,Br); CF3:='(/F,/F^60,60,F); CCl3:='(/Cl,/Cl^60,60,Cl);CBr3:='(/Br,/Br^60,60,Br);O_H:='(O,!,H);CO_H:='(//O,!,H); -%------------------------------------------------------------------------------------------------ +%================================================================================================== CO_OH:='(//O,!,O,!,H); C_N:='(!~tm,N); N_HH:='(N,/H,60,H); N_OO:='(N,//O,60~dm,O); S_H:='(S,!,H); N_H:='(N,/H); C_HHH:='(/H,/H^60,60,H); %-------------------------------------------------------------------------------------------------- def expand_set= save CH,NH,NO,OH,CHO,COOH,CN,SH; CH3:=C_HHH; NH:=N_H; NH2:=N_HH; NO2:=N_OO; OH:=O_H; CHO:=CO_H; COOH:=CO_OH; CN:=C_N; SH:=S_H; enddef; -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -def SP(expr a,b)expr p=subpath(a*length(p),b*length(p)) of p enddef; -def vL= withpen penrazor scaled fP enddef; -def hL= withpen penrazor rotated 90 scaled fP enddef; -def sH expr a= shifted (0,a) enddef; -def PO= z10..(.8aW,fH)..tension 1.5..(.2aW,fH)..z09..(.2aW,hP)..tension 1.5..(.8aW,hP)..cycle +%================================================================================================== +message "-- total "&decimal(def_num)&" embedded definition --"; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +def char_size_set(expr a)(expr b)(expr c)(expr s)= + for j=0 upto length(s)-1: nA:=ASCII(pic_c(j,s)); + tbl_char_wd[nA]:=a; tbl_char_ht[nA]:=b; tbl_char_dp[nA]:=c; + endfor enddef; -def POh= (hP,.25aH)..z19..(fW,.25aH)..(hW,hH)..cycle enddef; +%--------------------------------------------------------------- +char_size_set( 1)( 1)( 0)("CGHMNOQ"); +char_size_set(.9)( 1)( 0)("ABDEFIJKLPRSTUVWXYZ-+/><m"); +char_size_set(.7)( 1)( 0)(" ()0123456789nhj=*bdiltf"); +char_size_set(.7)( 1)(.15)("pqg"); +char_size_set(.7)(.8)( 0)("acekosuvxzwry"); +char_size_set(.4)( 1)( 0)(".,:;'`"); +%------------------------------------------------------------------------------------------------ +def proc_char_setup(expr a)= +begingroup +save Z,aW,aH,fW,hW,hW,hH,fP,hP,vL,hL,PO,POh,sH,FD; +pair Z[]; +%--------------------------------------------------------------- def FD(expr c)(text s)= -if f_char[ASCII(c)]=1: - aW:=char_w[ASCII(c)]*(1-ratio_atomgap_atom*2); - aH:=char_h[ASCII(c)]*(1-ratio_atomgap_atom*2); - fW:=aW-hP; hW:=.5aW; fH:=aH-hP; hH:=.5aH; - z01=( 0,hP); z02=(hP, 0); z03=(hP,hP); z05=(aW,hP); z07=(fW, 0); z08=( 0,hH); z09=(hP,hH); - z10=(fW,hH); z12=( 0,fH); z13=(hP,fH); z14=(hW,fH); z16=(aW,fH); z18=(hP,aH); z19=(hW,hP); - s; - atom_font[ASCII(c)]:= + if f_char[ASCII(c)]=1: + aW#:=atom_wd#*tbl_char_wd[ASCII(c)]*(1-ratio_atomgap_atom*2); + aH#:=atom_wd#*tbl_char_ht[ASCII(c)]*(1-ratio_atomgap_atom*2); + define_pixels(aW,aH); + 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); Z08:=( 0,hH); + Z09:=(hP,hH); Z10:=(fW,hH); Z12:=( 0,fH); Z13:=(hP,fH); Z14:=(hW,fH); Z16:=(aW,fH); + Z18:=(hP,aH); Z19:=(hW,hP); Z20:=(hW,hH); Z06:=(hW,aH); Z07:=(hW, 0); Z11:=(hW,aW); + Z15:=(fW,aH); Z17:=(aW,hH); + s; + atom_font[ASCII(c)]:= currentpicture shifted (ratio_atomgap_atom*atom_wd,ratio_atomgap_atom*atom_wd); - clearxy; save x,y; clearit; -fi + clearit; + fi enddef; -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -def char_font_setup(expr a)= pickup pencircle scaled a; fP:=a; hP:=.5a; +%----------------------------------------------------------------------------------------- +def vL= withpen penrazor scaled fP enddef; +def hL= withpen penrazor rotated 90 scaled fP enddef; +def PO= + Z10..(.8aW,fH)..tension 1.5..(.2aW,fH)..Z09..(.2aW,hP)..tension 1.5..(.8aW,hP)..cycle enddef; +def POh= (hP,.25aH)..Z19..(fW,.25aH)..Z20..cycle enddef; +def sH expr n= shifted (0,n) enddef; +def SP(expr m,n)expr p=subpath(m*length(p),n*length(p)) of p enddef; +%================================================================================================== +pickup pencircle scaled a; fP:=a; hP:=.5a; FD(" ")(); -FD(".")(drawdot z19 wpcs fP); -FD(",")(drawdot z19 wpcs fP; draw (hW+.5fP,hP)..(hW+.3fP,-fP)..(hW-.5fP,hP-2fP)); -FD("'")(drawdot z14 wpcs fP; draw (hW+.5fP,fH)..(hW+.3fP,fH-fP)..(hW-.5fP,fH-2fP)); +FD(".")(drawdot Z19 wpcs fP); +FD(",")(drawdot Z19 wpcs fP; draw (hW+.5fP,hP)..(hW+.3fP,-fP)..(hW-.5fP,hP-2fP)); +FD("'")(drawdot Z14 wpcs fP; draw (hW+.5fP,fH)..(hW+.3fP,fH-fP)..(hW-.5fP,fH-2fP)); FD("`")(drawdot (hW,fH-2fP) wpcs fP;draw (hW-.5fP,fH-2fP)..(hW-.3fP,fH-fP)..(hW+.5fP,fH)); FD(":")(drawdot (hW,.2aH) wpcs fP; drawdot (hW,.8aH) wpcs fP); FD(";")(drawdot (hW,.2aH) wpcs fP; drawdot (hW,.8aH) wpcs fP;draw (hW+hP,.2aH)..(hW-hP,.2aH-2fP)); -FD("(")(draw z19...z09...z14); -FD(")")(draw z19...z10...z14); -FD(">")(cutdraw z01--(aW,hH)--z12); -FD("<")(cutdraw z16--z08--z05); -FD("0")(draw z09...z14...z10...z19...cycle); -FD("1")(draw (hW, 0)--(hW,aH)--(hW-hP,fH)--(hW-hP,aH-2.5hP) vL); -FD("2")(cutdraw SP(0,.71)(hP,1.3hP)--(fW,.55aH)..z14..(hP,.5aH)..(hW,.27aH); draw z05--z01 hL); -FD("3")(cutdraw SP(0,.77)POh; cutdraw SP(.23,.95)POh sH .5aH-hP; draw (.3aW,hH)--(hW,hH) hL); +FD("(")(draw Z19...Z09...Z14); +FD(")")(draw Z19...Z10...Z14); +FD(">")(cutdraw Z01--Z17--Z12); +FD("<")(cutdraw Z16--Z08--Z04); +FD("0")(draw Z09...Z14...Z10...Z19...cycle); +FD("1")(draw Z07--Z06--(hW-hP,fH)--(hW-hP,aH-2.5hP) vL); +FD("2")(cutdraw SP(0,.71)(hP,1.3hP)--(fW,.55aH)..Z14..(hP,.5aH)..(hW,.27aH); draw Z04--Z01 hL); +FD("3")(cutdraw SP(0,.77)POh; cutdraw SP(.23,.95)POh sH .5aH-hP; draw (.3aW,hH)--Z20 hL); FD("4")(draw (0,.3aH)--(aW,.3aH) hL; draw (.7aW,0)--(.7aW,aH)--(1.2hP,.3aH+hP) vL); -FD("5")(draw z12--z16 hL; draw z13--(hP,.49aH) vL; +FD("5")(draw Z12--Z16 hL; draw Z13--(hP,.49aH) vL; cutdraw (.5hP,.15aH)..(.65aW,1.3hP)..(fW,.3aH)..(hW,.6aH)..(.6hP,.53aH)); -FD("6")(draw z19..(fW,.5fW)..(hW,fW)..(hP,.5fW)..cycle; cutdraw (hP,.4aH)--(hW,aH)); -FD("7")(draw (0,.fH)--(aW,fH) hL; draw (aW-1.2hP,aH-fP)--(.4aW,0) vL scaled 1.2); -FD("8")(draw POh; draw (hP,.75aH)...z14...(fW,.75aH)...(hW,hH)...cycle;); -FD("9")(draw z19..(fW,.5fW)..(hW,fW)..(hP,.5fW)..cycle sH .32aH; cutdraw (fW,.6aH)--(hW, 0)); -FD("A")(draw z02--(hW,aH)--z07 vL scaled 1.14; draw .33[z02,(hW,aH)]--.33[z07,(hW,aH)]); -FD("B")(draw z13--z14{right}..(.9fH,.75aH)..{left}(.5aW,hH)--z09--(.5aW,hH){right}.. - (.9fH,.25aH)..{left}z19--z03; draw z02--z18 vL); +FD("6")(draw Z19..(fW,.5fW)..(hW,fW)..(hP,.5fW)..cycle; cutdraw (hP,.4aH)--Z06); +FD("7")(draw (0,.fH)--Z16 hL; draw (aW-1.2hP,aH-fP)--(.4aW,0) vL scaled 1.2); +FD("8")(draw POh; draw (hP,.75aH)...Z14...(fW,.75aH)...Z20...cycle;); +FD("9")(draw Z19..(fW,.5fW)..(hW,fW)..(hP,.5fW)..cycle sH .32aH; cutdraw (fW,.6aH)--Z07); +FD("A")(draw Z02--Z06--Z05 vL scaled 1.14; draw .33[Z02,Z06]--.33[Z05,Z06]); +FD("B")(draw Z13--Z14{right}..(.9fH,.75aH)..{left}(.5aW,hH)--Z09--(.5aW,hH){right}.. + (.9fH,.25aH)..{left}Z19--Z03; draw Z02--Z18 vL); FD("C")(cutdraw SP(.05,.95)PO); -FD("D")(draw z13--z14..z10..z19--z03; draw z02--z18 vL); -FD("E")(draw z05--z01 hL;draw z12--z16 hL;draw z08--(aW,hH) hL;draw z02--z18 vL); -FD("F")(draw z12--z16 hL; draw (0,.45aH)--(fW,.45aH) hL; draw z02--z13 vL); -FD("G")(cutdraw SP(.06,.97)PO; draw bot (hW,hH)-- bot (aW,hH) hL); -FD("H")(draw z02--z18 vL; draw z09--z10; draw z07--(fW,aH) vL); -FD("I")(draw z19--z14 vL; draw (hW-fP,hP)--(hW+fP,hP) hL; draw (hW-fP,fH)--(hW+fP,fH) hL); -FD("J")(cutdraw z09..(hP,.4aH){down}..{right}z19{right}..{up}(fW,.4aH)..(fW,aH)); -FD("K")(cutdraw z02--z18; cutdraw .5[.45[z02,z18],z16]--z07; cutdraw .45[z02,z18]--z16); -FD("L")(draw z05--z01 hL; draw z02--z18 vL); -FD("M")(draw z02--z18 vL; draw z18--z19--(fW,aH) vL scaled 1.14; draw (fW,aH)--z07 vL); -FD("N")(draw z02--z18 vL; draw z07--(fW,aH) vL;draw (1.4hP,aH)--(aW-1.4hP,0) vL scaled 1.4); +FD("D")(draw Z13--Z14..Z10..Z19--Z03; draw Z02--Z18 vL); +FD("E")(draw Z04--Z01 hL;draw Z12--Z16 hL;draw Z08--Z17 hL;draw Z02--Z18 vL); +FD("F")(draw Z12--Z16 hL; draw (0,.45aH)--(fW,.45aH) hL; draw Z02--Z13 vL); +FD("G")(cutdraw SP(.06,.97)PO; draw bot Z20-- bot Z17 hL); +FD("H")(draw Z02--Z18 vL; draw Z09--Z10; draw Z05--Z15 vL); +FD("I")(draw Z19--Z14 vL; draw (hW-fP,hP)--(hW+fP,hP) hL; draw (hW-fP,fH)--(hW+fP,fH) hL); +FD("J")(cutdraw Z09..(hP,.4aH){down}..{right}Z19{right}..{up}(fW,.4aH)..Z15); +FD("K")(cutdraw Z02--Z18; cutdraw .5[.45[Z02,Z18],Z16]--Z05; cutdraw .45[Z02,Z18]--Z16); +FD("L")(draw Z04--Z01 hL; draw Z02--Z18 vL); +FD("M")(draw Z02--Z18 vL; draw Z18--Z19--Z15 vL scaled 1.14; draw Z15--Z05 vL); +FD("N")(draw Z02--Z18 vL; draw Z05--Z15 vL;draw (1.4hP,aH)--(aW-1.4hP,0) vL scaled 1.4); FD("O")(draw PO); -FD("P")(draw z02--z18 vL; draw z13--(.3aW,fH){right}..(fW,.7aH)..{left}(.3aW,.44aH)..(hP,.44aH)) -FD("Q")(draw PO; draw (.6aW,.4aH)--z07); -FD("R")(draw z02--z18 vL; draw z13--(.3aW,fH){right}..(fW,.7aH)..{left}(.3aW,.44aH)..(hP,.44aH); - cutdraw z07{up}..{left}(hW,.44aH)); +FD("P")(draw Z02--Z18 vL; draw Z13--(.3aW,fH){right}..(fW,.7aH)..{left}(.3aW,.44aH)..(hP,.44aH)) +FD("Q")(draw PO; draw (.6aW,.4aH)--Z05); +FD("R")(draw Z02--Z18 vL; draw Z13--(.3aW,fH){right}..(fW,.7aH)..{left}(.3aW,.44aH)..(hP,.44aH); + cutdraw Z05{up}..{left}(hW,.44aH)); FD("S")(cutdraw SP(.05,.45)PO; cutdraw SP(.55,.95)PO; draw (fW,.3aH){up}..{up}(hP,.7aH)); -FD("T")(draw z12--z16 hL;draw .5[z12,z16]--(hW, 0) vL); -FD("U")(cutdraw z18..z09{down}..{right}z19{right}..{up}z10..(fW,aH)); -FD("V")(draw z18--(hW, 0) vL scaled 1.2; draw (hW, 0)--(fW,aH) vL scaled 1.2); -FD("W")(draw z18--(.25aW,0)--(hW,aH)--(.75aW,0)--(fW,aH) vL scaled 1.08); -FD("X")(draw z18..z07 vL scaled 1.4; draw z02..(fW,aH) vL scaled 1.4); -FD("Y")(draw z18--(hW,hH)--(fW,aH) vL scaled 1.2; draw (hW,hH)--(hW, 0) vL); -FD("Z")(draw z12--z16 hL;draw (1.4hP,fP)--(aW-1.4hP,aH-fP) vL scaled 1.4;draw z01--z05 hL); -FD("-")(draw z09--z10 hL); +FD("T")(draw Z12--Z16 hL;draw .5[Z12,Z16]--Z07 vL); +FD("U")(cutdraw Z18..Z09{down}..{right}Z19{right}..{up}Z10..Z15); +FD("V")(draw Z18--Z07--Z15 vL scaled 1.2); +FD("W")(draw Z18--(.25aW,0)--Z06--(.75aW,0)--Z15 vL scaled 1.08); +FD("X")(draw Z18..Z05 vL scaled 1.4; draw Z02..Z15 vL scaled 1.4); +FD("Y")(draw Z18--Z20--Z15 vL scaled 1.2; draw Z20--Z07 vL); +FD("Z")(draw Z12--Z16 hL;draw (1.4hP,fP)--(aW-1.4hP,aH-fP) vL scaled 1.4;draw Z01--Z04 hL); +FD("-")(draw Z09--Z10 hL); FD("=")(draw (hP,.3aH)--(fW,.3aH) hL;draw (hP,.6aH)--(fW,.6aH) hL); -FD("/")(draw (fW,fH)..z01); -FD("+")(draw z19--z14 vL; draw z09--z10 hL); -FD("a")(draw z19..z10..z14..z09..cycle; draw z07--(fW,aH) vL); -FD("b")(draw z19..z10..(hW,aW)..z09..cycle; draw z02--(hP,1.2aH) vL); -FD("c")(cutdraw SP(.06,.94)z10..z14..z09..z19..cycle); -FD("d")(draw z19..z10..(hW,aW)..z09..cycle; draw z07--(fW,1.2aH) vL); -FD("e")(cutdraw SP(0,.92)z10..z14..z09..z19..cycle; draw z10--z09); -FD("f")(cutdraw (.5aW,0)--(.5aW,.75aH){up}..(.75aW,fH)..{down}(fW,.8aH); draw z08--(aW,hH) hL); -FD("g")(draw z19..z10..(hW,aW)..z09..cycle sH .3aH; cutdraw (fW,aH)--(fW,hP)..(hW,0)..(.1aW,fP)); -FD("h")(draw z02..(hP,.3aH){up}..(hW,.7fH)..{down}(fW,.3aH)..z07; draw (hP,.3aH)--z18 vL); -FD("i")(draw (hW, 0)--(hW,.63aH) vL; draw z14 wpcs 1.4fP); -FD("j")(draw z19--(hW,.63aH) vL; draw z19..(.25aW,-hP)..z01; draw z14 wpcs 1.4fP); -FD("k")(draw z02--z18 vL; cutdraw .5[.45[z02,z18],z16]--z07; cutdraw .45[z02,z18]--z16); -FD("l")(draw (hW, 0)--(hW,aH) vL; draw z14--z13 hL; draw z19--(fW,hP) hL); -FD("m")(cutdraw z02..(hP,.3aH){up}..(.28aW,.7fH)..{down}(hW,.3aH)..(hW, 0); - cutdraw (hW,.3aH){up}..(.7aW,.7aH-hP)..{down}(fW,.3aH)..z07; draw (hP,.3aH)--(hP,.7aH) vL); -FD("n")(cutdraw z02..(hP,.3aH){up}..(hW,.7fH)..{down}(fW,.3aH)..z07; draw (hP,.3aH)--(hP,.7aH) vL); -FD("o")(draw z19..z10..z14..z09..cycle); -FD("p")(draw z19..z10..(hW,aW)..z09..cycle sH .3aH; draw (hP,0)--z18 vL); -FD("q")(draw z19..z10..(hW,aW)..z09..cycle sH .3aH; draw (fW,0)--(fW,aH) vL); -FD("r")(cutdraw SP(.35,.72)z19..z10..z14..z09..cycle sH -fP; draw z02--z18 vL); +FD("/")(draw (fW,fH)..Z01); +FD("+")(draw Z19--Z14 vL; draw Z09--Z10 hL); +FD("a")(draw Z19..Z10..Z14..Z09..cycle; draw Z05--Z15 vL); +FD("b")(draw Z19..Z10..Z11..Z09..cycle; draw Z02--(hP,1.2aH) vL); +FD("c")(cutdraw SP(.06,.94)Z10..Z14..Z09..Z19..cycle); +FD("d")(draw Z19..Z10..Z11..Z09..cycle; draw Z05--(fW,1.2aH) vL); +FD("e")(cutdraw SP(0,.92)Z10..Z14..Z09..Z19..cycle; draw Z10--Z09); +FD("f")(cutdraw (.5aW,0)--(.5aW,.75aH){up}..(.75aW,fH)..{down}(fW,.8aH); draw Z08--Z17 hL); +FD("g")(draw Z19..Z10..Z11..Z09..cycle sH .3aH; cutdraw Z15--(fW,hP)..(hW,0)..(.1aW,fP)); +FD("h")(draw Z02..(hP,.3aH){up}..(hW,.7fH)..{down}(fW,.3aH)..Z05; draw (hP,.3aH)--Z18 vL); +FD("i")(draw Z07--(hW,.63aH) vL; draw Z14 wpcs 1.4fP); +FD("j")(draw Z19--(hW,.63aH) vL; draw Z19..(.25aW,-hP)..Z01; draw Z14 wpcs 1.4fP); +FD("k")(draw Z02--Z18 vL; cutdraw .5[.45[Z02,Z18],Z16]--Z05; cutdraw .45[Z02,Z18]--Z16); +FD("l")(draw Z07--Z06 vL; draw Z14--Z13 hL; draw Z19--(fW,hP) hL); +FD("m")(cutdraw Z02..(hP,.3aH){up}..(.28aW,.7fH)..{down}(hW,.3aH)..Z07; + cutdraw (hW,.3aH){up}..(.7aW,.7aH-hP)..{down}(fW,.3aH)..Z05; draw (hP,.3aH)--(hP,.7aH) vL); +FD("n")(cutdraw Z02..(hP,.3aH){up}..(hW,.7fH)..{down}(fW,.3aH)..Z05; draw (hP,.3aH)--(hP,.7aH) vL); +FD("o")(draw Z19..Z10..Z14..Z09..cycle); +FD("p")(draw Z19..Z10..Z11..Z09..cycle sH .3aH; draw (hP,0)--Z18 vL); +FD("q")(draw Z19..Z10..Z11..Z09..cycle sH .3aH; draw (fW,0)--Z15 vL); +FD("r")(cutdraw SP(.35,.72)Z19..Z10..Z14..Z09..cycle sH -fP; draw Z02--Z18 vL); FD("s")(cutdraw SP(.05,.45)PO; cutdraw SP(.55,.95)PO; draw (fW,.3aH){up}..{up}(hP,.7aH)); -FD("t")(draw (hW, 0)--(hW,aH) vL; draw (0,.66aH)--(aW,.66aH) hL); -FD("u")(cutdraw z18..(hP,.55aH){down}..z19..(fW,.55aH){up}..(fW,aH); draw (fW,aH)--z07 vL); -FD("v")(draw z18--(hW, 0)--(fW,aH) vL); -FD("w")(draw z18--(.25aW,0)--(hW,aH)--(.75aW,0)--(fW,aH) vL); -FD("x")(draw z18--z07 vL scaled 1.4; draw (fW,aH)--z02 vL scaled 1.4); -FD("y")(draw z18--(hW,hH) vL scaled 1.4; draw (fW,aH)--z02 vL scaled 1.4); -FD("z")(draw z12--z16 hL;draw (1.4hP,fP)--(aW-1.4hP,aH-fP) vL scaled 1.4; draw z01--z05 hL); -enddef; -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +FD("t")(draw Z07--Z06 vL; draw (0,.66aH)--(aW,.66aH) hL); +FD("u")(cutdraw Z18..(hP,.55aH){down}..Z19..(fW,.55aH){up}..Z15; draw Z15--Z05 vL); +FD("v")(draw Z18--Z07--Z15 vL); +FD("w")(draw Z18--(.25aW,0)--Z06--(.75aW,0)--Z15 vL); +FD("x")(draw Z18--Z05 vL scaled 1.4; draw Z15--Z02 vL scaled 1.4); +FD("y")(draw Z18--Z20 vL scaled 1.4; draw Z15--Z02 vL scaled 1.4); +FD("z")(draw Z12--Z16 hL;draw (1.4hP,fP)--(aW-1.4hP,aH-fP) vL scaled 1.4; draw Z01--Z04 hL); +endgroup +enddef; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def blank_str:= " " enddef; -def fixed_r(expr n)(expr s)= (substring(0,n-length(s)) of blank_str)&s enddef; -def fixed_l(expr n)(expr s)= s&(substring(0,n-length(s)) of blank_str) enddef; -def fdr(expr n)(expr s)=fixed_r(n)(decimal(s)) 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; def warning(expr s)= message "% "&decimal(char_num)&fdr(3)(incr warning_cnt)&")"&s&" !!!"; enddef; def B_check(expr s)(expr t)(expr n)= if com_str[strA[s]]=t: if bond_cnt>n: warning(fdr(4)(s)&" ["&com_str[strA[s]]&"] has "&fdr(3)(bond_cnt)&" bonds"); fi fi enddef; vardef stripP(expr a)=if length(a)=4: substring (1,3) of a else: a fi enddef; -%=================================================================================================== +%================================================================================================== def proc_get_info= for j=1 upto inf_num: nA:=0; for i=0 upto length(info[j]): if pic_c(i,info[j])=":": nA:=i; fi exitif nA>0; endfor @@ -829,16 +837,21 @@ def proc_get_info= fi endfor enddef; -%-------------------------------------------------------------------------------------------------- -def STa(expr a,b)= tblA[incr awt_tbl_cnt]:=a; tblN[awt_tbl_cnt]:=0; tblWt[awt_tbl_cnt]:=b; enddef; -def STb(expr a)(text s)= tblA[incr awt_tbl_cnt]:=a; tblN[awt_tbl_cnt]:=0; - for list=s: tblN[awt_tbl_cnt]:=tblN[awt_tbl_cnt]+1; - for j=1 upto awt_tbl_cnt: if list=tblA[j]: tblB[awt_tbl_cnt][tblN[awt_tbl_cnt]]:=j; fi endfor +%================================================================================================== +def STa(expr a,b)= + tbl_atom_str[incr tbl_cnt]:=a; tbl_atom[tbl_cnt]:=0; tbl_atom_wt[tbl_cnt]:=b; +enddef; +%---------------------------------------------------------------------------------- +def STb(expr a)(text s)= + tbl_atom_str[incr tbl_cnt]:=a; tbl_atom[tbl_cnt]:=0; + for list=s: tbl_atom[tbl_cnt]:=tbl_atom[tbl_cnt]+1; + for j=1 upto tbl_cnt: + if list=tbl_atom_str[j]: tbl_subst[tbl_cnt][tbl_atom[tbl_cnt]]:=j; fi + endfor endfor enddef; -%-------------------------------------------------------------------------------------------------- -awt_tbl_cnt:=0; -def set_atom_wt_tbl= +%================================================================================================== +tbl_cnt:=0; STa("C",12.0107); STa("H",1.00794); STa("{Al}",26.9815); STa("{As}",74.9236); STa("B",10.811); STa("{Br}",79.904); STa("{Ca}",40.078); STa("{Cl}",35.453); STa("{Cu}",63.546); STa("D",2.012); STa("F",18.9984); STa("{Fe}",55.845); STa("{Hg}",200.59); STa("I",126.90447); STa("K",39.0983); @@ -851,8 +864,7 @@ STb("SH")("S","H"); STb("CHO")("C","H","O"); STb("N{O_2_}")("N","O","O"); STb("N{H_2_}")("N","H","H"); STb("S{O_3_}")("S","O","O","O"); STb("COOH")("C","O","O","H"); STb("C{H_3_}")("C","H","H","H"); STb("C{F_3_}")("C","F","F","F"); -enddef; -%=================================================================================================== +%================================================================================================== def proc_calc_out= begingroup save warning_cnt,cal_MW,cal_MWp,knownA,cal_FM,bondC,tmp_wtp,bond_cnt,hide_H, @@ -862,9 +874,8 @@ def proc_calc_out= inf_NO,inf_EN,inf_JN,inf_FM,inf_CAS,inf_USE,inf_EXA,inf_EXB,inf_MW; inf_NO:=inf_EN:=inf_JN:=inf_FM:=inf_CAS:=inf_USE:=inf_EXA:=inf_EXB:=inf_MW:=""; cal_MW_str:=cal_FM:=""; hide_H:=warning_cnt:=cal_MW:=cal_MWp:=0; - if awt_tbl_cnt=0: set_atom_wt_tbl fi proc_get_info; - for i=1 upto awt_tbl_cnt: sumA[i]:=0; endfor + for i=1 upto tbl_cnt: sumA[i]:=0; endfor for i=1 upto cntA: knownA:=bond_cnt:=0; for j=1 upto cntB: if (lineB[j]=dl)or(lineB[j]=dr)or(lineB[j]=dm): bondC[j]:=2; elseif (lineB[j]=tm): bondC[j]:=3; elseif lineB[j]=nl: bondC[j]:=0; @@ -875,29 +886,43 @@ def proc_calc_out= if com_str[strA[i]]="C": if bond_cnt<4: hide_H:=hide_H+(4-bond_cnt); fi fi B_check(i)("C")(4); B_check(i)("H")(1); B_check(i)("O")(2); B_check(i)("F")(1); B_check(i)("{Cl}")(1); B_check(i)("Br}")(1); - for j=1 upto awt_tbl_cnt: - if com_str[strA[i]]=tblA[j]: - if tblN[j]=0: sumA[j]:=sumA[j]+1; - else: for k=1 upto tblN[j]: sumA[tblB[j][k]]:=sumA[tblB[j][k]]+1; endfor fi + for j=1 upto tbl_cnt: + if com_str[strA[i]]=tbl_atom_str[j]: + if tbl_atom[j]=0: sumA[j]:=sumA[j]+1; + else: for k=1 upto tbl_atom[j]: sumA[tbl_subst[j][k]]:=sumA[tbl_subst[j][k]]+1; endfor fi knownA:=1; fi endfor if knownA=0: warning(" Unknown Str("&com_str[strA[i]]&") is used "&decimal(i)); fi endfor sumA[2]:=sumA[2]+hide_H; - for i=1 upto awt_tbl_cnt: + for i=1 upto tbl_cnt: if sumA[i]>=1: - tmp_wtp:=(tblWt[i]/100)*sumA[i]; - if (tmp_wtp<=40)and(cal_MWp<=40): cal_MW:=cal_MW+(tblWt[i]*sumA[i]); + tmp_wtp:=(tbl_atom_wt[i]/100)*sumA[i]; + if (tmp_wtp<=40)and(cal_MWp<=40): cal_MW:=cal_MW+(tbl_atom_wt[i]*sumA[i]); else: cal_MWp:=cal_MWp+tmp_wtp; fi - cal_FM:=cal_FM&stripP(tblA[i]) if sumA[i]>=2: &decimal(sumA[i]) fi; + cal_FM:=cal_FM&stripP(tbl_atom_str[i]) if sumA[i]>=2: &decimal(sumA[i]) fi; fi endfor - if sw_auxout=1: auxfile_out; fi - if sw_checklist=1: checklist_out; fi - if sw_MOLout=1: MOLfileout; fi + if sw_auxout=1: proc_auxfile_out; fi + if sw_checklist=1: proc_checklist_out; fi + if sw_MOLout=1: proc_MOLfile_out; fi endgroup enddef; %================================================================================================== -def checklist_out= nA:=0; +def auxtag_out= + for i=1 upto aux_max: exitif tag[i]=""; if i=1: printf tag[1] else: &aux_delimiter&tag[i] fi + endfor +enddef; +%================================================================================================== +def proc_auxfile_out= + for i=1 upto aux_max: exitif tag[i]=""; + if i=1: printf "" else: &aux_delimiter fi if sw_auxfix=0: &tag[i]&":" fi & + if string scantokens(var[i]): scantokens(var[i]) + elseif numeric scantokens(var[i]): decimal(scantokens(var[i])) fi + endfor + if sw_auxfix=0: for i=1 upto inf_num: &aux_delimiter&info[i] endfor; fi +enddef; +%================================================================================================== +def proc_checklist_out= nA:=0; message "% Molecular name = "& inf_EN; message "% There were "&fdr(3)(warning_cnt)& " warnings / Expanded command count= "&decimal(cntMC[0]); @@ -917,10 +942,11 @@ def checklist_out= nA:=0; message "%Fomula / Molecular weight ---------------------------------------"; if cal_MWp<=40: cal_MW_str:=fdr(10)(cal_MW); else: cal_MW_str:=fdr(10)(cal_MWp)&" * 100"; fi - for i=1 upto awt_tbl_cnt: + for i=1 upto tbl_cnt: if sumA[i]>=1: - message "% "&fixed_l(4)(stripP(tblA[i]))&"("&fdr(9)(tblWt[i])&") * "&fdr(6)(sumA[i])&" = " - if tmp_wtp<=40: &fdr(12)(tblWt[i]*sumA[i]); else: &fdr(12)(tmp_wtp)&" * 100"; fi fi + message "% "&fixed_l(4)(stripP(tbl_atom_str[i]))&"("&fdr(9)(tbl_atom_wt[i])& + ") * "&fdr(6)(sumA[i])&" = " + if tmp_wtp<=40: &fdr(12)(tbl_atom_wt[i]*sumA[i]); else: &fdr(12)(tmp_wtp)&" * 100"; fi fi endfor message "% Weight Calc: " &cal_MW_str &" / Input: " if inf_MW<>"": &inf_MW &" / weight gap= " &decimal(cal_MW-scantokens(inf_MW)) fi; @@ -928,8 +954,8 @@ def checklist_out= nA:=0; if inf_FM<>"": &inf_FM&" / "& if inf_FM=cal_FM: "MACTCH" else: "NOT MACTCH" fi fi; message "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"; enddef; -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -def MOLfileout= +%================================================================================================== +def proc_MOLfile_out= mp_log_name:=jobname&"-"&fit_zero(char_num)&decimal(char_num)&"-"&inf_EN&".mol"; 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"; @@ -944,4 +970,6 @@ def MOLfileout= printf fdr(3)(sB[i])&fdr(3)(eB[i])&fdr(3)(nA)&fdr(3)(nB)&" 0 0"; fi endfor printf "M END"; enddef; +%------------------------------------------------------------------------------------------------- +vardef fit_zero(expr n)=if n<=9: "00" elseif n<=99: "0" fi enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |