Skip to content

Commit

Permalink
Implemented secondary structure formamide correction and melting curv…
Browse files Browse the repository at this point in the history
…es production.
  • Loading branch information
ggirelli committed Oct 27, 2017
1 parent 87bbb3d commit 07de237
Show file tree
Hide file tree
Showing 6 changed files with 274 additions and 57 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [unreleased]

## [1.4.4]
### Changed
- Renamed `oligomeltlib.py` to `meltlib.py`.
- Renamed `oligomelt.py` to `melt_duplex.py`.

### Added
- `melt_second.py` to perform formamide correction and melting curve calculation for secondary structures predicted with OligoArrayAux.

## [1.4.3]
### Added
- Melting curve plotting script (from fish-conditions repo).
Expand Down Expand Up @@ -50,6 +58,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [1.0.0]

* [unreleased] https://github.com/ggirelli/oligo-melting
* [1.4.4] https://github.com/ggirelli/oligo-melting/releases/tag/v1.4.4
* [1.4.3] https://github.com/ggirelli/oligo-melting/releases/tag/v1.4.3
* [1.4.2] https://github.com/ggirelli/oligo-melting/releases/tag/v1.4.2
* [1.4.0] https://github.com/ggirelli/oligo-melting
Expand Down
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
oligo-melting
===

The `oligomelt.py` script, implemented in Python, allows to calculate the melting temperature of a nucleic acid duplex, provided the sequence of one of the two strands.
## Duplexes

The `melt_duplex.py` script, implemented in Python, allows to calculate the melting temperature of a nucleic acid duplex, provided the sequence of one of the two strands.

The hybridization delta free energy calculation is based on the N-N thermodynamic values in literature and is available for DNA:DNA[^3], RNA:RNA[^1] and DNA:RNA[^2] duplexes. The melting temperature calculation is based on Santalucia, 1998[^4]. Sodium and cagnesium concentration correction is based on the work of Owczarzy et al[^5][^6]. Formamide correction can be performed based on two different published models[^7][^8].

Expand All @@ -13,15 +15,13 @@ The hybridization delta free energy calculation is based on the N-N thermodynami
* Use `-C` for the temperature in **degree Celsius** instead of Kelvin.
* Use `--out-curve` to specify a file where to save estimated single-sequence **melting curves** with temperature range and step around the melting temperature as defined with `--t-curve`.

### Help page

```
usage: oligomelt.py [-h] [-t {DNA:DNA,RNA:RNA,RNA:DNA,DNA:RNA}]
[-o oligo_conc] [-n na_conc] [-m mg_conc]
[-f fa_conc] [--fa-mode fa_mode] [--fa-mvalue m]
[--t-curve range step] [--out-curve outname]
[-C] [-F] [-v]
seq
usage: melt_duplex.py [-h] [-t {DNA:DNA,RNA:RNA,RNA:DNA,DNA:RNA}]
[-o oligo_conc] [-n na_conc] [-m mg_conc]
[-f fa_conc] [--fa-mode fa_mode] [--fa-mvalue m]
[--t-curve range step] [--out-curve outname]
[-C] [-F] [-v]
seq
Calculate melting temeprature of a DNA duplex at provided [oligo],
[Na+], [Mg2+]. Either provide an oligo sequence or a file with one oligo
Expand Down Expand Up @@ -74,9 +74,13 @@ optional arguments:
-v, --verbose Verbose output.
```

### Secondary structure

The `melt_second.py` script, implemented in Python, allows to correct the melting temperature of a nucleic acid secondary structure, previously calculated with OligoArrayAux, and to produce the corresponding melting curves.

### Library

The `oligomeltlib.py` function library (available in `/lib/`) contains all the functions necessary to calculate and/or correct a duplex melting temperature based on a number of parameters.
The `meltlib.py` function library (available in `/lib/`) contains all the functions necessary to calculate and/or correct a duplex melting temperature based on a number of parameters.

### Additional scripts

Expand Down
Binary file added lib/__pycache__/meltlib.cpython-36.pyc
Binary file not shown.
114 changes: 83 additions & 31 deletions lib/oligomeltlib.py → lib/meltlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@
#
# Author: Gabriele Girelli
# Email: gigi.ga90@gmail.com
# Version: 1.0.1
# Version: 1.4.4
# Date: 20171026
# Project: oligo characterization
# Description: functions to calculate and correct melting temperature.
#
# Changelog:
# unrelease: ...
# 1.0.1: fixed melting curves (inverted).
# 1.0.0: functions retrieved from original script.
#
# References:
# [1] Freier et al, PNAS(83), 1986;
# [2] Sugimoto et al, Biochemistry(34), 1995.
Expand Down Expand Up @@ -207,8 +202,27 @@ def rc(na, t):

return(rc)

def melt_fa_adj(tm, h, s, seq, oligo_conc, fa_conc, fa_mode, mvalue, tt_mode):
# Adjust melting temperature based on formamide concentration.
def ssMelt_fa_adj(tm, fa_conc):
# Adjustsecondary 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.
#
# Returns:
# float: corrected melting temperature.

if 0 == fa_conc:
return(tm)
else:
return(tm - 0.72 * fa_conc)

def duMelt_fa_adj(tm, h, s, seq, oligo_conc, fa_conc, fa_mode, mvalue, tt_mode):
# Adjust melting temperature of a duplex based on formamide concentration.
# Based on Wright, Appl. env. microbiol.(80), 2014
# Or on McConaughy, Biochemistry(8), 1969
#
Expand Down Expand Up @@ -241,8 +255,8 @@ def melt_fa_adj(tm, h, s, seq, oligo_conc, fa_conc, fa_mode, mvalue, tt_mode):

return(tm)

def melt_na_adj(tm, na_conc, fgc):
# Adjust melting temperature based on sodium concentration.
def duMelt_na_adj(tm, na_conc, fgc):
# Adjust melting temperature of a duplexx based on sodium concentration.
# Based on Owczarzy et al, Biochemistry(43), 2004
#
# Args:
Expand Down Expand Up @@ -271,8 +285,8 @@ def melt_na_adj(tm, na_conc, fgc):

return(Tm2)

def melt_mg_adj(tm, mg_conc, fgc):
# Adjust melting temperature based on sodium concentration.
def duMelt_mg_adj(tm, mg_conc, fgc):
# Adjust melting temperature a duplexx based on sodium concentration.
# Based on Owczarzy et al, Biochemistry(47), 2008
#
# Args:
Expand Down Expand Up @@ -306,8 +320,8 @@ def melt_mg_adj(tm, mg_conc, fgc):

return(Tm3)

def melt_ion_adj(tm, na_conc, mg_conc, fgc):
# Adjust melting temperature based on ion concentration
def duMelt_ion_adj(tm, na_conc, mg_conc, fgc):
# Adjust melting temperature a duplexx based on ion concentration
#
# Args:
# tm (float): melting temperature.
Expand All @@ -318,13 +332,13 @@ def melt_ion_adj(tm, na_conc, mg_conc, fgc):
# Returns:
# float: adjusted melting temperature.
if 0 != mg_conc:
return(melt_mg_adj(tm, mg_conc, fgc))
return(duMelt_mg_adj(tm, mg_conc, fgc))
elif 0 != na_conc:
return(melt_na_adj(tm, na_conc, fgc))
return(duMelt_na_adj(tm, na_conc, fgc))
else:
return(tm)

def melt_curve(seq, oligo_conc, na_conc, mg_conc, fa_conc, fa_mode, mvalue,
def duMelt_curve(seq, oligo_conc, na_conc, mg_conc, fa_conc, fa_mode, mvalue,
fgc, h, s, tm, trange, tstep, tt_mode):
# Generate melting curve
#
Expand Down Expand Up @@ -352,7 +366,7 @@ def melt_curve(seq, oligo_conc, na_conc, mg_conc, fa_conc, fa_mode, mvalue,

# Adjust melting temperature
if "wright" == fa_mode:
tm = melt_fa_adj(tm, h, s, seq, oligo_conc,
tm = duMelt_fa_adj(tm, h, s, seq, oligo_conc,
fa_conc, fa_mode, mvalue, tt_mode)

# Explore the temperature range
Expand All @@ -372,8 +386,8 @@ def melt_curve(seq, oligo_conc, na_conc, mg_conc, fa_conc, fa_mode, mvalue,
k = 1 - factor / (1 + factor)

# Adjust output temperature
t_out = melt_ion_adj(t, na_conc, mg_conc, fgc)
t_out = melt_fa_adj(t_out, h, s, seq, oligo_conc,
t_out = duMelt_ion_adj(t, na_conc, mg_conc, fgc)
t_out = duMelt_fa_adj(t_out, h, s, seq, oligo_conc,
fa_conc, fa_mode, mvalue, tt_mode)

if "wright" == fa_mode:
Expand All @@ -390,7 +404,7 @@ def melt_curve(seq, oligo_conc, na_conc, mg_conc, fa_conc, fa_mode, mvalue,
k = 1 - factor / (1 + factor)

# Adjust output temperature
t_out = melt_ion_adj(t, na_conc, mg_conc, fgc)
t_out = duMelt_ion_adj(t, na_conc, mg_conc, fgc)

# Append melting data
data.append((t_out, k))
Expand All @@ -401,9 +415,47 @@ def melt_curve(seq, oligo_conc, na_conc, mg_conc, fa_conc, fa_mode, mvalue,
# Return melting table
return(data)

def melt_std_calc(seq, tt, tt_mode, couples, oligo_conc):
# Calculate melting temperature at standard 1 M NaCl (monovalent ions conc)
# Based on SantaLucia, PNAS(95), 1998
def ssMelt_curve(h, s, tm, fa_conc, trange, tstep):
# 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.:
dg = h - t * s

# Calculate factor
factor = math.exp(-dg / (R * t))

# Calculate fraction
k = 1 / (1 + factor)

# Adjust output temperature
t_out = ssMelt_fa_adj(t, fa_conc)

# Append melting data
data.append((t_out, k))

# Go to next temperature
t += tstep

# Return melting table
return(data)

def duMelt_std_calc(seq, tt, tt_mode, couples, oligo_conc):
# Calculate melting temperature of a duplex at standard 1 M NaCl (monovalent
# ions conc). Based on SantaLucia, PNAS(95), 1998
#
# Args:
# seq (string): oligonucleotide sequence.
Expand Down Expand Up @@ -456,11 +508,11 @@ def melt_std_calc(seq, tt, tt_mode, couples, oligo_conc):
# Output
return((h, s, tm))

def melt_calc(name, seq, oligo_conc, na_conc, mg_conc,
def duMelt_calc(name, seq, oligo_conc, na_conc, mg_conc,
fa_conc, fa_mode, fa_mval_s, mvalue,
tt, tt_mode, celsius, is_verbose,
do_curve, curve_step, curve_range, curve_outpath):
# Calculate melting temperature of provided oligo sequence.
# Calculate melting temperature of provided oligo duplex sequence.
#
# Args:
# seq (string): oligonucleotide sequence.
Expand Down Expand Up @@ -507,25 +559,25 @@ def melt_calc(name, seq, oligo_conc, na_conc, mg_conc,
# 1 M NaCl case
# Based on SantaLucia, PNAS(95), 1998
# -----------------------------------
(h, s, Tm1) = melt_std_calc(seq, tt, tt_mode, couples, oligo_conc)
(h, s, Tm1) = duMelt_std_calc(seq, tt, tt_mode, couples, oligo_conc)

# Adjust for FA
# Based on Wright, Appl. env. microbiol.(80), 2014
# Or on McConaughy, Biochemistry(8), 1969
# ------------------------------------------------
Tm2 = melt_fa_adj(Tm1, h, s, seq, oligo_conc,
Tm2 = duMelt_fa_adj(Tm1, h, s, seq, oligo_conc,
fa_conc, fa_mode, mvalue, tt_mode)

# Adjusted for [Na]
# Based on Owczarzy et al, Biochemistry(43), 2004
# -----------------------------------------------
Tm3 = melt_na_adj(Tm2, na_conc, fgc)
Tm3 = duMelt_na_adj(Tm2, na_conc, fgc)

# Adjusted for Mg
# Based on Owczarzy et al, Biochemistry(47), 2008
# -----------------------------------------------
if 0 < mg_conc:
Tm4 = melt_mg_adj(Tm2, mg_conc, fgc)
Tm4 = duMelt_mg_adj(Tm2, mg_conc, fgc)
else:
Tm4 = Tm3

Expand All @@ -534,7 +586,7 @@ def melt_calc(name, seq, oligo_conc, na_conc, mg_conc,

if do_curve:
fout = open(curve_outpath, 'a+')
tab = melt_curve(seq, oligo_conc, na_conc, mg_conc,
tab = duMelt_curve(seq, oligo_conc, na_conc, mg_conc,
fa_conc, fa_mode, mvalue, fgc, h, s, Tm1,
curve_range, curve_step, tt_mode)
for (t, k) in tab:
Expand Down
21 changes: 5 additions & 16 deletions oligomelt.py → melt_duplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,11 @@
#
# Author: Gabriele Girelli
# Email: gigi.ga90@gmail.com
# Version: 1.4.3
# Version: 1.4.4
# Date: 20170711
# Project: oligo characterization
# Description: calculate melting temperature of a provide NA duplex
#
# Changelog:
# 1.4.3: fixed melting curves (inverted).
# 1.4.2: changed to user-defined formamide m-value for wright correction.
# 1.4.0: added formamide correction.
# 1.3.0: added temperature curve calculation. Proper fasta input.
# 1.2.2: fixed allawi and freier tables.
# 1.2.1: fixed sugimotod table.
# 1.2.0: DNA/RNA and RNA/DNA duplex calculation.
# 1.1.0: input file mode. Fixed Mg2+ correction.
# 1.0.0: first implementation.
#
# References:
# [1] Freier et al, PNAS(83), 1986;
# [2] Sugimoto et al, Biochemistry(34), 1995.
Expand All @@ -42,14 +31,14 @@
import re
import sys

from lib.oligomeltlib import *
from lib.meltlib import *

# PARAMETERS ===================================================================

# Add script description
parser = argparse.ArgumentParser(
description = '''
Calculate melting temeprature of a DNA duplex at provided [oligo],
Calculate melting temperature of a DNA duplex at provided [oligo],
[Na+], [Mg2+]. Either provide an oligo sequence or a file with one oligo
per line (and use -F option). References:
[1] Freier et al, PNAS(83), 1986;
Expand Down Expand Up @@ -236,7 +225,7 @@
# Single sequence case
data['name'] = 'seq'
data['seq'] = seq
melt_calc(**data)
duMelt_calc(**data)
else:
# Empty sequence dictionary
fastad = {}
Expand All @@ -257,7 +246,7 @@
for (name, seq) in fastad.items():
data['name'] = name
data['seq'] = seq
melt_calc(**data)
duMelt_calc(**data)

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

Expand Down
Loading

0 comments on commit 07de237

Please sign in to comment.