Skip to content

Commit

Permalink
Blacked.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggirelli committed Mar 2, 2021
1 parent 6eb9fed commit 7084183
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 36 deletions.
52 changes: 28 additions & 24 deletions oligo_melting/secstr.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-

'''
"""
@author: Gabriele Girelli
@contact: gigi.ga90@gmail.com
@description: methods for melting temperature calculation and correction for
single-strand oligonucleotide secondary structures.
'''
"""

# DEPENDENCIES =================================================================

Expand All @@ -15,26 +15,27 @@
# CONSTANTS ====================================================================

# Gas constant
R = 1.987 / 1000 # kcal / (K mol)
R = 1.987 / 1000 # kcal / (K mol)

# FUNCTIONS ====================================================================

def adj_fa(tm, fa_conc, fa_conc_0 = None):
'''Adjust secondary structure melting temperature based on formamide

def adj_fa(tm, fa_conc, fa_conc_0=None):
"""Adjust secondary structure melting temperature based on formamide
concentration. Method adapted to work with OligoArrayAux output.
Based on McConaughy, Biochemistry(8), 1969
Method based on Wright et al not implemented, as m-value is not available.
Args:
tm (float): melting temperature, in K.
fa_conc (float): formamide concentration in %v,v.
fa_mode (string): formamide correction lavel.
fa_conc_0 (float): initial formamide concentration in %v,v.
Returns:
float: corrected melting temperature.
'''
"""

# Default initial concentration
if type(None) == type(fa_conc_0):
fa_conc_0 = 0
Expand All @@ -44,29 +45,30 @@ def adj_fa(tm, fa_conc, fa_conc_0 = None):

# Correct
if 0 == dfac:
return(tm)
return tm
else:
return(tm - 0.72 * dfac)
return tm - 0.72 * dfac


def melt_curve(h, s, tm, fa_conc, trange, tstep):
'''Generate melting curve
"""Generate melting curve
Args:
tm (float): melting temperature.
fa_conc (float): formamide concentration in %v,v.
trange (float): melting curve temperature range.
tstep (float): melting curve temperature step.
Returns:
list: melting curve data (x, y)
'''
"""

# Empty list for melting table
data = []

# Explore the temperature range
t = tm - trange / 2.
while t <= tm + trange / 2.:
t = tm - trange / 2.0
while t <= tm + trange / 2.0:
# Calculate dissociated fraction
k = unfolded_fraction(h, t, s)

Expand All @@ -80,20 +82,21 @@ def melt_curve(h, s, tm, fa_conc, trange, tstep):
t += tstep

# Return melting table
return(data)
return data


def unfolded_fraction(h, t, s):
'''Calculate secondary structure unfolded fraction
"""Calculate secondary structure unfolded fraction
Args:
h (float): enthalpy.
t (float): current temperature.
s (float): enthropy.
Returns:
float: dissociated fraction.
'''
"""

# Calculate free energy at current temperature
dg = h - t * s

Expand All @@ -104,7 +107,8 @@ def unfolded_fraction(h, t, s):
k = 1 / (1 + factor)

# Output
return(k)
return k


# END ==========================================================================

Expand Down
26 changes: 14 additions & 12 deletions oligo_melting/seq.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-

'''
"""
@author: Gabriele Girelli
@contact: gigi.ga90@gmail.com
@description: methods for basic nucleic acid sequence management.
'''
"""

# CONSTANTS ====================================================================

Expand All @@ -13,27 +13,28 @@

# FUNCTIONS ====================================================================


def rc(na, t):
'''
"""
Args:
na (string): nucleic acid sequence.
t (string): nucleic acid type, either 'dna' or 'rna'.
Return:
string: reverse complement of na.
'''
"""

# Identify type
t = t.lower()

# Select alphabet
if t == 'dna':
if t == "dna":
ab = AB_DNA
elif t == 'rna':
elif t == "rna":
ab = AB_RNA
else:
print('ERROR: unknown na type.')
return()
print("ERROR: unknown na type.")
return ()

rab = ab[1].strip().lower()
ab = ab[0].strip().lower()
Expand All @@ -43,8 +44,8 @@ def rc(na, t):

for c in na:
if not c in ab:
print('ERROR: provided string conflicts with selected alphabet.')
return()
print("ERROR: provided string conflicts with selected alphabet.")
return ()

# Calculate reverse
r = na[::-1]
Expand All @@ -54,9 +55,10 @@ def rc(na, t):
for c in r:
rc.append(rab[ab.index(c)])

rc=''.join([str(c) for c in rc]).upper()
rc = "".join([str(c) for c in rc]).upper()

return rc

return(rc)

# END ==========================================================================

Expand Down

0 comments on commit 7084183

Please sign in to comment.