\HeaderA{extract.lib}{Functions for SAGE library extraction}{extract.lib}
\aliasA{combine.libs}{extract.lib}{combine.libs}
\aliasA{compute.unique.tags}{extract.lib}{compute.unique.tags}
\aliasA{extract.ditags}{extract.lib}{extract.ditags}
\aliasA{extract.lib.from.directory}{extract.lib}{extract.lib.from.directory}
\aliasA{extract.lib.from.zip}{extract.lib}{extract.lib.from.zip}
\aliasA{extract.library.tags}{extract.lib}{extract.library.tags}
\aliasA{read.phd.file}{extract.lib}{read.phd.file}
\aliasA{read.seq.qual.filepair}{extract.lib}{read.seq.qual.filepair}
\aliasA{reestimate.lib.from.tagcounts}{extract.lib}{reestimate.lib.from.tagcounts}
\aliasA{remove.sage.artifacts}{extract.lib}{remove.sage.artifacts}
\aliasA{SAGEartifacts}{extract.lib}{SAGEartifacts}
\keyword{manip}{extract.lib}
\begin{Description}\relax
Functions to extract the tags in a library from sequences or
base-caller output.
\end{Description}
\begin{Usage}
\begin{verbatim}
extract.lib.from.zip(zipfile, libname=sub(".zip","",basename(zipfile)),
                     ...)
extract.lib.from.directory(dirname, libname=basename(dirname),
                           pattern, ...)
extract.library.tags(filelist, base.caller.format="phd",
                     remove.duplicate.ditags=TRUE, 
                     remove.N=FALSE, remove.low.quality=10,
                     taglength=10, min.ditag.length=(2*taglength-2),
                     max.ditag.length=(2*taglength+4),
                     cut.site="catg", default.quality=NA, verbose=TRUE,
                     ...) 
reestimate.lib.from.tagcounts(tagcounts, libname, default.quality=20, ...) 
compute.unique.tags(lib)
combine.libs(..., artifacts=c("Linker", "Ribosomal", "Mitochondrial"))
remove.sage.artifacts(lib,
                      artifacts=c("Linker","Ribosomal","Mitochondrial"),
                      ...)
read.phd.file(file)
read.seq.qual.filepair(file, default.quality=NA)
extract.ditags(sequence, taglength=10, filename=NA,
               min.ditag.length=(2*taglength-2),
               max.ditag.length=(2*taglength+4), cut.site="catg")

\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{zipfile,dirname}] Name of a ZIP file or a directory that contains
base-caller output files
\item[\code{libname}] \code{libname} a character string to be assigned as
library name
\item[\code{pattern}] Regular expression to specify pattern for the files
that will be read
\item[\code{filelist}] List of files to be read
\item[\code{base.caller.format}] \code{base.caller.format} can be "phd" or
"seq" or a character vector of the length of the filelist
\item[\code{remove.duplicate.ditags}] Remove duplicate ditags. TRUE or FALSE
\item[\code{remove.N}] Remove all tags that contain N. TRUE or FALSE
\item[\code{remove.low.quality}] Remove all tags with an average quality
score of less than \code{remove.low.quality}. Skipped if \textless{} 0
\item[\code{taglength}] Length of tags. Usually 10 or 17
\item[\code{min.ditag.length,max.ditag.length}] Minimum and maximum length
for ditags
\item[\code{cut.site}] Restriction enzyme cut site. Usually CATG
\item[\code{verbose}] Display information during process
\item[\code{lib}] Library object
\item[\code{file,filename}] Character string indicating file name
\item[\code{default.quality}] Quality value to use on sequences, if quality
files are missing
\item[\code{sequence}] Construct containing sequence and quality values
returned by read.phd.file or read.seq.qual.filepair
\item[\code{artifacts}] Types of artificially generated tags to remove.
\item[\code{...}] Arguments passed on to extraction functions.
\item[\code{tagcounts}] Tagcounts from library. Integer Vecotor with Tag sequences as names.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The functions \code{extract.lib.from.zip} or
\code{extract.lib.from.directory} should be used to extract the SAGE
TAGS from the sequences of a library, the sequences need to be
provided by the output files from the base caller software either
in a ZIP archive or in a directory. These are usually the only functions
that should directly be called by the user. The other functions are
called by these and should only be used directly by experienced users
to get more direct control over the process. Most arguments are
passed on and can be specified in the high level
functions. Zipfilenames must be specified using relative pathnames!
\end{Details}
\begin{Value}
\code{lib} returns an SAGE library object.
\end{Value}
\begin{Author}\relax
Tim Beissbarth
\end{Author}
\begin{References}\relax
\url{http://tagcalling.mbgproject.org}
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{sage.library}{sage.library}},
\code{\LinkA{error.correction}{error.correction}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
#library(sagenhaft)
#file.copy(system.file("data/E15postHFI.zip",package="sagenhaft"),
#          "E15postHFI.zip")
#E15post<-extract.lib.from.zip("E15postHFI.zip", taglength=10,
#                              min.ditag.length=20, max.ditag.length=24)
#E15post
\end{ExampleCode}
\end{Examples}

