setInsertHook.GeneralInsertor: Set the insert hook function

Description Usage Arguments Value Author(s) See Also Examples

Description

Set the insert hook function.

The insert hook allows to make various modifications on the insert before performing the insertion. The function must have the following arguments: seq (the sequence object to insert), target.seq (the target Sequence object), event.pos (the position of the site which generated the insertion event), insert.pos (the position of 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

1
2
## S3 method for class 'GeneralInsertor'
setInsertHook(this, value, ...)

Arguments

this

A GeneralInsertor object.

value

A function object.

...

Not used.

Value

The function object.

Author(s)

Botond Sipos, Gregory Jordan

See Also

For more information see GeneralInsertor.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
	# 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)
 

phylosim documentation built on Nov. 22, 2019, 1:07 a.m.