def probeTmOpt_var(self, seq1): """ :param self: :param seq1: :return: """ vargibbs_res = str(self.inputFile).split('.')[0] vargibbs_run = [ self.vargibbs, f'-o={vargibbs_res}', f'-par={self.par}', '-calc=prediction', '-v=0', '-seqsalt={}'.format(1000), '\"-seq=r({})\"'.format(seq1.replace('T', 'U')), '-cseq={}'.format(complement(seq1)), f'-ct={self.ct}', f'-targetsalt={self.sal}', f'-saltscheme={self.saltscheme}' ] run_func = ' '.join(vargibbs_run) proc = subprocess.Popen(run_func, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) result, err = proc.communicate() try: tm_val = float( open(vargibbs_res + '.ver').read().split('\n')[1].split(' ')[1]) except: LOG.warning(err) return False tm_val = mt.chem_correction(tm_val, fmd=self.form) return tm_val
def probeTm(seq1, saltConc, formConc): """Calculates the melting temperature of a given sequence under the specified salt and formamide conditions.""" tmval = float(('%0.2f' % mt.Tm_NN(seq1, Na=saltConc))) fcorrected = ('%0.2f' % mt.chem_correction(tmval, fmd=formConc)) return fcorrected
def BedprobeTm(self, seq7): """Tm calculation function for use with .bed output.""" bedTmVal = float(('%0.2f' % mt.Tm_NN(seq7, Na=self.sal, dnac1=self.conc1, dnac2=self.conc2))) bed_fcorrected = ('%0.2f' % mt.chem_correction(bedTmVal, fmd=self.form)) return bed_fcorrected
def __probeTm(self): """ Calculates the melting temperature of a given sequence under the specified salt and formamide conditions. """ tmval = float(mt.Tm_NN(self.seq, Na=self.sal)) Tm = ('%0.2f' % mt.chem_correction(tmval, fmd=int(self.form))) return Tm
def probeTmOpt(self, seq1, ind, i, j): """Calculate the melting temperature more efficiently, by not recomputing stack sums for every possible oligo. This method is based on the Tm_NN function in the Bio.SeqUtils.MeltingTemp library. Logic for mismatches and other unnecessary parts have been stripped. This algorithm uses a sliding window strategy to keep track of deltaH and deltaS contributions, as well as values based on GC content and the identities of the bases on the edges of strands.""" # If we are just looking at a longer sequence, this will extend the # considered energy window. if ind == self.currInd and self.currLen != len(seq1): # Subtract the value for the previous end # Add the new base stacks # Add new end value (newBackH, newBackS) = self.getBackVals(seq1[-1]) self.currdH = self.currdH - self.backH + newBackH self.currdS = self.currdS - self.backS + newBackS (self.backH, self.backS) = (newBackH, newBackS) diffGC = 0 for j in range(self.currLen - 1, len(seq1) - 1): self.currdH += self.hQueue[(self.queueInd + j) % self.L] self.currdS += self.sQueue[(self.queueInd + j) % self.L] if seq1[j] in 'GCgc': diffGC += 1 if seq1[self.currLen - 1] in 'GCgc': diffGC -= 1 if seq1[-1] in 'GCgc': diffGC += 1 self.computeGCDiffs(diffGC) self.currLen = len(seq1) # If we jumped the window forward too far, all Tm values get reset. elif ind - self.currInd >= self.L - self.l \ or self.currLen < len(seq1) + (ind - self.currInd): self.resetTmVals(ind, len(seq1)) # Here, we have moved forward and need to shorten the front and back. elif self.currLen > len(seq1): # Subtract the value for the previous start and end. # Subtract the first base stack(s) and last base stack(s). # Add new start and end values. (newFrontH, newFrontS) = self.getFrontVals(seq1[0]) (newBackH, newBackS) = self.getBackVals(seq1[-1]) self.currdH = self.currdH - self.backH + newBackH - self.frontH \ + newFrontH self.currdS = self.currdS - self.backS + newBackS - self.frontS \ + newFrontS (self.frontH, self.frontS) = (newFrontH, newFrontS) (self.backH, self.backS) = (newBackH, newBackS) diffGC = 0 # Subtract from front. for j in range(ind - self.currInd): self.currdH -= self.hQueue[(self.queueInd + j) % self.L] self.currdS -= self.sQueue[(self.queueInd + j) % self.L] if self.block[ind - 1 - j] in 'GCgc': diffGC -= 1 # Subtract from back. for j in range(self.currInd + self.currLen - ind - len(seq1)): self.currdH -= self.hQueue[(self.queueInd + self.currLen \ - 2 - j) % self.L] self.currdS -= self.sQueue[(self.queueInd + self.currLen \ - 2 - j) % self.L] if self.block[self.currInd + self.currLen - j - 2] in 'GCgc': diffGC -= 1 if self.block[self.currInd + self.currLen - 1] in 'GCgc': diffGC -= 1 if seq1[-1] in 'GCgc': diffGC += 1 self.queueInd = (self.queueInd + ind - self.currInd) % self.L for j in range(len(seq1), self.L): if ind + j + 1 < len(self.block): neighbors = self.block[ind + j] + self.block[ind + j + 1] if neighbors in self.stackTable: self.hQueue[(self.queueInd + j) % self.L] = \ self.stackTable[neighbors][self.dH] self.sQueue[(self.queueInd + j) % self.L] = \ self.stackTable[neighbors][self.dS] # Adjust GC content count as necessary. self.computeGCDiffs(diffGC) self.currLen = len(seq1) self.currInd = ind # Adjust estimate based on salt concentration. Note that this logic # corresponds to saltcorr = 5 in the MeltingTemp library. concval = (self.conc1 - (self.conc2 / 2.0)) * 1e-9 saltval = mt.salt_correction(Na=self.sal, K=0, Tris=0, Mg=0, dNTPs=0, \ method=5, seq=seq1) tmval = (1000.0 * self.currdH) / \ (self.currdS + saltval + (1.987 * math.log(concval))) - 273.15 # ! return mt.chem_correction(tmval, fmd=self.form) approxtmval = float('%0.2f' % tmval) return mt.chem_correction(approxtmval, fmd=self.form)
def probeTm(seq1, conc1, conc2, saltConc, formConc): """Calculates the Tm of a given sequence.""" tmval = float(('%0.2f' \ % mt.Tm_NN(seq1, Na=saltConc, dnac1=conc1, dnac2=conc2))) fcorrected = ('%0.2f' % mt.chem_correction(tmval, fmd=formConc)) return fcorrected