Skip to content

Commit

Permalink
use cat to get cleaner vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Charlop-Powers authored and Zachary Charlop-Powers committed Mar 3, 2024
1 parent 4c93aa5 commit 110e44b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions R/depict.R
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ get_svg_string <- function(molgrid) {
svg_str <- .jcall(molgrid, 'S' ,'toSvgStr')

svg_list <- strsplit(svg_str, "\n")[[1]]

# return the svg without the two header lines
paste(svg_list[3:length(svg_list)], collapse="\n")
}
Expand Down
28 changes: 17 additions & 11 deletions vignettes/depict.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ pen <- parse_smiles("CC1(C(N2C(S1)C(C2=O)NC(=O)CC3=CC=CC=C3)C(=O)[O-])C penicill
# `depiction` is the base class; styles are applied to it
# `depict` applies the styles to the molecule
depiction() |>
set_zoom(2) |>
depict(pen) |>
get_svg_string()
get_svg_string() |>
cat()
```


Expand All @@ -58,14 +60,16 @@ many_containers <- atomcontainer_list_to_jarray(atmcontainers)
depiction() |>
set_zoom(2) |>
depict(many_containers) |>
get_svg_string()
get_svg_string() |>
cat()
```



# Use Colors, SMARTS, Highlighting

```{r, results='asis'}
# you must supply java colors
color <- J("java.awt.Color")
Expand All @@ -85,12 +89,12 @@ depiction() |>
highlight_atoms(atms, color$LIGHT_GRAY) |>
highlight_atoms(bnds, color$LIGHT_GRAY) |>
highlight_atoms(lactam, color$RED) |>
#set_size(400, 400) |>
set_zoom(2) |>
outerglow() |>
add_title() |>
depict(pen) |>
get_svg_string()
get_svg_string() |>
cat()
```


Expand All @@ -105,7 +109,8 @@ depiction() |>
outerglow() |>
add_title() |>
depict(many_containers) |>
get_svg_string()
get_svg_string() |>
cat()
```

## Multiple Colors
Expand All @@ -125,32 +130,33 @@ color <- J("java.awt.Color")
depiction() |>
highlight_atoms(highlight_imid, color$GREEN) |>
highlight_atoms(highlight_2, color$RED) |>
#set_size(400, 400) |>
#set_zoom(4) |>
set_zoom(2) |>
outerglow() |>
add_title() |>
depict(mol) |>
get_svg_string()
get_svg_string() |>
cat()
```

## A Larger Example


```{r, results='asis'}
# laoding a molfile
# loading a molfile
insulinmol <- system.file("molfiles/ChEBI_5931.mol", package = "depict")
insulin <- read_mol(insulinmol)
cysteine <- match_smarts("C(=O)C(CS)N", insulin)
xlinks <- match_smarts("SS", insulin)
depiction() |>
# set_size(700, 400) |>
set_zoom(0.7) |>
outerglow() |>
highlight_atoms(cysteine, color$YELLOW) |>
highlight_atoms(xlinks, color$YELLOW) |>
depict(insulin) |>
get_svg_string()
get_svg_string() |>
cat()
```

0 comments on commit 110e44b

Please sign in to comment.