R/pdb_dataframe.R

#' This function is neccesary to process the pdb file pre processed by Rpdb from the .pdb file into a data frame containing the xyz coordinates.
#' To use the package functions this is a necesary pre-processing step of the Rpdb object.
#' You may add more options to the function passed onto a as.tibble call for processing the Rpdb object.
#'
#' @param mypdb
#' This is an object given by an Rpdb processed .pdb file
#' @param ...
#' Parameters passed onto an as_tibble() call
#' @return
#' Retuns a coordinate based dataframe (tibble) of the pdb file
#' Comments, and connectivity information is lost
#' @export
#'
#' @examples
#' library(Rpdb)
#' library(tidyverse)
#' library(dplyr)
#'
#' y <- pdb_dataframe(CYP)
#'
pdb_dataframe <- function(mypdb, ...){
  if(!(Rpdb::is.pdb(mypdb))) {
    stop('This function can only handle pdb files processed by Rpdb!\n',
         'You have provided an object of class:', class(mypdb)[1])
  }
  #for some reason I have to null this out
  mypdb$cryst1 <- NULL
  return(tibble::as_tibble(mypdb$atoms, ...))
}
zalperst/visualizeprot documentation built on May 4, 2019, 9:08 p.m.