Learn R Programming

phylosim (version 3.0.5)

getInsertHook.GeneralInsertor: Get the insert hook function

Description

Get the insert hook function.

The insert hook allows to make various modifications on the insert before performing the insertion.

The insert hook function is called by the insertion event handler function. The insert hook takes the sequence generated by the generateInsert method throught the "seq" argument. The function must return a Sequnece object, which will be inserted in the target sequence.

Usage

# S3 method for GeneralInsertor
getInsertHook(this, ...)

Arguments

this

A GeneralInsertor object.

...

Not used.

Value

A function object.

See Also

For more information see GeneralInsertor.

Examples

Run this code
# NOT RUN {
	# create a GeneralInsertor object
	i<-GeneralInsertor(
		rate=0.5,
		propose.by=function(process){sample(c(5:10),1)}, # inserts between 5 and 10
		template.seq=NucleotideSequence(length=5,processes=list(list(JC69())))
	)
	# set a dummy insert hook
	setInsertHook(i,function(seq){return(seq)})
	# set a new insert hook via virtual field
	i$insertHook<-function(seq){
		seq$processes<-list(list(GTR())) # replace the subsitution process
		return(seq)
	}
	# get the insert hook via virtual field
	i$insertHook
	# get the insert hook
	getInsertHook(i)
 
# }

Run the code above in your browser using DataLab