diff options
author | Karl Berry <karl@freefriends.org> | 2016-04-28 21:42:17 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-04-28 21:42:17 +0000 |
commit | 421666a3551c85693aa8880d01fa24d9a0ec5dd9 (patch) | |
tree | 15d239f92456c0283aa3ed9ce68a754d4834600c /Master/texmf-dist/metapost | |
parent | f529089ae21bedbfe683bb242c18309d5f4bf034 (diff) |
mcf2graph (28apr16)
git-svn-id: svn://tug.org/texlive/trunk@40804 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost')
-rw-r--r-- | Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf | 74 |
1 files changed, 43 insertions, 31 deletions
diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf index 3bca433c396..af64639b040 100644 --- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf +++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% mcf2graph ver 3.89 Copyright (c) 2013-2016 Akira Yamaji +% mcf2graph ver 3.90 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, @@ -30,7 +30,7 @@ % Set output checklist : mpost -s ahlength=2 FILENAME %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% tracingstats:=1; -message " This is mcf2graph ver 3.8 2016.4"; +message " This is mcf2graph ver 3.9 2016.4"; %------------------------------------------------------------------------------------------------- pair posB[],posA[],pairT,Ls,Le,pairA; numeric angB[],angA[],br_ang[],sB[],eB[],f_FON[],atom_w[],atom_h[],atom_d[],strA[],stkB[],stkA[], @@ -38,13 +38,13 @@ numeric angB[],angA[],br_ang[],sB[],eB[],f_FON[],atom_w[],atom_h[],atom_d[],strA comMC[][],parMC[][],stock_p[],cntMC[],colorA[],colorB[],tblN[],tblB[][],wtA[],sumA[], CH[],NH[],NO[],SO[],CCl[],CF[],CBr[],?[],![],Ph[]; path pA,pB,pC,pT; -string info[],tblA[],com_str[],var[],tag[], - calc_formula,mp_log_name,mol_name,mol_formula,calc_weight_str,info_str,aux_delimiter; +string info[],tblA[],com_str[],var[],tag[],cal_FM,mp_log_name,inf_EN,inf_JN,inf_FM,cal_MW_str, + inf_USE,inf_EXA,inf_EXB,inf_str,aux_delimiter; picture atom_font[],chem_structure,temp_picture; %------------------------------------------------------------------------------------------------- sw_numberA:=sw_numberB:=sw_mol_frame:=sw_auxout:=sw_solid:=sw_expand:=sw_start_vector:=0; char_num:=str_cnt:=proc_end:=sw_font_frame:=sw_atom_frame:=sw_checklist:=sw_MOLout:=0; -sw_subst_off:=sw_bond_single:=0; +sw_subst_off:=sw_bond_single:=sw_auxfix:=0; 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 @@ -81,7 +81,7 @@ ratio_zebra_black:=0.4; ratio_wedge_bond:=0.12; ratio_atomgap_atom:=.05 offset_thickness#:=0.2pt#; offset_bond_gap#:=0.3pt#; offset_zebra_gap#:=0.1pt#; offset_wedge#:=0.4pt#; par_s=ASCII("{"); par_e=ASCII("}"); score_u=ASCII("_"); hat=ASCII("^"); -max_info_num:=12; for i:=1 upto max_info_num: info[i]:=":"; endfor +max_inf_num:=12; for i:=1 upto max_inf_num: info[i]:=":"; endfor 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, @@ -107,13 +107,19 @@ def restore_par(text t)= nA:=0; enddef; %------------------------------------------------------------------------------------------------- def beginfont(text s)= - mol_name:=mol_formula:=""; len_x:=len_y:=cntA:=info_num:=mol_weight:=f_beginchar:=0; + inf_EN:=inf_JN:=inf_FM:=inf_USE:=inf_EXA:=inf_EXB:=""; + len_x:=len_y:=cntA:=inf_num:=inf_MW:=f_beginchar:=0; store_par(parameter_list); stock_wd#:=font_wd#; stock_ht#:=font_ht#; ratio_bond_width:=1/30; - for list=s: info_num:=info_num+1; info[info_num]:=list; - if substring (0,2) of list="EN": mol_name:=substring (3,length(list)) of list; fi - if substring (0,2) of list="FM": mol_formula:=substring (3,length(list)) of list; fi - if substring (0,2) of list="MW": mol_weight:=scantokens(substring (3,length(list)) of list); fi + for list=s: inf_num:=inf_num+1; info[inf_num]:=list; + if substring (0,2) of list="NO": inf_NO:=scantokens(substring (3,length(list)) of list); + elseif substring (0,2) of list="MW": inf_MW:=scantokens(substring (3,length(list)) of list); + elseif substring (0,2) of list="EN": inf_EN:=substring (3,length(list)) of list; + elseif substring (0,2) of list="JN": inf_JN:=substring (3,length(list)) of list; + elseif substring (0,2) of list="FM": inf_FM:=substring (3,length(list)) of list; + elseif substring (0,3) of list="USE": inf_USE:=substring (4,length(list)) of list; + elseif substring (0,3) of list="EXA": inf_EXA:=substring (4,length(list)) of list; + elseif substring (0,3) of list="EXB": inf_EXB:=substring (4,length(list)) of list; fi endfor enddef; %------------------------------------------------------------------------------------------------- @@ -569,13 +575,19 @@ fi 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 +enddef; def auxfile_out= - for i=1 upto aux_max: exitif var[i]=""; - if i=1: printf "" else: &aux_delimiter fi &tag[i]&":"& - if string scantokens(var[i]): scantokens(var[i]) - elseif numeric scantokens(var[i]): decimal(scantokens(var[i])) fi - endfor - for i=1 upto info_num: &aux_delimiter&info[i] endfor; + 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; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% mc_num:=first_def_number; @@ -759,7 +771,7 @@ 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"); %------------------------------------------------------------------------------------------------- def mol_check= - hide_H:=warning_cnt:=calc_weight:=calc_weightp:=0; calc_formula:=""; + hide_H:=warning_cnt:=cal_MW:=cal_MWp:=0; cal_FM:=""; for i=1 upto tbl_max: sumA[i]:=0; endfor for i=1 upto cntA: knownA:=nA:=0; for j=1 upto cntB: if (lineB[j]=dl)or(lineB[j]=dr)or(lineB[j]=dm): bondC[j]:=2; @@ -782,16 +794,16 @@ def mol_check= for i=1 upto tbl_max: if sumA[i]>=1: tmp_wtp:=(wtA[i]/100)*sumA[i]; - if (tmp_wtp<=40)and(calc_weightp<=40): calc_weight:=calc_weight+(wtA[i]*sumA[i]); - else: calc_weightp:=calc_weightp+tmp_wtp; fi - calc_formula:=calc_formula&stripP(tblA[i]) if sumA[i]>=2: &decimal(sumA[i]) fi; + if (tmp_wtp<=40)and(cal_MWp<=40): cal_MW:=cal_MW+(wtA[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; fi endfor enddef; %------------------------------------------------------------------------------------------------ def checklist_out= - nA:=0; calc_weight_str:=""; - message "% Molecular name = "& mol_name; + nA:=0; cal_MW_str:=""; + message "% Molecular name = "& inf_EN; message "% There were "&fdr(3)(warning_cnt)& " warnings / Expanded command count= "&decimal(cntMC[0]); message "% width * height = " & fdr(8)(max_x-min_x)&" * "&fdr(8)(max_y-min_y); @@ -806,22 +818,22 @@ def checklist_out= for i=1 upto cntB: if lineB[i]<>0: message "% "&fdr(3)(incr nA)&" "&fdr(3)(sB[i])& " -> "&fdr(3)(eB[i])&" ("&fdr(3)(bondC[i]-si+1)&")"; fi endfor message "%Fomula / Molecular weight ---------------------------------------"; - if calc_weightp<=40: calc_weight_str:=fdr(10)(calc_weight); - else: calc_weight_str:=fdr(10)(calc_weightp)&" * 100"; fi + 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 tbl_max: if sumA[i]>=1: message "% "&fixed_l(4)(stripP(tblA[i]))&"("&fdr(9)(wtA[i])&") * "&fdr(6)(sumA[i])&" = " if tmp_wtp<=40: &fdr(12)(wtA[i]*sumA[i]); else: &fdr(12)(tmp_wtp)&" * 100"; fi fi endfor - message "% Weight Calc: " &calc_weight_str &" / Input: " - if mol_weight>0: &decimal(mol_weight) &" / weight gap= " &decimal(calc_weight-mol_weight) fi; - message "% Fomula Calc: "&calc_formula&" / Input: " - if mol_formula<>"":&mol_formula&" / "& - if mol_formula=calc_formula: "MACTCH" else: "NOT MACTCH" fi fi; + message "% Weight Calc: " &cal_MW_str &" / Input: " + if inf_MW>0: &decimal(inf_MW) &" / weight gap= " &decimal(cal_MW-inf_MW) fi; + message "% Fomula Calc: "&cal_FM&" / Input: " + if inf_FM<>"":&inf_FM&" / "& + if inf_FM=cal_FM: "MACTCH" else: "NOT MACTCH" fi fi; message "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"; enddef; %------------------------------------------------------------------------------------------------ def MOLfileout= - mp_log_name:=jobname&"-"&fit_zero(char_num)&decimal(char_num)&"-"&mol_name&".mol"; + 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"; for i=1 upto cntA: printf fdr(10)(xpart(posA[i])/BL)& fdr(10)(ypart(posA[i])/BL)& |