Skip to content

Commit

Permalink
added example
Browse files Browse the repository at this point in the history
  • Loading branch information
cpanse committed Nov 9, 2018
1 parent 79172bb commit 7a1b77c
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 33 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Author: Pascal Egloff [ctb, aut],
Christian Panse [aut, cre] (0000-0003-1975-3064),
Bernd Roschitzki [ctb, aut],
Markus Seeger [ctb, aut] (0000-0003-1761-8571)
Version: 0.99.57
Version: 0.99.58
Depends: R (>= 3.5.1),
Biostrings,
gplots,
Expand Down
7 changes: 4 additions & 3 deletions R/compose.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
#' @author Christian Panse <cp@fgcz.ethz.ch> 2015
#' @export compose_GSx7cTerm
compose_GSx7cTerm <-
function(pool=c(rep('A', 18), rep('S', 6), rep('T', 12), rep('N', 1),
function(pool=c(rep('A', 18), rep('S', 6), rep('T', 12),
rep('N', 1),
rep('Q', 1), rep('D', 11), rep('E', 11), rep('V', 12),
rep('L', 2), rep('F', 1), rep('Y', 4), rep('W', 1),
rep('G', 8), rep('P', 12)),
Expand Down Expand Up @@ -304,12 +305,12 @@ NULL
#' @name F255744
#' @docType data
#' @author Pascal Egloff \email{p.egloff@imm.uzh.ch}
#' @references \url{http://fgcz-mascot-server.uzh.ch/mascot/cgi/master_results_2.pl?file=..%2Fdata%2F20170819%2FF255744.dat}
#' @seealso \href{https://fgcz-bfabric.uzh.ch/bfabric/userlab/show-resource.html?id=409912}{F255744}
#' @keywords data
#' @examples
#' class(F255744)
#' hist(F255744$RTINSECONDS)
#' hist(F255744$RTINSECONDS[F255744$pep_score>20])
#' hist(F255744$RTINSECONDS[F255744$pep_score > 20])
NULL


Expand Down
58 changes: 38 additions & 20 deletions R/fasta.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,60 @@

#' write FASTA
#'
#' @param x a \code{nanobodyFlycodeLinking} class computed by \code{\link{runNGSAnalysis}}.

#' @param x a \code{nanobodyFlycodeLinking} S3 object computed by
#' \code{\link{runNGSAnalysis}}.
#' @param file a filename
#' @param ... just passed
#'
#' @return sprintf stream
#' @export nanobodyFlycodeLinking.as.fasta
#'
#' @author Lennart Opitz, Christian Panse 2018
#' @examples
#' \dontrun{
#' FF <- c('~/__projects/2018/20181030-p1875/NL7-1.extendedFrags_uniqNB2FC.txt',
#' '~/__projects/2018/20181030-p1875/NL7-2.extendedFrags_uniqNB2FC.txt')
#'
#' X <- do.call('rbind', lapply(FF, read.table, header=T, sep='\t'))
#' cat(uniqNB2FC.as.fasta(X), file=tempfile(fileext=".fasta"))
#' }
nanobodyFlycodeLinking.as.fasta <- function(x, ...){
#' f <- system.file("extdata/nanobodyFlycodeLinkage.RData", package="NestLink")
#' load(f)
#' summary(nanobodyFlycodeLinkage.sample)
#' nanobodyFlycodeLinking.as.fasta(nanobodyFlycodeLinkage.sample)
nanobodyFlycodeLinking.as.fasta <- function(x, file=NULL, ...){
if (!is.nanobodyFlycodeLinking(x)){
warning("object is not of class nanobodyFlycodeLinking")
}
idx <- seq(1, nrow(x))
sprintf(">NB%04d_NL7Idx1 FC%d %s\n%s\n", idx, x$FlycodeCount[idx],
x$NB[idx], gsub(",", "", x$AssociatedFlycodes[idx]))

fasta <- sprintf(">NB%04d FC%d %s\n%s\n",
idx,
x$FlycodeCount[idx],
x$NB[idx],
gsub(",", "", x$AssociatedFlycodes[idx]))

if(!is.null(file)){
cat(fasta, file, sep = '')
message(paste("FASTA written to", file))
}else{
return(fasta)
}
}

is.nanobodyFlycodeLinking <- function(object){
sum(object$FlycodeCount) == sum(sapply(strsplit(object$AssociatedFlycodes, ","), length))
}

#' Object Summaries of S3 class \code{nanobodyFlycodeLinking}
#'
#' @param object a \code{nanobodyFlycodeLinking} class computed by \code{\link{runNGSAnalysis}}.
#'
#' @return a data.frame object
#' @export nanobodyFlycodeLinking.summary
#' @examples
#' f <- system.file("extdata/nanobodyFlycodeLinkage.RData", package="NestLink")
#' load(f)
#' summary(nanobodyFlycodeLinkage.sample)
nanobodyFlycodeLinking.summary <- function(object){

# number of NB
# number FC
# number of AAs
# cat(length(object))
# cat()
cat ("to be implemented.")
if (!is.nanobodyFlycodeLinking(object)){
warning("object is not of class nanobodyFlycodeLinking")
}
df<-data.frame("number.Nanobodies"=nrow(object),
"number.Flycodes"= sum(object$FlycodeCount),
"number.AminoAcids"=sum(nchar(gsub(",", "", object$AssociatedFlycodes))))
df
}

3 changes: 3 additions & 0 deletions man/F255744.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions man/nanobodyFlycodeLinking.as.fasta.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions man/nanobodyFlycodeLinking.summary.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7a1b77c

Please sign in to comment.