-
atomList [accessing]
atomList isNil
ifTrue:
[| aCollection |
aCollection := SortedCollection new: self numberOfAtoms.
self moleculeObject atomObjectsDo:
[:atomObject |
aCollection
add: (atomObject perform: self defaultSymbolOfSerialNumber) -> atomObject].
atomList := aCollection asArray collect: [:assoc | assoc value]].
^atomList
-
connectionList [accessing]
connectionList isNil
ifTrue:
[| aCollection atomObject |
aCollection := SortedCollection new: self numberOfConnections.
self moleculeObject atomConnections do:
[:atomConnection |
atomObject := atomConnection fromAtom.
aCollection
add: (atomObject attributeTable at: self defaultSymbolOfSerialNumber)
-> atomConnection].
connectionList := aCollection asArray collect: [:assoc | assoc value]].
^connectionList
-
defaultSymbolOfSerialNumber [defaults]
^#serialNumber
-
indexOf: theAtomObject [accessing]
self atomList with: (1 to: self atomList size)
do: [:atomObject :anIndex | atomObject = theAtomObject ifTrue: [^anIndex]].
^0
-
initialize [initialize-release]
super initialize.
moleculeObject := nil.
atomList := nil.
connectionList := nil
-
moleculeObject [accessing]
^moleculeObject
-
moleculeObject: aMolecule [accessing]
moleculeObject := aMolecule.
atomList := nil.
connectionList := nil
-
numberOfAtoms [accessing]
^self moleculeObject ifNil: [0] ifNotNil: [:it | it numberOfAtoms]
-
numberOfConnections [accessing]
^self moleculeObject ifNil: [0] ifNotNil: [:it | it numberOfConnections]
-
writeAtomBlockOn: aStream [writing]
self atomList do:
[:atomObject |
aStream nextPutAll: (self format: 'f10.4' value: atomObject atomicPoint x).
aStream nextPutAll: (self format: 'f10.4' value: atomObject atomicPoint y).
aStream nextPutAll: (self format: 'f10.4' value: atomObject atomicPoint z).
aStream nextPutAll: (self format: 'x1' value: nil).
aStream nextPutAll: (self format: 'a3' value: atomObject atomicSymbol).
aStream nextPutAll: (self format: 'i2' value: 0).
11 timesRepeat: [aStream nextPutAll: (self format: 'i3' value: 0)].
aStream cr]
-
writeBondBlockOn: aStream [writing]
self connectionList do:
[:atomConnection |
aStream nextPutAll: (self format: 'i3'
value: (self indexOf: atomConnection fromAtom)).
aStream
nextPutAll: (self format: 'i3' value: (self indexOf: atomConnection toAtom)).
aStream nextPutAll: (self format: 'i3' value: atomConnection bondType).
aStream nextPutAll: (self format: 'i3' value: atomConnection stereoType).
3 timesRepeat: [aStream nextPutAll: (self format: 'i3' value: 0)].
aStream cr]
-
writeCountsLineOn: aStream [writing]
aStream nextPutAll: (self format: 'i3' value: self numberOfAtoms).
aStream nextPutAll: (self format: 'i3' value: self numberOfConnections).
8 timesRepeat: [aStream nextPutAll: (self format: 'i3' value: 0)].
aStream nextPutAll: (self format: 'i3' value: 1).
aStream nextPutAll: (self format: 'x1' value: nil).
aStream nextPutAll: (self format: 'a5' value: 'V2000').
aStream cr
-
writeHeaderBlockOn: aStream [writing]
| firstBlock secondBlock thirdBlock |
firstBlock :=
[aStream nextPutAll: ' - ' , self baseName , ' - '.
aStream cr].
secondBlock :=
[| aString |
aStream nextPutAll: (self format: 'a2' value: ' ').
aStream nextPutAll: (self format: 'a8' value: 'ChemoJun').
aString := Date today monthIndex printString.
2 - aString size timesRepeat: [aString := '0' , aString].
aStream nextPutAll: (self format: 'a2' value: aString).
aString := Date today dayOfMonth printString.
2 - aString size timesRepeat: [aString := '0' , aString].
aStream nextPutAll: (self format: 'a2' value: aString).
aString := Date today year printString.
aString := aString copyFrom: aString size - 1 to: aString size.
aStream nextPutAll: (self format: 'a2' value: aString).
aString := Time now hours printString.
2 - aString size timesRepeat: [aString := '0' , aString].
aStream nextPutAll: (self format: 'a2' value: aString).
aString := Time now minutes printString.
2 - aString size timesRepeat: [aString := '0' , aString].
aStream nextPutAll: (self format: 'a2' value: aString).
self moleculeObject is2d
ifTrue: [aStream nextPutAll: (self format: 'a2' value: '2D')]
ifFalse: [aStream nextPutAll: (self format: 'a2' value: '3D')].
aStream nextPutAll: (self format: 'i2' value: 1).
aStream nextPutAll: (self format: 'f10.5' value: 1).
aStream nextPutAll: (self format: 'f12.5' value: 0).
aStream nextPutAll: (self format: 'i6' value: 0).
aStream cr].
thirdBlock :=
[aStream
space;
space.
aStream nextPutAll: 'This molfile was created by '.
aStream nextPutAll: ChemoJunSystem system.
aStream nextPutAll: ChemoJunSystem version.
aStream nextPutAll: ' at '.
aStream nextPutAll: JunCalendarModel stringFromDateAndTime.
aStream cr].
firstBlock value.
secondBlock value.
thirdBlock value
-
writeOn: aStream [writing]
self writeHeaderBlockOn: aStream.
self writeCountsLineOn: aStream.
self writeAtomBlockOn: aStream.
self writeBondBlockOn: aStream.
self writePropertiesBlockOn: aStream
-
writePropertiesBlockOn: aStream [writing]
aStream nextPutAll: 'M END'.
aStream cr