Esempio n. 1
0
    def initializePacketInfo(self, paraInfo):

        #for split runs 
        if paraInfo == ['splitRun', 'splitRun']:
            self._splitRunFlag = True
            paraInfo = [None, None] # now treat paraInfo as if there was nothing...
       
        #for normal runs
        if paraInfo != [None, None]: 
            paraInfo[0] = int(paraInfo[0])
            paraInfo[1] = int(paraInfo[1])
            self._packetInfo = cgFile.getPacketInfo(self._dataFileName, paraInfo[1])[paraInfo[0] - 1]
Esempio n. 2
0
    def load(self, attNames, paraInfo=[None, None]):
        '''paraInfo is [runNumber, numberOfRuns]'''

        #t = bioLibCG.cgTimer()
        #stage_cumTime = dict( (x, 0.0) for x in (''))
        #t.start()

        if paraInfo == ['splitRun', 'splitRun']:
            self._splitRunFlag = True
            paraInfo = [None,
                        None]  # now treat paraInfo as if there was nothing...

        if paraInfo != [None, None]:
            paraInfo[0] = int(paraInfo[0])
            paraInfo[1] = int(paraInfo[1])
            self._packetInfo = cgFile.getPacketInfo(
                self._dataFileName, paraInfo[1])[paraInfo[0] - 1]

    #if running parallel or specific range, mark range info
        self._selectedAttNames = attNames

        #get casting and column info
        self.loadTranscriptionInfo(attNames)

        #init master dictionaries
        self.initializeMasterDict()

        #get number of slots
        numSlots = self.getNumberOfSlots()

        #open file and binary skip to correct line if packet
        dataFile = cgFile.cgFile(self._dataFileName)
        if self._packetInfo:
            dataFile.seekToLineStart(self._packetInfo[0])

        #print 'before loop', t.split()
        #transcribe values
        currentID = 0
        for line in dataFile.file:

            ls = line.strip().split('\t')

            #get ID
            if self.hasIDs:
                id = int(ls[0])  #id is always first slot
            else:
                id = currentID
                currentID += 1

        #stop if at end of range
            if self._packetInfo:
                if id == self._packetInfo[1]:
                    break

            #transcribe
            #Note lots of copying is SLOW (10x)
            #only copy if list?
            for attName in attNames:
                colPosition = self._attName_columnPosition[attName]
                if colPosition < numSlots:
                    if ls[colPosition] != '.':
                        self._attName_id_value[attName][
                            id] = self._attName_casteFromFxn[attName](
                                ls[colPosition])
                    else:
                        self._attName_id_value[attName][id] = copy(
                            self._attName_defaultValue[attName])
                else:
                    self._attName_id_value[attName][id] = copy(
                        self._attName_defaultValue[attName])
        #print 'after loop', t.split()
        dataFile.file.close()

        #bind attribute names to dictionaries
        self.bindAttributes(attNames)

        #bind id attribute to first attribute, they all have the same ids...
        self.linkIDsToColumn()
Esempio n. 3
0
	def load(self, attNames, paraInfo = [None, None]):
                '''paraInfo is [runNumber, numberOfRuns]'''
       
                #t = bioLibCG.cgTimer()
                #stage_cumTime = dict( (x, 0.0) for x in (''))
                #t.start()

                if paraInfo == ['splitRun', 'splitRun']:
                        self._splitRunFlag = True
                        paraInfo = [None, None] # now treat paraInfo as if there was nothing...
                
                if paraInfo != [None, None]: 
                        paraInfo[0] = int(paraInfo[0])
                        paraInfo[1] = int(paraInfo[1])
                        self._packetInfo = cgFile.getPacketInfo(self._dataFileName, paraInfo[1])[paraInfo[0] - 1]
                        
		#if running parallel or specific range, mark range info
		self._selectedAttNames = attNames		
		

		#get casting and column info
		self.loadTranscriptionInfo(attNames)

                #init master dictionaries
                self.initializeMasterDict()

		#get number of slots
                numSlots = self.getNumberOfSlots()
		
                #open file and binary skip to correct line if packet            
                dataFile = cgFile.cgFile(self._dataFileName)
                if self._packetInfo:
                        dataFile.seekToLineStart(self._packetInfo[0])

                #print 'before loop', t.split()
                #transcribe values
                currentID = 0
                for line in dataFile.file:

			ls = line.strip().split('\t')

                        #get ID
                        if self.hasIDs:
                            id = int(ls[0]) #id is always first slot
                        else:
                            id = currentID
                            currentID += 1
		
                        #stop if at end of range
                        if self._packetInfo:
                                if id == self._packetInfo[1]:
                                        break

			#transcribe
                        #Note lots of copying is SLOW (10x)
                        #only copy if list?
			for attName in attNames:
                                colPosition = self._attName_columnPosition[attName]
				if colPosition < numSlots:
                                        if ls[colPosition] != '.':
                                                self._attName_id_value[attName][id] = self._attName_casteFromFxn[attName](ls[colPosition])
                                        else:
					        self._attName_id_value[attName][id] = copy(self._attName_defaultValue[attName])
				else:
					self._attName_id_value[attName][id] = copy(self._attName_defaultValue[attName])
                #print 'after loop', t.split()
                dataFile.file.close()
                
		#bind attribute names to dictionaries
                self.bindAttributes(attNames)

                #bind id attribute to first attribute, they all have the same ids...
                self.linkIDsToColumn()