Last active
October 30, 2022 23:43
-
-
Save tycheleturner/19d2e7f6886a92ab51702906426a5fbd to your computer and use it in GitHub Desktop.
bulk_AlphaFold_viewer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "AlphaFold Viewer Final" | |
author: "Tychele N. Turner, Ph.D." | |
date: "Created on October 30, 2022" | |
output: | |
html_document: default | |
pdf_document: default | |
abstract: This document contains the documentation for making the AlphaFold html. | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE) | |
``` | |
### Set up of the environment | |
```{r} | |
library("NGLVieweR") | |
#run interactive | |
setwd("~/Desktop/pdb_AF") | |
#list the pdb files | |
pdb <- list.files(".", pattern="pdb") | |
#make a function out of the viewer | |
nglV <- function(x){ | |
NGLVieweR(x) %>% stageParameters(backgroundColor = "white", zoomSpeed = 1) %>% addRepresentation("cartoon", param = list(name = "cartoon", colorScheme = "bfactor") ) %>% setSpin() | |
} | |
###list the output from your other file in here to make the final html### | |
"NP_000132.3.pdb" | |
nglV(pdb[1]) | |
"NP_000133.1.pdb" | |
nglV(pdb[2]) | |
"NP_000179.2.pdb" | |
nglV(pdb[3]) | |
"NP_000255.2.pdb" | |
nglV(pdb[4]) | |
"NP_000275.1.pdb" | |
nglV(pdb[5]) | |
"NP_000305.3.pdb" | |
nglV(pdb[6]) | |
"NP_000453.2.pdb" | |
nglV(pdb[7]) | |
"NP_000480.3.pdb" | |
nglV(pdb[8]) | |
"NP_000507.1.pdb" | |
nglV(pdb[9]) | |
"NP_000710.5.pdb" | |
nglV(pdb[10]) | |
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/Rscript | |
#Tychele N. Turner, Ph.D. | |
#October 30, 2022 | |
library("NGLVieweR") | |
#get pdb files | |
pdb <- list.files(".", pattern="pdb") | |
#loop to print out the name and the funtion running on the name of the file (this is the input to the viewer script) | |
for(i in 1:length(pdb)){ | |
cat(paste('"', pdb[i], '"', "\n", sep="")) | |
cat(paste("nglV(pdb[", i, "])", "\n", sep="")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tychele N. Turner, Ph.D.
October 30, 2022
I wrote this gist because for some reason when you loop through
NGLVieweR
to generate AlphaFold 3D structures it does not output the images. However, if you enter them by name it works. This GIST consists of a prep script to generate the input and a R markdown file to run the code to generate multiple 3D figures.To view multiple pdb files generated by AlphaFold
Put the pdb files you want to visualize in one directory
In the directory containing the pdb files, run the
alphafold_viewer_prep.R
as followsNote, you must have
R
installed and you must have already installed the packageNGLVieweR
from https://cran.r-project.org/web/packages/NGLVieweR/The script above will output some text to the screen. Copy that text and paste it in the
alphafold_viewer_final.Rmd
right under###list the output from your other file in here to make the final html###
Open the Rmd file in Rstudio. You also will want to set your working directory to wherever you have your pdb files.In Rstudio, run Knit to HTML. An HTML file will generate, and you may see the 3D structures. If you do not see the structures, close the Rstudio version of the HTML and open the HTML file in FireFox. This should show you the images.
Final notes:
Example input files, generated by me, are located here:
https://data.cyverse.org/dav-anon/iplant/home/tycheleturner/AlphaFold/bulk_AlphaFold_viewer/NP_000132.3.pdb
https://data.cyverse.org/dav-anon/iplant/home/tycheleturner/AlphaFold/bulk_AlphaFold_viewer/NP_000133.1.pdb
https://data.cyverse.org/dav-anon/iplant/home/tycheleturner/AlphaFold/bulk_AlphaFold_viewer/NP_000179.2.pdb
https://data.cyverse.org/dav-anon/iplant/home/tycheleturner/AlphaFold/bulk_AlphaFold_viewer/NP_000255.2.pdb
https://data.cyverse.org/dav-anon/iplant/home/tycheleturner/AlphaFold/bulk_AlphaFold_viewer/NP_000275.1.pdb
https://data.cyverse.org/dav-anon/iplant/home/tycheleturner/AlphaFold/bulk_AlphaFold_viewer/NP_000305.3.pdb
https://data.cyverse.org/dav-anon/iplant/home/tycheleturner/AlphaFold/bulk_AlphaFold_viewer/NP_000453.2.pdb
https://data.cyverse.org/dav-anon/iplant/home/tycheleturner/AlphaFold/bulk_AlphaFold_viewer/NP_000480.3.pdb
https://data.cyverse.org/dav-anon/iplant/home/tycheleturner/AlphaFold/bulk_AlphaFold_viewer/NP_000507.1.pdb
https://data.cyverse.org/dav-anon/iplant/home/tycheleturner/AlphaFold/bulk_AlphaFold_viewer/NP_000710.5.pdb
Example output html, generated by me, is located here:
https://data.cyverse.org/dav-anon/iplant/home/tycheleturner/AlphaFold/bulk_AlphaFold_viewer/alphafold_viewer_final.html