#! /usr/bin/python3 -t import mformula, mformula_svg import mformula_carbon_chain_horz as mcch import math; from math import sqrt,sin,cos,pi import rn def image_name(style, hydro): return "unbranched_carbon_chain" + \ "_hydro" + str(hydro)[0] + \ "_style" + style def image_descr(style, hydro): return \ """Basic test of {mformula_carbon_chain_horz}.""" + \ "\n" + \ ("With" if hydro else "Without") + " hydrogen atoms.\n" + \ "\n" + \ mformula_svg.style_descr(style) def build_formula(svg, hydro): # Well-isolated: MB1 = ( ('2c*', 3), ('2t*', 7), ('*', 9), ('3*', 11), ) n1 = 14 # Close but not cumulative: MB2 = ( ('2c*', 5), ('2c*', 7), ('2c*', 11), ('2t*', 13), ('2c*', 17), ('3*', 19), ('2t*', 23), ('2t*', 25), ('2t*', 29), ('3*', 31), ('3*', 34), ('3*', 36), ) n2 = 40 # Cumulative pairs of double bonds: MB3 = ( ('2R*', 10), ('2R', 11), ('*', 12), ('2S*', 15), ('2S', 16), ('*', 17), ('2*', 20), ('2', 21), ('*', 22), ) n3 = 25 # Cumulative triples of double bonds: MB4 = ( ('2c*', 5), ('2c*', 6), ('2c*', 7), ('2t*', 11), ('2t*', 12), ('2t*', 13), ('*', 20), ) n4 = 20 sfm = [None]*4 sfm[0] = mcch.build(svg,n1,MB1, False, False, True, False, ) sfm[1] = mcch.build(svg,n2,MB2, False, True, True, False, ) sfm[2] = mcch.build(svg,n3,MB3, True, False, True, False, ) sfm[3] = mcch.build(svg,n4,MB4, True, True, True, False, ) fm = mformula.obj() for k in range(4): if hydro: mcch.add_hydrogens(svg,sfm[k]) fm.add_subformula(sfm[k], False, 0, [0, -3*k]) return fm;