Extended model for water formation

25 views
Skip to first unread message

Arda Keleş

unread,
Apr 12, 2021, 4:55:06 PM4/12/21
to IU Computing in Molecular Biology
Hello everyone, 

I've tried to write the extended version of the water formation system (OH included). I wonder if anyone else has tried it so we can compare our codes. Here is the function:


complex_water_formation <- function(N, r1_rate, r2_rate, r3_rate, r4_rate, H_ini, O_ini, OH_ini, W_ini) {
  
  W <- d_W <- rep(NA, N)
  OH <- d_OH <- rep(NA, N)
  O <- d_O <- rep(NA, N)
  H <- d_H <- rep(NA, N)
  
  W[1] <- W_ini
  OH[1] <- OH_ini
  O[1] <- O_ini
  H[1] <- H_ini
  
  d_W[1] <- d_OH[1] <- d_O[1] <- d_H[1] <- 0
  
  for(i in 2:N) {
    
    d_W[i] <- r4_rate * d_OH[i-1] * d_H[i-1] - r3_rate * d_W[i-1]
    d_OH[i] <- -r4_rate * d_H[i-1] * d_OH[i-1] - r2_rate * d_OH[i-1] + r1_rate * d_O[i-1] * d_H[i-1] + r3_rate * d_W[i-1]
    d_O[i] <- -r1_rate * d_H[i-1] * d_O[i-1] + r2_rate * d_OH[i-1]
    d_H[i] <- r2_rate * d_OH[i-1] + r3_rate * d_W[i-1] - r1_rate * d[H-1] * d_O[i-1] - r4_rate * d_H[i-1] * d_OH[i-1]
    
    W[i] <- W[i-1] + d_W[i]
    OH[i] <- OH[i-1] + d_OH[i]
    O[i] <- O[i-1] + d_O[i]
    H[i] <- H[i-1] + d_H[i]
      
  }
  
 return(data.frame(W, H, O, OH))
   
}


Take care,
Arda

Dr. Andrés Aravena

unread,
May 9, 2021, 5:56:15 AM5/9/21
to IU Computing in Molecular Biology
Hi

sorry for the late reply. I reorganized your code to understand it better. I think it is better to write first the formulas for each reaction. The key part of your code is

r1 <- r1_rate * d_H[i-1] * d_O[i-1]
r2 <- r2_rate * d_OH[i-1]
r3 <- r3_rate * d_W[i-1]
r4 <- r4_rate * d_OH[i-1] * d_H[i-1]
d_W[i] <- r4 - r3
d_OH[i] <- -r4 - r2 + r1 + r3
d_O[i] <- -r1 + r2
d_H[i] <- r2 + r3 - r1 - r4

I think this corresponds to the diagram on the blog.
Good work. Well done

Arda Keleş

unread,
May 12, 2021, 1:18:37 PM5/12/21
to iu-...@googlegroups.com
Yes sir, 
What I did at first, it looks 'ugly'. Writing the formulas for each reaction at first is so much better. I think it was a rookie mistake :)
Take care,
Arda Keleş


Dr. Andrés Aravena <andres....@istanbul.edu.tr>, 9 May 2021 Paz, 12:56 tarihinde şunu yazdı:

Yasal Uyarı: Bu elektronik posta, buradan  ulaşabileceğiniz Koşul ve Şartlara tabidir.
Disclaimer: This email is subject to the Terms and Conditions available here.
------------------------------------------------------------------
Lütfen bu e-postayı yazdırmadan önce çevreye olan etkisini dikkate alınız. Unutmayınız ki; dünyadaki kağıt tüketiminin yarısı kazanılırsa, her yıl 8 milyon hektar orman alanı (Ege Bölgesi büyüklüğünde) yok olmaktan kurtulacaktır.
------------------------------------------------------------------
Please take into account the impact on the environment before printing this e-mail. Do not forget that if we reduce our paper consumption by half, every year 8 million hectares of forest (an area the size of Aegean Region in Turkey) will be saved from vanishing.
------------------------------------------------------------------

--
You received this message because you are subscribed to a topic in the Google Groups "IU Computing in Molecular Biology" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/iu-cmb/EsqIuRi-PoY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to iu-cmb+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iu-cmb/5ecaae51-e5d0-464e-b83b-3340f0e92655n%40googlegroups.com.


--
Nazım Arda KELEŞ
İstanbul Üniversitesi - Moleküler Biyoloji ve Genetik

Andres Aravena

unread,
May 12, 2021, 2:27:21 PM5/12/21
to IU Computing in Molecular Biology
On Wed, 12 May 2021 at 20:18, Arda Keleş <ardak...@gmail.com> wrote:
Yes sir, 
What I did at first, it looks 'ugly'. Writing the formulas for each reaction at first is so much better. I think it was a rookie mistake :)

In fact it is not. It is my fault. I teach it the wrong way. Even this semester I sent a text with the confusing text. I really need to change it. I'm sorry for the confusion.

take care
Reply all
Reply to author
Forward
0 new messages