Skip to content

Instantly share code, notes, and snippets.

@newmen
Last active August 29, 2015 14:08
Show Gist options
  • Save newmen/fbe37e0ff90d7245b92e to your computer and use it in GitHub Desktop.
Save newmen/fbe37e0ff90d7245b92e to your computer and use it in GitHub Desktop.
Чтобы переосознать процесс, можно попробовать его написать на другом языке
; bridge
(defn find [anchor]
(if (is anchor 3)
(if (havent anchor BRIDGE 3)
(def nbrs (cross_110 (crystal anchor) anchor))
(if (and (all nbrs) (is nbrs[0] 6) (is nbrs[1] 6)
(has_bond anchor nbrs[0]) (has_bond anchor nbrs[1]))
(def atoms [anchor nbrs[0] nbrs[1]])
(create BRIDGE atoms)))))
; -------------------------------------------------------------------------------------
; bridge(ct: *, ct: i)
(defn find [parent]
(def anchor (atom parent 0))
(if (is anchor 28)
(if (havent anchor BRIDGE_CTSI 28)
(create BRIDGE_CTSI parent))))
; bridge(cr: *, ct: i, cl: i)
(defn find [parent]
(def anchors [(atom parent 0) (atom parent 1) (atom parent 2)])
(if (and (is anchors[0] 0) (is anchors[1] 5) (is anchors[2] 4))
(if (or (havent anchors[0] BRIDGE_CRS_CTI_CLI 0)
(havent anchors[1] BRIDGE_CRS_CTI_CLI 5)
(havent anchors[2] BRIDGE_CRS_CTI_CLI 4))
(create BRIDGE_CRS_CTI_CLI parent))))
; methyl_on_bridge
(defn find [parent]
(def anchor (atom parent 0))
(if (is anchor 9)
(if (havent anchor METHYL_ON_BRIDGE 9)
(def amorph1 (amorph_neighbour anchor))
(if (is amorph1 14)
(create METHYL_ON_BRIDGE amorph1 parent)))))
; -------------------------------------------------------------------------------------
; bridge(cr: i)
(defn find [parent]
(each_symmetry parent (fn [specie]
(def anchor (atom specie 1))
(if (is anchor 4)
(if (havent anchor BRIDGE_CRI 4)
(create BRIDGE_CRI specie))))))
; -------------------------------------------------------------------------------------
; dimer
(defn find [anchor]
(if (is anchor 22)
(if (havent anchor DIMER 22)
(each_neighbour anchor front_100 (fn [neighbour]
(if (and (is neighbour 22) (has_bond anchor neighbour))
(def parents [(spec_by_role anchor BRIDGE 3) (spec_by_role neighbour BRIDGE 3)])
(create DIMER parents)))))))
; methyl_on_dimer
(defn find [anchor]
(if (is anchor 23)
(if (havent anchor METHYL_ON_DIMER 23)
(each_neighbour anchor front_100 (fn [neighbour]
(if (and (is neighbour 22) (has_bond anchor neighbour))
(def parents [(spec_by_role anchor METHYL_ON_BRIDGE 9) (spec_by_role neighbour BRIDGE 3)])
(create METHYL_ON_DIMER parents)))))
(if (is anchor 22)
(if (havent anchor METHYL_ON_DIMER 22)
(each_neighbour anchor front_100 (fn [neighbour]
(if (and (is neighbour 23) (has_bond anchor neighbour))
(def parents [(spec_by_role neighbour METHYL_ON_BRIDGE 9) (spec_by_role anchor BRIDGE 3)])
(create METHYL_ON_DIMER parents))))))))
; -------------------------------------------------------------------------------------
; cross_bridge_on_bridges
(defn find [anchor]
(if (is anchor 10)
(if (havent anchor CROSS_BRIDGE_ON_BRIDGES 10)
(def species (specs_by_role anchor METHYL_ON_BRIDGE 2 14))
(if (all species)
(def atoms [(atom species[0] 1) (atom species[1] 1)])
(each_neighbour atoms[0] cross_100 (fn [neighbour])
(if (and (== atoms[1] neighbour) (not (has_bond atoms[0], neighbour)))
(def parents [species[0] species[1]])
(create CROSS_BRIDGE_ON_BRIDGES parents)))))))
; three_bridges
(defn find [anchor]
(if (is anchor 24)
(if (havent anchor THREE_BRIDGES 24)
(each_spec_by_role anchor BRIDGE 6 (fn [target1]
(each_symmetry target1 (fn [specie1]
(if (== (atom specie1 1) anchor)
(each_spec_by_role anchor BRIDGE 6 (fn [target2]
(if (== target2 target1)
(each_symmetry target2 (fn [specie2]
(if (== (atom specie2 2) anchor)
(def atom1 (atom specie1 2))
(def specie3 (specs_by_role atom1 BRIDGE 3))
(def parents [specie1 specie2 specie3])
(create THREE_BRIDGES parents)))))))))))))))
; bridge_with_dimer
(defn find [anchor]
(if (is anchor 32)
(if (havent anchor BRIDGE_WITH_DIMER 32)
(each_spec_by_role anchor DIMER 22 (fn [target1]
(each_symmetry target1 (fn [specie1]
(if (== (atom specie1 3) anchor)
(each_spec_by_role anchor BRIDGE 6 (fn [target2]
(each_symmetry target2 (fn [specie2]
(if (== (atom specie2 1) anchor)
(def atom1 (atom specie2 2))
(def specie3 (specs_by_role atom1 BRIDGE 3))
(def parents [specie1 specie2 specie3])
(create THREE_BRIDGES parents))))))))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment