0 | module Test.Text.Molfile.Generators
2 | import public Test.Chem.Generators
3 | import public Test.Data.Graph.Generators
4 | import public Text.Molfile
11 | molLine : Gen MolLine
12 | molLine = MkMolLine <$> string (linear 0 80) printableAscii
15 | molVersion : Gen MolVersion
16 | molVersion = element [V2000, V3000]
19 | chiralFlag : Gen ChiralFlag
20 | chiralFlag = element [NonChiral, Chiral]
23 | stereoParity : Gen StereoParity
24 | stereoParity = element [NoStereo, OddStereo, EvenStereo, AnyStereo]
27 | stereoCareBox : Gen StereoCareBox
28 | stereoCareBox = element [IgnoreStereo, MatchStereo]
31 | valence : Gen Valence
32 | valence = fromMaybe 0 . refineValence <$> bits8 (linear 0 15)
35 | h0Designator : Gen H0Designator
36 | h0Designator = element [H0NotSpecified, NoHAllowed]
39 | hydrogenCount : Gen HydrogenCount
40 | hydrogenCount = fromMaybe 0 . refineHydrogenCount <$> bits8 (linear 0 5)
43 | coordinate : Gen Coordinate
45 | fromMaybe 0 . refineCoordinate <$>
46 | integer (exponentialFrom 0 (-
9999_9999) 99999_9999)
49 | coords : Gen (Vect 3 Coordinate)
50 | coords = vect 3 coordinate
56 | atom : Gen (Maybe AtomGroup) -> Gen MolAtom
58 | [| MkAtom isotope charge coords radical u u u nr |]
61 | simpleAtom : Gen MolAtom
63 | [| MkAtom (map cast elem) (pure 0) coords (pure NoRadical) u u u (pure Nothing) |]
66 | bondStereo : Gen BondStereo
67 | bondStereo = element [NoBondStereo,Up,Either,Down]
70 | bondTopo : Gen BondTopo
71 | bondTopo = element [AnyTopology,Ring,Chain]
75 | bond = [| MkBond bool bondOrder bondStereo |]
78 | bondEdge : Gen (Edge 999 MolBond)
79 | bondEdge = edge bond
82 | lbl = [| go alpha (string (linear 1 10) alphaNum) |]
84 | go : Char -> String -> String
85 | go = (++) . singleton
87 | groups : Gen (List AtomGroup)
88 | groups = withIndex [<] 1 <$> list (linear 0 4) lbl
90 | withIndex : SnocList AtomGroup -> Nat -> List String -> List AtomGroup
91 | withIndex sa n [] = sa <>> []
92 | withIndex sa n (l::ls) = withIndex (sa :< G n l) (S n) ls
94 | group : List AtomGroup -> Gen (Maybe AtomGroup)
95 | group [] = pure Nothing
96 | group (h::t) = maybe (element $
h :: Vect.fromList t)
99 | sdHeader : Gen SDHeader
100 | sdHeader = fromMaybe "" . refineSDHeader <$> string (linear 0 70) alphaNum
103 | sdValue : Gen SDValue
104 | sdValue = fromMaybe "" . refineSDValue <$> string (linear 0 300) printableAscii
107 | structureData : Gen StructureData
108 | structureData = [| SD sdHeader sdValue |]
111 | molFileGS : List AtomGroup -> Gen Molfile
117 | (lgraph (linear 1 30) (linear 0 30) bond (atom $
group gs))
122 | molFile : Gen Molfile
123 | molFile = groups >>= molFileGS
126 | sdFileGS : List AtomGroup -> Gen Molfile
132 | (lgraph (linear 1 30) (linear 0 30) bond (atom $
group gs))
133 | (list (linear 0 5) structureData)
137 | sdFile : Gen Molfile
138 | sdFile = groups >>= sdFileGS