0 | module CyBy.Draw.Internal.Abbreviations
  1 |
  2 | import CyBy.Draw.Internal.Atom
  3 | import CyBy.Draw.Internal.Graph
  4 | import Derive.Prelude
  5 | import Text.Molfile
  6 |
  7 | %default total
  8 | %language ElabReflection
  9 |
 10 | public export
 11 | record Abbreviation where
 12 |   constructor A
 13 |   label  : String
 14 |   ||| Label to use when printing the abbreviation from right to left
 15 |   revlbl : String
 16 |   graph  : CDGraph
 17 |
 18 | %runElab derive "Abbreviation" [Show,Eq]
 19 |
 20 | abbr : String -> String -> String -> Abbreviation
 21 | abbr x y = A x y . readMolfile
 22 |
 23 | export
 24 | reverseLabel : String -> List Abbreviation -> String
 25 | reverseLabel s []              = s
 26 | reverseLabel s (A l r _ :: xs) = if s == l then r else reverseLabel s xs
 27 |
 28 | export
 29 | ph, cy : String
 30 | export
 31 | ac, oAc, bn, bz : String
 32 |
 33 | export
 34 | phenyl : CDGraph
 35 | phenyl = readMolfile ph
 36 |
 37 | export
 38 | abbreviations : List Abbreviation
 39 | abbreviations =
 40 |   [ abbr "Ac" "Ac" ac
 41 |   , abbr "Bn" "Bn" bn
 42 |   , abbr "Bz" "Bz" bz
 43 |   , abbr "Cy" "Cy" cy
 44 |   , abbr "OAc" "AcO" oAc
 45 |   , abbr "Ph" "Ph" ph
 46 |   ]
 47 |
 48 | ac =
 49 |   """
 50 |
 51 |   created by cyby-draw 1.0
 52 |   
 53 |     3  2     0                      V2000
 54 |      -2.3125    2.9375    0.0000   C
 55 |      -2.3125    4.1875    0.0000   O
 56 |      -3.3950    2.3124    0.0000   C
 57 |     1  2  2  0
 58 |     1  3  1  0
 59 |   M  END
 60 |   """
 61 |
 62 | oAc =
 63 |   """
 64 |
 65 |   created by cyby-draw 1.0
 66 |
 67 |     4  3     0                      V2000
 68 |      -2.1875    1.6875    0.0000   O
 69 |      -1.1049    2.3125    0.0000   C
 70 |      -0.0223    1.6875    0.0000   C
 71 |      -1.1049    3.5625    0.0000   O
 72 |     1  2  1  0
 73 |     2  3  1  0
 74 |     2  4  2  0
 75 |   M  END
 76 |   """
 77 |
 78 | ph =
 79 |   """
 80 |   
 81 |   created by cyby-draw 1.0
 82 |   
 83 |     6  6     0                      V2000
 84 |      -0.3125    1.5625    0.0000   C
 85 |      -1.3949    0.9375    0.0000   C
 86 |      -1.3949   -0.3125    0.0000   C
 87 |      -0.3125   -0.9375    0.0000   C
 88 |       0.7699   -0.3125    0.0000   C
 89 |       0.7699    0.9375    0.0000   C
 90 |     1  2  1  0
 91 |     1  6  2  0
 92 |     2  3  2  0
 93 |     3  4  1  0
 94 |     4  5  2  0
 95 |     5  6  1  0
 96 |   M  END
 97 |   """
 98 |
 99 | cy =
100 |   """
101 |   
102 |   created by cyby-draw 1.0
103 |   
104 |     6  6     0                      V2000
105 |      -0.3125    1.5625    0.0000   C
106 |      -1.3949    0.9375    0.0000   C
107 |      -1.3949   -0.3125    0.0000   C
108 |      -0.3125   -0.9375    0.0000   C
109 |       0.7699   -0.3125    0.0000   C
110 |       0.7699    0.9375    0.0000   C
111 |     1  2  1  0
112 |     1  6  1  0
113 |     2  3  1  0
114 |     3  4  1  0
115 |     4  5  1  0
116 |     5  6  1  0
117 |   M  END
118 |   """
119 |
120 | bn =
121 |   """
122 |
123 |   created by cyby-draw 1.0
124 |   
125 |     7  7     0                      V2000
126 |      -5.8125    2.0625    0.0000   C
127 |      -3.6476    4.5625    0.0000   C
128 |      -4.7299    3.9375    0.0000   C
129 |      -4.7299    2.6875    0.0000   C
130 |      -3.6476    2.0625    0.0000   C
131 |      -2.5650    2.6875    0.0000   C
132 |      -2.5650    3.9375    0.0000   C
133 |     1  4  1  0
134 |     2  3  1  0
135 |     2  7  2  0
136 |     3  4  2  0
137 |     4  5  1  0
138 |     5  6  2  0
139 |     6  7  1  0
140 |   M  END
141 |   """
142 |
143 | bz =
144 |   """
145 |
146 |   created by cyby-draw 1.0
147 |
148 |     8  8     0                      V2000
149 |      -5.8125    2.0625    0.0000   C
150 |      -3.6476    4.5625    0.0000   C
151 |      -4.7299    3.9375    0.0000   C
152 |      -4.7299    2.6875    0.0000   C
153 |      -3.6476    2.0625    0.0000   C
154 |      -2.5650    2.6875    0.0000   C
155 |      -2.5650    3.9375    0.0000   C
156 |      -5.8125    0.8125    0.0000   O
157 |     1  4  1  0
158 |     1  8  2  0
159 |     2  3  1  0
160 |     2  7  2  0
161 |     3  4  2  0
162 |     4  5  1  0
163 |     5  6  2  0
164 |     6  7  1  0
165 |   M  END
166 |   """
167 |