How to do it...

Creating simple S3 objects to simplify code can be done using the following steps:

  1. Create a constructor function:
SimpleGenome <- function( nchr=NA, lengths = NA){

genome <- list(
chromosome_count = nchr,
chromosome_lengths = lengths
)
class(genome) <- append(class(genome), "SimpleGenome")
return(genome)
}
  1. Call the constructor to make new objects:
ecoli <- SimpleGenome(nchr = 1, lengths = c(4600000) )
bakers_yeast <- SimpleGenome(nchr = 1, lengths=c(12100000))

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.2.212