0 | module Geom.Gen2D.Debug
3 | import Chem.Aromaticity
6 | import Geom.Gen2D.Types
7 | import Geom.Gen2D.Generate
13 | toMolatomAT : (MolPoint, SmilesAtomAT) -> MolAtomAT
16 | , radical := NoRadical
18 | , position := toCoords p [0,0,0]
22 | toMolbond : SmilesBond -> MolBond
23 | toMolbond Sngl = MkBond False Single NoBondStereo
24 | toMolbond Arom = MkBond False Single NoBondStereo
25 | toMolbond Dbl = MkBond False Dbl NoBondStereo
26 | toMolbond Trpl = MkBond False Triple NoBondStereo
27 | toMolbond Quad = MkBond False Single NoBondStereo
28 | toMolbond FW = MkBond False Single NoBondStereo
29 | toMolbond BW = MkBond False Single NoBondStereo
31 | attachPoint : AttachPoint n -> String
32 | attachPoint None = ""
33 | attachPoint (Attach a n) = " (\{show a} -> \{show n})"
36 | showComponent : Component k e n -> String
37 | showComponent (C a xs r _) =
38 | let pre := the String $
if r then "Ring" else "Chain"
39 | in "\{pre}: \{show xs}\{attachPoint a}"
42 | printComponents : Graph e n -> IO ()
43 | printComponents (G _ g) = traverse_ (putStrLn . showComponent) (components g)
46 | test : String -> IO ()
48 | case readSmiles' s of
49 | Left x => putStrLn "\{x}"
50 | Right x => printComponents x
53 | coords : String -> IO ()
55 | case perceiveSmilesAtomTypes <$> readSmiles' s of
56 | Left x => putStrLn "\{x}"
57 | Right (G _ g) => putStrLn (pretty interpolate disp $
coordinates {dg = Debugging} g)
60 | disp : (MolPoint, SmilesAtomAT) -> String
61 | disp (p,a) = "\{a.elem.elem} : \{show p}"
64 | smilesToMol : String -> Either String MolfileAT
66 | case (kekulize (const Dbl) . perceiveSmilesAtomTypes) <$> readSmiles' s of
69 | let cg := coordinates {dg = NoDebugging} g
70 | mg := bimap toMolbond toMolatomAT cg
71 | in Right $
MkMolfile "" "" "" (G k mg) []
74 | mol : String -> IO ()
75 | mol = putStrLn . either interpolate writeMolfile . smilesToMol