94_makeNewAnnotationPackage.R 4.41 KB
Newer Older
VladaMilch's avatar
VladaMilch committed
1
2
3
4
5
6
7
8
9
10
11
12
#' Short description string here
#'
#' Long description string
#'
#' @title What function does (short)
#' @param alignment.dir path to the directory that contains alignment files
#' @param Annotation regerence genome annotation \code{data.frame}
#' @param outputDir output directory
#' @param level character string, can take values "gene" or "transcript", specifying if new probe sets should be formed per gene or per transcript
#' @param min_probe_number numeric, minimal number or probes in a probe set
#' @param pkgNameSUFFIX character, suffix to the package name, usually starts with dor: '.hereIsYourSuffix'
#' @param quiet logical
13
#' @param fastaDir directory used for generation of the FASTA files
VladaMilch's avatar
VladaMilch committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#' @return a \code{"output type"}.
#' @seealso \code{function or class name}
#' @author Vladislava Milchevskaya \email{milchv@gmail.com}
#' @examples
#' data("Alignments_class_example")
#' data("Annotation_example")
#' data("seed_example")
#' alignmentDir <- 
#'   unlist(strsplit(dir(system.file("extdata",package="pdProbeRemap"), 
#'                       pattern="example_drosophila.Aligned.out.sam",
#'                       full.names=TRUE), split = "example_drosophila.Aligned.out.sam"))[1]
#' 
#' outputDir_example = system.file("data", package = "pdProbeRemap")
#' 
#' \dontrun{
#' makeNewAnnotationPackage(alignment.dir = alignmentDir, 
#'                          Annotation = Annotation_example, 
#'                          outputDir = outputDir_example, 
#'                          level = "gene", 
#'                          min_probe_number = 1, 
#'                          pkgNameSUFFIX = ".example")
#'                          }
#' @export
makeNewAnnotationPackage <- function(alignment.dir, 
                                     Annotation,
                                     outputDir,
                                     level,
                                     min_probe_number, 
                                     quiet=FALSE, 
43
44
                                     pkgNameSUFFIX, 
                                     fastaDir)
VladaMilch's avatar
VladaMilch committed
45
{
46
      if(!file.exists( file.path(fastaDir, "tmpProbesTableDir/seed3.RData")))
47
    {stop("Please provide the directory used to generate fasta files in the previous step (fastaDir). \n")}
VladaMilch's avatar
VladaMilch committed
48
    
49
    load(file.path(fastaDir, "tmpProbesTableDir/seed3.RData"))
VladaMilch's avatar
VladaMilch committed
50
51
52
53
54
55
56
    new_pd <- makeNewAnnotationPackage_inner(alignment.dir = alignment.dir, 
                                   Annotation = Annotation,
                                   package_seed = seed3,
                                   outputDir = outputDir,
                                   level = level,
                                   min_probe_number = min_probe_number, 
                                   quiet=quiet, 
57
58
                                   pkgNameSUFFIX = pkgNameSUFFIX, 
                                   fastaDir=fastaDir)
VladaMilch's avatar
VladaMilch committed
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
    # debugging msg start
    cat(paste0(names(new_pd)))
    # debugging msg end

    invisible(new_pd)
}


# inner function #
makeNewAnnotationPackage_inner <- function(alignment.dir, 
                                           Annotation,
                                           package_seed,
                                           outputDir,
                                           level,
                                           min_probe_number, 
                                           quiet=FALSE, 
75
76
                                           pkgNameSUFFIX, 
                                           fastaDir=fastaDir
VladaMilch's avatar
VladaMilch committed
77
78
79
80
81
82
83
84
)
{
    stopifnot(class(pkgNameSUFFIX) == "character")
    stopifnot(class(quiet) == "logical")
  
    # checks for input parameters for alignments2parsedData inside the function  
    NEW_ParsedData <- alignments2parsedData(alignment.dir = alignment.dir, 
                                            Annotation = Annotation,
85
                                            outputDir = fastaDir,
VladaMilch's avatar
VladaMilch committed
86
87
88
89
90
91
                                            level = level,
                                            min_probe_number = min_probe_number, 
                                            package_seed = package_seed)
    
    make_package_from_parsedData(parsedData = NEW_ParsedData, 
                                 object = package_seed[[1]], #seed
92
                                 destDir = fastaDir,
VladaMilch's avatar
VladaMilch committed
93
94
95
96
97
98
                                 quiet = quiet, 
                                 pkgNameSUFFIX = pkgNameSUFFIX,
                                 annotation_type = package_seed[[3]])
  
    return(NEW_ParsedData)
}