###################################################
### chunk number 1: load
###################################################
library(cosmo) 


###################################################
### chunk number 2: rseqArgs
###################################################
args(rseq)


###################################################
### chunk number 3: pwm
###################################################
data(motifPWM)
motifPWM


###################################################
### chunk number 4: seqLogo1
###################################################
seqLogo(motifPWM)


###################################################
### chunk number 5: transMats
###################################################
data(transMats)
transMats



###################################################
### chunk number 6: rseqEx
###################################################
simSeqs <- rseq(20, 100, 1.0, motifPWM, transMats, "ZOOPS")
simSeqs$motifs



###################################################
### chunk number 7: makeConSetArg
###################################################
args(makeConSet)


###################################################
### chunk number 8: makeConSetEx
###################################################
conSet1 <- makeConSet(numInt=3, type=c("B","V","B"),length=c(3,NA,3))


###################################################
### chunk number 9: printConSet
###################################################
conSet1


###################################################
### chunk number 10: boundCon1
###################################################
boundCon1 <- makeBoundCon(lower=1.0, upper=2.0)


###################################################
### chunk number 11: boundCon2
###################################################
boundCon2 <- makeBoundCon(lower=0.0, upper=1.0)


###################################################
### chunk number 12: palCon
###################################################
palCon1 <- makePalCon(int1=1, int2=3, errBnd=0.05)


###################################################
### chunk number 13: addCon
###################################################
constraint <- list(boundCon1, boundCon2, palCon1)
int <- list(1, 2, NA)
conSet1 <- addCon(conSet=conSet1, constraint=constraint, int=int)
conSet1


###################################################
### chunk number 14: conSet2
###################################################
conSet2 <- makeConSet(numInt=1, type="V",length=NA)
subCon1 <- makeSubMotifCon(submotif="TATA",minfreq=0.9)
conSet2 <- addCon(conSet=conSet2, constraint=subCon1, int=NA)
conSet2


###################################################
### chunk number 15: cosmoArgs
###################################################
args(cosmo)


###################################################
### chunk number 16: cosmoClass
###################################################
slotNames("cosmo")


###################################################
### chunk number 17: example1
###################################################
seqFile <- system.file("Exfiles/seq.fasta", package="cosmo")
res <- cosmo(seqs=seqFile, constraints=list(conSet1, conSet2) , minW=7, maxW=8, models=c("OOPS", "TCM")) 


###################################################
### chunk number 18: printPwm
###################################################
print(res)


###################################################
### chunk number 19: summary
###################################################
summary(res)


###################################################
### chunk number 20: candModels
###################################################
res@cand


###################################################
### chunk number 21: motifs
###################################################
summary(res@motifs)


###################################################
### chunk number 22: seqLogo2
###################################################
plot(res)


###################################################
### chunk number 23: postprob
###################################################
plot(res, type="prob")


###################################################
### chunk number 24: bgModelArgs
###################################################
args(bgModel)


###################################################
### chunk number 25: bgModelEx
###################################################
bgFile <- system.file("Exfiles", "bgSeqs", package="cosmo")
tm <- bgModel(bgFile)


###################################################
### chunk number 26: bgModelOutput
###################################################
tm


###################################################
### chunk number 27: tmatEx
###################################################
res <- cosmo(seqs=seqFile, constraints="None" , minW=8, maxW=8, models="OOPS", transMat=tm$transMat)


###################################################
### chunk number 28: tmatExOut
###################################################
res 


###################################################
### chunk number 29: bfileEx
###################################################
bfile <- system.file("Exfiles", "bfile", package="cosmo")
s1 <- scan(file = bfile, what = "", sep = "\n", quote = "", 
           allowEscapes = FALSE, quiet = TRUE)
cat(paste(s1,collapse="\n"))


###################################################
### chunk number 30: bfile2tmat
###################################################
tmat <- bfile2tmat(bfile)
tmat