index xrefs 2006/08/08 17:41:29

ChemoJunMolFileWriter

ChemoJun050 (2006/08/08) Copyright 2002-2006 National Institute of Informatics, Research Organization of Information and Systems.

category:

inheritance:

instance variables:

class instance variables:

class variables:

pool variables:

instance methods:

  1. atomList [accessing] xrefs
    	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
  2. connectionList [accessing] xrefs
    	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
  3. defaultSymbolOfSerialNumber [defaults] xrefs
    	^#serialNumber
  4. indexOf: theAtomObject [accessing] xrefs
     
    	self atomList with: (1 to: self atomList size)
    		do: [:atomObject :anIndex | atomObject = theAtomObject ifTrue: [^anIndex]].
    	^0
  5. initialize [initialize-release] xrefs
    	super initialize.
    	moleculeObject := nil.
    	atomList := nil.
    	connectionList := nil
  6. moleculeObject [accessing] xrefs
    	^moleculeObject
  7. moleculeObject: aMolecule [accessing] xrefs
     
    	moleculeObject := aMolecule.
    	atomList := nil.
    	connectionList := nil
  8. numberOfAtoms [accessing] xrefs
    	^self moleculeObject ifNil: [0] ifNotNil: [:it | it numberOfAtoms]
  9. numberOfConnections [accessing] xrefs
    	^self moleculeObject ifNil: [0] ifNotNil: [:it | it numberOfConnections]
  10. writeAtomBlockOn: aStream [writing] xrefs
     
    	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]
  11. writeBondBlockOn: aStream [writing] xrefs
     
    	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]
  12. writeCountsLineOn: aStream [writing] xrefs
     
    	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
  13. writeHeaderBlockOn: aStream [writing] xrefs
     
    	| 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
  14. writeOn: aStream [writing] xrefs
     
    	self writeHeaderBlockOn: aStream.
    	self writeCountsLineOn: aStream.
    	self writeAtomBlockOn: aStream.
    	self writeBondBlockOn: aStream.
    	self writePropertiesBlockOn: aStream
  15. writePropertiesBlockOn: aStream [writing] xrefs
     
    	aStream nextPutAll: 'M  END'.
    	aStream cr

class methods:

  1. copyright [copyright] xrefs
    	^'ChemoJun050 (2006/08/08) Copyright 2002-2006 National Institute of Informatics, Research Organization of Information and Systems.'
  2. example1 [examples] xrefs
    	"ChemoJunMolFileWriter example1."
    
    	| aReader moleculeObject aWriter |
    	aReader := ChemoJunMolFileReader request.
    	aReader isNil ifTrue: [^nil].
    	moleculeObject := ChemoJunMoleculeObject fromReader: aReader.
    	aWriter := ChemoJunMolFileWriter 
    				requestInitialFileName: moleculeObject baseName , '_' 
    						, JunSystem defaultBaseName , moleculeObject extension.
    	aWriter isNil ifTrue: [^nil].
    	aWriter moleculeObject: moleculeObject.
    	aWriter write.
    	^aWriter
  3. moleculeObject: moleculeObject [instance creation] xrefs
     
    	^(self new)
    		moleculeObject: moleculeObject;
    		yourself
  4. system [copyright] xrefs
    	^'ChemoJun'
  5. version [copyright] xrefs
    	^'050'

index xrefs