Esempio n. 1
0
    def readFastaChunks(self):
        numChunks = self.scale or 1
        if self.seq is not None and len(self.seq) >= (
            (numChunks - 1) *
                chunkSize) + 1:  #at least on character in the last chunk
            return
        self.seq = ''
        self.length = len(self.seq)
        partialSequences = []
        for index, chunkStart in enumerate(
                range(self.start, self.start + numChunks * chunkSize,
                      chunkSize)):
            tempState = self.copy()
            tempState.start = chunkStart

            chunk = readFile(tempState)
            if chunk is None:
                break
            else:
                partialSequences.append(chunk)

        self.seq = "".join(partialSequences)

        if self.scale >= 10:
            print "Done reading files"
        self.length = len(self.seq)
Esempio n. 2
0
    def readAndAppendNextChunk(self, addPadding=False):
        assert StorageRequestHandler.GetFastaFilePath(self.specimen, self.chromosome,
                                                      1) is not None, "Specimen and Chromosome is not in the database"
        startBackup = self.start
        if not self.seq:
            self.seq = '' #ensure that seq is at least a string object
        self.start = self.start + len(self.seq) # jump to the end of the current sequence  (+ chunkSize)

        #print "Requesting",self.specimen, self.chromosome, self.start
        sequence = readFile(self)# see if there's a file that begins where you end, this will stop on a partial file
        if sequence is not None:
            self.seq = self.seq + sequence #append two sequences together
        elif addPadding:
            self.seq = self.seq + ('N' * chunkSize)
        self.start = startBackup
        self.length = len(self.seq)
        return self
Esempio n. 3
0
 def readFastaChunks(self):
     numChunks = self.scale or 1
     if self.seq is not None and len(self.seq) >= (
             (numChunks - 1) * chunkSize) + 1: #at least on character in the last chunk
         return
     self.seq = ''
     self.length = len(self.seq)
     partialSequences = [None] * numChunks
     for index, chunkStart in enumerate(range(self.start, self.start + numChunks * chunkSize, chunkSize)):
         tempState = self.copy()
         tempState.start = chunkStart
         partialSequences[index] = readFile(tempState)
         if partialSequences[index] is None:
             partialSequences[index] = ''
     self.seq = ''.join(partialSequences)
     if self.scale >= 10:
         print "Done reading files"
     self.length = len(self.seq)
Esempio n. 4
0
    def readAndAppendNextChunk(self, addPadding=False):
        assert StorageRequestHandler.GetFastaFilePath(
            self.specimen, self.chromosome,
            1) is not None, "Specimen and Chromosome is not in the database"
        startBackup = self.start
        if not self.seq:
            self.seq = ''  #ensure that seq is at least a string object
        self.start = self.start + len(
            self.seq)  # jump to the end of the current sequence  (+ chunkSize)

        #print "Requesting",self.specimen, self.chromosome, self.start
        sequence = readFile(
            self
        )  # see if there's a file that begins where you end, this will stop on a partial file
        if sequence is not None:
            self.seq = self.seq + sequence  #append two sequences together
        elif addPadding:
            self.seq = self.seq + ('N' * chunkSize)
        self.start = startBackup
        self.length = len(self.seq)
        return self