Пример #1
0
 def setSequence(self, value, forced=False):
     if forced:
         self.sequence = value
     else:
         if self.readDirection == FastqSequence.READ_DIRECTION_LEFT_TO_RIGHT:
             self.sequence = value
         else:
             self.sequence = DnaUtils.complementAndReverseDnaSequence(value)
     self.logger.debug("self.sequence : " + self.sequence)
Пример #2
0
 def setSequence(self, value, forced=False):
     if forced:
         self.sequence = value
     else:
         if self.readDirection == FastqSequence.READ_DIRECTION_LEFT_TO_RIGHT:
             self.sequence = value
         else:
             self.sequence = DnaUtils.complementAndReverseDnaSequence(value)
     self.logger.debug("self.sequence : " + self.sequence)
Пример #3
0
def cutFusionAndMerge(headerF, dataF, headerR, dataR, wellThresholds, log,
                      outputFile):
    logger.debug("[cutFusionAndMerge] " + headerF + ", " + headerR + ", " +
                 str(wellThresholds))

    forward = 0
    reverse = 1

    dataF = dataF[0:wellThresholds[forward]]
    #a = "ATAACGCTGTTATCCCTGCGGTAACTTGTTCTTTTGATCACTGTAAGTGGATCACACCTTCATTTTTATGATTTAAGAAAAACAATTCTTTTATTTTAGGTTAATATAACCATATAGTAGCGGAGGATTTTCTTTCTCCGGGATTGCCCCAATCAAAGCTTGTTTCAATTTGCCATGCTCTAGGCCTACTATTTCTATTATATTAGTTAGGGCTAATAGTAAATAACAATTAAAATTCAACTACAGCTCG"
    #dataR = DnaUtils.complementAndReverseDnaSequence(dataR[0:wellThresholds[reverse]])
    cdataR = DnaUtils.complementAndReverseDnaSequence(dataR)
    cdataR = cdataR[:wellThresholds[reverse]]
    #cdataR = DnaUtils.complementAndReverseDnaSequence(cdataR)
    #data   = merge(dataF, cdataR)
    # print(dataF)
    #print(DnaUtils.complementAndReverseDnaSequence(cdataR))

    fastqSequenceForward = FastqSequence.createFasqSequenceHeader(headerF)
    fastqSequenceForward.setSequence(dataF, True)
    fastqSequenceForward.quality = None

    fastqSequenceReverse = FastqSequence.createFasqSequenceHeader(headerR)
    fastqSequenceReverse.setSequence(cdataR)
    fastqSequenceReverse.quality = None

    newFastQ = FastqSequence.matchFastqSequence(fastqSequenceForward,
                                                fastqSequenceReverse)

    logging.debug(newFastQ.getLineHeader() + "\t" + str(newFastQ.typeFusion))
    if newFastQ.typeFusion == newFastQ.TYPE_FUSION_OK:
        log.write("Merge " + fastqSequenceForward.getLineHeader() + " with " +
                  fastqSequenceReverse.getLineHeader() + "\n")
    elif newFastQ.typeFusion == newFastQ.TYPE_FUSION_NO_MATCH:
        log.write("Forced merge " + fastqSequenceForward.getLineHeader() +
                  " with " + fastqSequenceReverse.getLineHeader() + "\n")
    elif newFastQ.typeFusion == newFastQ.TYPE_FUSION_PARTIAL:
        log.write("Partial merge " + fastqSequenceForward.getLineHeader() +
                  " with " + fastqSequenceReverse.getLineHeader() + "\n")
    else:
        log.write("Can't merge " + fastqSequenceForward.getLineHeader() +
                  " with " + fastqSequenceReverse.getLineHeader() + "\n")

    #outputFile.write(">" + newFastQ.getLineHeader() + "\n")
    #outputFile.write(newFastQ.sequence + "\n")
    #sys.exit(1)
    return newFastQ
Пример #4
0
def readSingleFastQFile(fileName, threshold, logFileName, mapOligos,
                        outputDir):
    f = open(fileName, "r")
    log = open(logFileName, "w")

    lineNumber = 0
    lastHeaderLineNumber = 0
    lastSeparatorLineNumber = 0
    sequences = []
    fastqSequence = None

    for line in f:
        line = line[:-1]
        if line[0] == "@" and lastSeparatorLineNumber != lineNumber - 1:
            if fastqSequence != None:
                #tryToFusion(fastqSequence, reverseFileName, threshold, log, seqOutput)
                logger.debug("before threshold " + fastqSequence.sequence)
                fastqSequence.applyDrasticThreshold(threshold)
                logger.debug("after threshold " + fastqSequence.sequence)
                logger.debug("after threshold " +
                             DnaUtils.complementAndReverseDnaSequence(
                                 fastqSequence.sequence))
                DnaUtils.splitMarker1(mapOligos, outputDir, fastqSequence,
                                      fileName)

            fastqSequence = FastqSequence.readFasqSequenceHeader(line)
            lastHeaderLineNumber = lineNumber

            logging.debug(line)
        elif lastHeaderLineNumber == lineNumber - 1:
            logging.debug("seq in file : " + line)
            fastqSequence.setSequence(line)
        elif line[0] == "+":
            lastSeparatorLineNumber = lineNumber
        elif lastSeparatorLineNumber == lineNumber - 1:
            fastqSequence.setQuality(line)

        lineNumber += 1
    #tryToFusion(fastqSequence, reverseFileName, threshold, log, seqOutput)
    fastqSequence.applyDrasticThreshold(threshold)
    DnaUtils.splitMarker1(mapOligos, outputDir, fastqSequence, fileName)
    f.close()
    log.close()
Пример #5
0
Файл: test.py Проект: chaby/dana
def cutFusionAndMerge(headerF, dataF, headerR, dataR, wellThresholds, log, outputFile):
    logger.debug("[cutFusionAndMerge] " + headerF + ", " + headerR + ", " + str(wellThresholds))
    
    forward  = 0
    reverse  = 1
    
    dataF = dataF[0:wellThresholds[forward]]
    #a = "ATAACGCTGTTATCCCTGCGGTAACTTGTTCTTTTGATCACTGTAAGTGGATCACACCTTCATTTTTATGATTTAAGAAAAACAATTCTTTTATTTTAGGTTAATATAACCATATAGTAGCGGAGGATTTTCTTTCTCCGGGATTGCCCCAATCAAAGCTTGTTTCAATTTGCCATGCTCTAGGCCTACTATTTCTATTATATTAGTTAGGGCTAATAGTAAATAACAATTAAAATTCAACTACAGCTCG"
    #dataR = DnaUtils.complementAndReverseDnaSequence(dataR[0:wellThresholds[reverse]])
    cdataR = DnaUtils.complementAndReverseDnaSequence(dataR)
    cdataR = cdataR[:wellThresholds[reverse]]
    #cdataR = DnaUtils.complementAndReverseDnaSequence(cdataR)
    #data   = merge(dataF, cdataR)
    # print(dataF)
    #print(DnaUtils.complementAndReverseDnaSequence(cdataR))
    
    fastqSequenceForward = FastqSequence.createFasqSequenceHeader(headerF)
    fastqSequenceForward.setSequence(dataF, True)
    fastqSequenceForward.quality = None
    
    fastqSequenceReverse = FastqSequence.createFasqSequenceHeader(headerR)
    fastqSequenceReverse.setSequence(cdataR)
    fastqSequenceReverse.quality = None
    
    newFastQ = FastqSequence.matchFastqSequence(fastqSequenceForward, fastqSequenceReverse)
    
    logging.debug(newFastQ.getLineHeader() + "\t" + str(newFastQ.typeFusion))
    if newFastQ.typeFusion == newFastQ.TYPE_FUSION_OK:
        log.write("Merge " + fastqSequenceForward.getLineHeader() + " with " + fastqSequenceReverse.getLineHeader() + "\n")
    elif newFastQ.typeFusion == newFastQ.TYPE_FUSION_NO_MATCH:
        log.write("Forced merge " + fastqSequenceForward.getLineHeader() + " with " + fastqSequenceReverse.getLineHeader() + "\n")
    elif newFastQ.typeFusion == newFastQ.TYPE_FUSION_PARTIAL:
        log.write("Partial merge " + fastqSequenceForward.getLineHeader() + " with " + fastqSequenceReverse.getLineHeader() + "\n")
    else:
        log.write("Can't merge " + fastqSequenceForward.getLineHeader() + " with " + fastqSequenceReverse.getLineHeader() + "\n")
        
    #outputFile.write(">" + newFastQ.getLineHeader() + "\n")
    #outputFile.write(newFastQ.sequence + "\n")
    #sys.exit(1)
    return newFastQ
Пример #6
0
Файл: test.py Проект: chaby/dana
def readSingleFastQFile(fileName, threshold, logFileName, mapOligos, outputDir):
    f = open(fileName, "r")
    log = open(logFileName, "w")
    
    lineNumber = 0
    lastHeaderLineNumber    = 0
    lastSeparatorLineNumber = 0
    sequences  = []
    fastqSequence = None
    
    for line in f:
        line = line[:-1]
        if line[0] == "@" and lastSeparatorLineNumber != lineNumber - 1:
            if fastqSequence != None:
                #tryToFusion(fastqSequence, reverseFileName, threshold, log, seqOutput)
                logger.debug("before threshold " + fastqSequence.sequence)
                fastqSequence.applyDrasticThreshold(threshold)
                logger.debug("after threshold " + fastqSequence.sequence)
                logger.debug("after threshold " + DnaUtils.complementAndReverseDnaSequence(fastqSequence.sequence))
                DnaUtils.splitMarker1(mapOligos, outputDir, fastqSequence, fileName)
                
            fastqSequence = FastqSequence.readFasqSequenceHeader(line)
            lastHeaderLineNumber = lineNumber
            
            logging.debug(line)
        elif  lastHeaderLineNumber == lineNumber - 1:
            logging.debug("seq in file : " + line)
            fastqSequence.setSequence(line)
        elif line[0] == "+":
            lastSeparatorLineNumber = lineNumber
        elif lastSeparatorLineNumber == lineNumber - 1:
            fastqSequence.setQuality(line)
            
        lineNumber += 1
    #tryToFusion(fastqSequence, reverseFileName, threshold, log, seqOutput)
    fastqSequence.applyDrasticThreshold(threshold)
    DnaUtils.splitMarker1(mapOligos, outputDir, fastqSequence, fileName)
    f.close()
    log.close()
Пример #7
0
 def setSequence(self, value):
     if self.readDirection == FastqSequence.READ_DIRECTION_LEFT_TO_RIGHT:
         self.sequence = value
     else:
         self.sequence = DnaUtils.complementAndReverseDnaSequence(value)