Skip to content

Commit

Permalink
-Update README and add GHA CHECK
Browse files Browse the repository at this point in the history
  • Loading branch information
tylermorganwall committed Feb 19, 2024
1 parent 1e0c441 commit 476d040
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 4 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
1 change: 1 addition & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ knitr::opts_chunk$set(
<img src="man/figures/caff.gif" ></img>

<!-- badges: start -->
[![R-CMD-check](https://github.com/tylermorganwall/raymolecule/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tylermorganwall/raymolecule/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

`raymolecule` is an R package to parse and render molecules in 3D. Rendering is powered by two packages: [rayrender](https://www.rayrender.net/) package, a pathtracer for R, and [rayvertex](https://www.rayvertex.com/), a rasterizer for R. `raymolecule` currently supports and parses SDF (structure-data file) and PDB (Protein Data Bank) files and returns a `rayrender` scene, which we then pathtrace and visualize in R. This initial release of the package only supports visualizing atoms and bonds.
Expand Down
35 changes: 31 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<img src="man/figures/caff.gif" ></img>

<!-- badges: start -->

[![R-CMD-check](https://github.com/tylermorganwall/raymolecule/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tylermorganwall/raymolecule/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

`raymolecule` is an R package to parse and render molecules in 3D.
Expand All @@ -31,10 +33,10 @@ remotes::install_github("tylermorganwall/raymolecule")
`raymolecule` includes several example SDF files for the following
molecules: “benzene”, “buckyball”, “caffeine”, “capsaicin”,
“cinnemaldehyde”, “geraniol”, “luciferin”, “morphine”, “penicillin”,
“pfoa”, “skatole”, “tubocurarine\_chloride”. You can get the file path
to these example files using the `get_example_molecule()` function. We
pass this path to the `read_sdf()` file to parse the file and extract
the atom coordinates and bond information in a list. `raymolecule` also
“pfoa”, “skatole”, “tubocurarine_chloride”. You can get the file path to
these example files using the `get_example_molecule()` function. We pass
this path to the `read_sdf()` file to parse the file and extract the
atom coordinates and bond information in a list. `raymolecule` also
includes the ability to fetch molecules from PubChem using the
`get_molecule()` function. The magrittr pipe is automatically imported
in the package, so we will use it to pass the output of each function to
Expand All @@ -43,6 +45,7 @@ the input of the next.
Here’s the format of the data:

``` r

library(raymolecule)

get_example_molecule("benzene") |>
Expand Down Expand Up @@ -85,6 +88,7 @@ ID (CID), in case you have a specific molecule with a long name or
unique isoform:

``` r

str(get_molecule("estradiol"))
#> List of 2
#> $ atoms:'data.frame': 44 obs. of 5 variables:
Expand Down Expand Up @@ -124,32 +128,44 @@ molecule. For more rendering options, see `rayrender::render_scene()`
and `rayvertex::rasterize_scene()`.

``` r

#Specify a width, height, and number of samples for the image (more samples == less noise)
get_example_molecule("caffeine") |>
read_sdf() |>
generate_full_scene() |>
render_model(width=800,height=800,samples=1000, clamp_value=10)
#> Warning in render_scene(scene = scene, fov = fov, lookfrom = c(0, 0, widest * :
#> "sobol_blue" sample method only valid for `samples` than or equal to
#> 256--switching to `sample_method = "sobol"`
```

<img src="man/figures/README-unnamed-chunk-5-1.png" width="100%" />

``` r

#Light from both bottom and top
get_example_molecule("cinnemaldehyde") |>
read_sdf() |>
generate_full_scene() |>
render_model(lights="both",width=800,height=800,samples=1000,clamp_value=10)
#> Warning in render_scene(scene = scene, fov = fov, lookfrom = c(0, 0, widest * :
#> "sobol_blue" sample method only valid for `samples` than or equal to
#> 256--switching to `sample_method = "sobol"`
```

<img src="man/figures/README-unnamed-chunk-5-2.png" width="100%" />

``` r

#Rotate the molecule and add a non-zero aperture setting to get depth of field effect
get_example_molecule("penicillin") |>
read_sdf() |>
generate_full_scene() |>
render_model(lights="both",width=800,height=800,samples=1000,angle=c(0,30,0),aperture=3,
clamp_value=10)
#> Warning in render_scene(scene = scene, fov = fov, lookfrom = c(0, 0, widest * :
#> "sobol_blue" sample method only valid for `samples` than or equal to
#> 256--switching to `sample_method = "sobol"`
```

<img src="man/figures/README-unnamed-chunk-5-3.png" width="100%" />
Expand All @@ -158,6 +174,7 @@ We can use `rayvertex` to render images much more quickly and noise
free, as well as include a toon cel-shading effect.

``` r

library(rayvertex)

#Render a basic example with rayvertex
Expand All @@ -170,6 +187,7 @@ get_example_molecule("tubocurarine_chloride") |>
<img src="man/figures/README-unnamed-chunk-6-1.png" width="100%" />

``` r

#Customize the material with toon shading
shiny_toon_material = material_list(type="toon_phong",
toon_levels=,
Expand All @@ -183,6 +201,7 @@ get_example_molecule("morphine") |>
<img src="man/figures/README-unnamed-chunk-6-2.png" width="100%" />

``` r

#Customize the lights with rayvertex
get_example_molecule("skatole") |>
read_sdf() |>
Expand All @@ -202,6 +221,7 @@ function or rayvertex’s `add_shape()` function. If you use
view yourself.

``` r

library(rayrender)

buckyball = get_example_molecule("buckyball") |>
Expand All @@ -213,17 +233,24 @@ buckyball |>
add_object(sphere(y=12,radius=3,material=light(color="white", intensity=50))) |>
add_object(sphere(y=-12,radius=3,material=light(color="red", intensity=50))) |>
render_model(lights="none",width=800,height=800,samples=1000, clamp_value=10)
#> Warning in render_scene(scene = scene, fov = fov, lookfrom = c(0, 0, widest * :
#> "sobol_blue" sample method only valid for `samples` than or equal to
#> 256--switching to `sample_method = "sobol"`
```

<img src="man/figures/README-unnamed-chunk-7-1.png" width="100%" />

``` r

#Generate ground underneath the model and use a light to cast a shadow
generate_ground(depth=-4,material=diffuse(sigma=90)) |>
add_object(buckyball) |>
add_object(sphere(y=8,material=light(intensity=100))) |>
render_scene(width=800,height=800,samples=1000,aperture=1,fov=30,lookfrom = c(0,1,30),
clamp_value = 10)
#> Warning in render_scene(add_object(add_object(generate_ground(depth = -4, :
#> "sobol_blue" sample method only valid for `samples` than or equal to
#> 256--switching to `sample_method = "sobol"`
```

<img src="man/figures/README-unnamed-chunk-7-2.png" width="100%" />
Binary file modified man/figures/README-unnamed-chunk-5-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-5-2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-5-3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-6-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-6-2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-6-3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-7-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-7-2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 476d040

Please sign in to comment.