//We start by defining several compounds

Compound create "Sulfadoxine"
Compound abbreviation "S"
Compound half_life 116 //hours
//Compound bio_availability 408 //1mg to nanoM
val Sulfa = Compound prepare

Compound create "Pyre"
Compound abbreviation "P"
Compound half_life 83 //hours
//Compound bio_availability 34 //1mg to nanoM
val Pyre = Compound prepare


//We now create a drug
//bio availability is 1mg to nanoM
Drug create "SP"
Drug includes Sulfa bio_availability 408 quantity 500
Drug includes Pyre bio_availability 34 quantity 25
val SP = Drug prepare


//The same exercise for Coartem (Arthemeter + Lumefrantrine)
Compound create "Arthemeter"
Compound abbreviation "A"
Compound half_life 1.5
//Compound bio_availability 0.5
val Arthe = Compound prepare

Compound create "Lumefrantrine"
Compound abbreviation "L"
Compound half_life 76
//Compound bio_availability 25
val Lume = Compound prepare

//Include references to all values
Drug create "Coartem"
Drug includes Arthe bio_availability 0.5 quantity 20
Drug includes Lume bio_availability 25 quantity 120
val Coartem = Drug prepare


//SP Regimen create
Regimen take SP
Regimen dose 3.0
Regimen at 0
val SPRegimen = Regimen prepared

Regimen take SP
Regimen dose 3.0
Regimen at 0
Regimen at 24*60
val SPRepeatRegimen = Regimen prepared

//Coartem regimen
Regimen take Coartem
Regimen dose 2
Regimen at 0
Regimen at 12*60
Regimen at 12*60*2
Regimen at 12*60*3
Regimen at 12*60*4
Regimen at 12*60*5
val CARegimen = Regimen prepared



//And now the genome/proteome
Proteome create;
Proteome protein "DHFR"
Proteome wild_type (51, Asn)
Proteome mutation Ile
Proteome wild_type (59, Cys)
Proteome mutation Arg
Proteome wild_type (108, Asp)
Proteome mutation Asn
Proteome protein "DHPS"
Proteome wild_type (437, Ala)
Proteome mutation Gly
val proteome = Proteome prepare;

val exogenous = new Effect(
    "Exogenous folate usage",
    Sub(
        Sum(
            Mul(Var("sConst"),Min(Var("S"), Num(5000))),
            Var("P")),
        Var("pLim")),
    {case "sConst" => 0.0004 case "pLim" => 2.7}, 1)

val DHFR108Res = new Resistance(exogenous,
      proteome.mutation("DHFR", 51, Ile) ::
      proteome.mutation("DHFR", 59, Arg) ::
      proteome.mutation("DHFR", 108, Asn) :: Nil,
       {case "sConst" => 0.14 case "pLim" => 1000}, 0)