Skip to content

new package Rscape-2.0.0-k #5344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 149 additions & 0 deletions R/Rscape/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder, BinaryBuilderBase, Pkg

name = "Rscape"
upstream_version = "2.0.0.k"
version = VersionNumber(replace(upstream_version, r"([0-9]+\.[0-9]+\.[0-9]+).*" => s"\1"))

# Collection of sources required to complete build
sources = [
ArchiveSource("http://rivaslab.org/software/rscape/rscape_v$(upstream_version).tar.gz",
"b4d76d7e4d875564ba5b97c9e96a9a1ef2c1fd7a5ad390850b04fd5eb7efc8b9"),
DirectorySource("./bundled")
]

# TODO
# - R-scape complains about missing gnuplot at runtime, probably
# needed for some plots, but works nonetheless

# Bash recipe for building across all platforms
# Notes
# - configure mentions --with-gsl, but the build fails with linking
# errors using this option (probably -lgsl is missing). Neither this
# configure option nor GSL are mentioned in the manual, so hopefully
# GSL isn't needed. I think the flag comes from HMMER, but it seems
# like the functions that are used from HMMER don't need GSL.
script = raw"""
cd $WORKSPACE/srcdir/rscape*/

# allow using the RSCAPE_HOME, RSCAPE_BIN, RSCAPE_SHARE environment
# variables to override default directories for finding data params at
# runtime instead of a hardcoded path (which doesn't work because that
# is set to the srcdir during build)
#
# first convert src/msatree.c to LF line endings (from CRLF),
# otherwise the patch doesn't apply
cp src/msatree.c src/msatree.c.bak
tr -d '\015' < src/msatree.c.bak > src/msatree.c
#
# now apply the patch
atomic_patch -p1 ../patches/allow-env-var-override-of-dirs.patch

update_configure_scripts
./configure \
--prefix=${prefix} --build=${MACHTYPE} --host=${target}

make -j${nproc}
make install

# install data params
for f in data/power/*; do
install -Dvm 755 "${f}" "${prefix}/${f}"
done

cp ./lib/R2R/R2R-current/r2r-license-text.txt r2r-license-text.txt
cp ./lib/R2R/R2R-current/NotByZasha/nlopt-*/src/algs/direct/COPYING COPYING-nlopt-direct
cp ./lib/R2R/R2R-current/NotByZasha/nlopt-*/COPYING COPYING-nlopt
cp ./lib/hmmer/libdivsufsort/COPYING COPYING-libdivsufsort
cp ./lib/hmmer/easel/LICENSE LICENSE-easel
cp ./lib/hmmer/LICENSE LICENSE-hmmer
cp ./lib/infernal/infernal-current/LICENSE LICENSE-infernal

# Note: Rscape manual says it is GPLv3, LICENSE says it is BSD
echo \"""
The R-scape manual (documentation/R-scape_userguide.pdf) says it is
licensed under GPLv3:

R-scape is licensed and freely distributed under the GNU General
Public License version 3 (GPLv3). For a copy of the License, see
http://www.gnu.org/licenses/.
\""" > LICENSE-Rscape-note-GPLv3

# Note: license file for R-view is missing, it claims to be GPLv3 but
# doesn't contain a full copy of the license.
echo \"""
The source code for R-view doesn't include a license file, and the only note in the
source code is in lib/R-view/src/rview_config.h which says it is GPLv3.
This gets printed as a banner when running the R-view program. The banner is:

# R-view :: R-view - basepairs(RNA) and contacts(RNA/peptides) from a pdb file
# R-view 0.1 (August 2018)
# Copyright (C) 2018 Howard Hughes Medical Institute.
# Freely distributed under the GNU General Public License (GPLv3).
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\""" > R-view-banner

# Note: license for FastTree only found in source code
head -n 42 lib/FastTree/src/FastTree.c > LICENSE-FastTree

# Note: no license for rnaview given in tarball
echo \"""
No explicit license in the lib/RNAVIEW directory.

In the Gentoo package repositories it is listed as public-domain:

https://packages.gentoo.org/packages/sci-biology/rnaview
\""" > LICENSE-rnaview

install_license LICENSE
install_license LICENSE-Rscape-note-GPLv3
install_license r2r-license-text.txt
install_license COPYING-nlopt-direct
install_license COPYING-nlopt
install_license COPYING-libdivsufsort
install_license LICENSE-easel
install_license LICENSE-hmmer
install_license LICENSE-infernal
install_license R-view-banner
install_license LICENSE-FastTree
install_license LICENSE-rnaview
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
# Notes:
# - configure demands either sse (i686/x86_64) or vmx (powerpc) vector
# instructions (this comes from HMMER)
# - windows compile fails (see HMMER build, but here also in the lib/R2R subdir)
# - compile fails on powerpc64le:
# "HMMER3 Altivec/VMX only supports bigendian platforms: e.g. ppc64 not ppc64le"
platforms = supported_platforms(; exclude = p -> Sys.iswindows(p) || proc_family(p) != "intel")
platforms = expand_cxxstring_abis(platforms)

# The products that we will ensure are always built
products = [
ExecutableProduct("appcov", :appcov),
ExecutableProduct("esl-afetch", :esl_afetch),
ExecutableProduct("esl-reformat", :esl_reformat),
ExecutableProduct("FastTree", :FastTree),
ExecutableProduct("msafilter", :msafilter),
ExecutableProduct("r2r", :r2r),
ExecutableProduct("rnaview", :rnaview),
ExecutableProduct("R-scape", :R_scape),
ExecutableProduct("R-scape-sim", :R_scape_sim),
ExecutableProduct("R-scape-sim-nobps", :R_scape_sim_nobps),
ExecutableProduct("R-view", :R_view),
# perl scripts
FileProduct("bin/pdb_parse.pl", :pdb_parse_pl),
FileProduct("bin/r2r_msa_comply.pl", :r2r_msa_comply_pl),
FileProduct("bin/SelectSubFamilyFromStockholm.pl", :SelectSubFamilyFromStockholm_pl),
]

# Dependencies that must be installed before this package can be built
dependencies = Dependency[
]

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies;
julia_compat="1.6")
229 changes: 229 additions & 0 deletions R/Rscape/bundled/patches/allow-env-var-override-of-dirs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
diff --git a/src/R-scape-sim.c b/src/R-scape-sim.c
index fd33547..10004e0 100644
--- a/src/R-scape-sim.c
+++ b/src/R-scape-sim.c
@@ -373,12 +373,17 @@ static int process_commandline(int argc, char **argv, ESL_GETOPTS **ret_go, stru

/* the evo paramfile */
cfg.paramfile = NULL;
+
+ // override default RSCAPE_SHARE with environment variable if it is set
+ char *env_rscape_share = getenv("RSCAPE_SHARE");
+ char *rscape_share = env_rscape_share ? env_rscape_share : RSCAPE_SHARE;
+
if ( esl_opt_IsOn(go, "--evofile") ) { cfg.paramfile = esl_opt_GetString(go, "--evofile"); }
- else if (RSCAPE_SHARE) {
+ else if (rscape_share) {
if (cfg.evomodel == AIF)
- esl_sprintf(&cfg.paramfile, "%s/doc/Pfam.seed.S1000.trainGD.AIF.param", RSCAPE_SHARE);
+ esl_sprintf(&cfg.paramfile, "%s/doc/Pfam.seed.S1000.trainGD.AIF.param", rscape_share);
else if (cfg.evomodel == AFG)
- esl_sprintf(&cfg.paramfile, "%s/doc/Pfam.seed.S1000.trainGD.AFG.param", RSCAPE_SHARE);
+ esl_sprintf(&cfg.paramfile, "%s/doc/Pfam.seed.S1000.trainGD.AFG.param", rscape_share);
else esl_fatal("could not identify evomodel");
}
else ESL_XFAIL(status, cfg.errbuf, "Failed to find evo parameters\n");
@@ -533,11 +538,15 @@ create_subsmodel(ESL_GETOPTS *go, struct cfg_s *cfg)

if (cfg->abc == NULL) esl_fatal("cannot create evolutionary model w/o an alphabet");

+ // override default RSCAPE_SHARE with environment variable if it is set
+ char *env_rscape_share = getenv("RSCAPE_SHARE");
+ char *rscape_share = env_rscape_share ? env_rscape_share : RSCAPE_SHARE;
+
switch(cfg->abc->type) {
case eslDNA:
case eslRNA:
if ( esl_opt_IsOn(go, "--ribofile") ) { cfg->ribofile = esl_opt_GetString(go, "--ribofile"); }
- else if (RSCAPE_SHARE) esl_sprintf(&cfg->ribofile, "%s/doc/ssu-lsu.final.er.ribosum", RSCAPE_SHARE);
+ else if (rscape_share) esl_sprintf(&cfg->ribofile, "%s/doc/ssu-lsu.final.er.ribosum", rscape_share);
else ESL_XFAIL(status, cfg->errbuf, "Failed to find ribosum matrices\n");

/* if RNA/DNA, calculate ribosum mtx */
diff --git a/src/R-scape.c b/src/R-scape.c
index ee236c5..c6865a8 100644
--- a/src/R-scape.c
+++ b/src/R-scape.c
@@ -951,15 +951,18 @@ static int process_commandline(int argc, char **argv, ESL_GETOPTS **ret_go, stru
cfg.powerhis = power_Histogram_Create(0.0, 10000, 1.0);
}
else { // read the power file
+ // override default RSCAPE_HOME with environment variable if it is set
+ char *env_rscape_home = getenv("RSCAPE_HOME");
+ char *rscape_home = env_rscape_home ? env_rscape_home : RSCAPE_HOME;
if (cfg.power_includegaps) {
- if (cfg.powerdouble) esl_sprintf(&cfg.powerfile, "%s/data/power/R-scape.power.double.withgaps.csv", RSCAPE_HOME);
- else if (cfg.powerjoin) esl_sprintf(&cfg.powerfile, "%s/data/power/R-scape.power.join.withgaps.csv", RSCAPE_HOME);
- else esl_sprintf(&cfg.powerfile, "%s/data/power/R-scape.power.subs.withgaps.csv", RSCAPE_HOME);
+ if (cfg.powerdouble) esl_sprintf(&cfg.powerfile, "%s/data/power/R-scape.power.double.withgaps.csv", rscape_home);
+ else if (cfg.powerjoin) esl_sprintf(&cfg.powerfile, "%s/data/power/R-scape.power.join.withgaps.csv", rscape_home);
+ else esl_sprintf(&cfg.powerfile, "%s/data/power/R-scape.power.subs.withgaps.csv", rscape_home);
}
else {
- if (cfg.powerdouble) esl_sprintf(&cfg.powerfile, "%s/data/power/R-scape.power.double.csv", RSCAPE_HOME);
- else if (cfg.powerjoin) esl_sprintf(&cfg.powerfile, "%s/data/power/R-scape.power.join.csv", RSCAPE_HOME);
- else esl_sprintf(&cfg.powerfile, "%s/data/power/R-scape.power.subs.csv", RSCAPE_HOME);
+ if (cfg.powerdouble) esl_sprintf(&cfg.powerfile, "%s/data/power/R-scape.power.double.csv", rscape_home);
+ else if (cfg.powerjoin) esl_sprintf(&cfg.powerfile, "%s/data/power/R-scape.power.join.csv", rscape_home);
+ else esl_sprintf(&cfg.powerfile, "%s/data/power/R-scape.power.subs.csv", rscape_home);
}
power_Read(cfg.powerfile, cfg.powerdouble, cfg.powerjoin, cfg.power_includegaps, &cfg.power, cfg.errbuf, cfg.verbose);
}
diff --git a/src/contactmap.c b/src/contactmap.c
index ba0e1c4..da140df 100644
--- a/src/contactmap.c
+++ b/src/contactmap.c
@@ -215,34 +215,37 @@ ContactMap_FromPDB(char *pdbfile, char *pdbchain, char *msafile, ESL_MSA *msa, i
fclose(tmpfp);

// read the contact from the pdbfile (small output -S)
- if (RSCAPE_BIN) esl_sprintf(&cmd, "%s/pdb_parse.pl", RSCAPE_BIN);
+ // override default RSCAPE_BIN with environment variable if it is set
+ char *env_rscape_bin = getenv("RSCAPE_BIN");
+ char *rscape_bin = env_rscape_bin ? env_rscape_bin : RSCAPE_BIN;
+ if (rscape_bin) esl_sprintf(&cmd, "%s/pdb_parse.pl", rscape_bin);
else ESL_XFAIL(status, errbuf, "Failed to find program pdb_parse.pl\n");

if (abcisRNA) {// run rnaview as well
if (pdbchain) {
if (noss)
esl_sprintf(&args, "%s -N -c %s -D %f -L %d -W MIN -C %s -M %s -R -S %s %s %s &> /dev/null",
- cmd, pdbchain, cntmaxD, cntmind, tmpmapfile, tmpcfile, pdbfile, msafile, RSCAPE_BIN);
+ cmd, pdbchain, cntmaxD, cntmind, tmpmapfile, tmpcfile, pdbfile, msafile, rscape_bin);
else
esl_sprintf(&args, "%s -c %s -D %f -L %d -W MIN -C %s -M %s -R -S %s %s %s &> /dev/null",
- cmd, pdbchain, cntmaxD, cntmind, tmpmapfile, tmpcfile, pdbfile, msafile, RSCAPE_BIN);
+ cmd, pdbchain, cntmaxD, cntmind, tmpmapfile, tmpcfile, pdbfile, msafile, rscape_bin);
}
else {
if (noss)
esl_sprintf(&args, "%s -N -D %f -L %d -W MIN -C %s -M %s -R -S %s %s %s &> /dev/null",
- cmd, cntmaxD, cntmind, tmpmapfile, tmpcfile, pdbfile, msafile, RSCAPE_BIN);
+ cmd, cntmaxD, cntmind, tmpmapfile, tmpcfile, pdbfile, msafile, rscape_bin);
else
esl_sprintf(&args, "%s -D %f -L %d -W MIN -C %s -M %s -R -S %s %s %s &> /dev/null",
- cmd, cntmaxD, cntmind, tmpmapfile, tmpcfile, pdbfile, msafile, RSCAPE_BIN);
+ cmd, cntmaxD, cntmind, tmpmapfile, tmpcfile, pdbfile, msafile, rscape_bin);
}
}
else {
if (noss)
esl_sprintf(&args, "%s -N -D %f -L %d -W MIN -C %s -M %s -S %s %s %s &> /dev/null",
- cmd, cntmaxD, cntmind, tmpmapfile, tmpcfile, pdbfile, msafile, RSCAPE_BIN);
+ cmd, cntmaxD, cntmind, tmpmapfile, tmpcfile, pdbfile, msafile, rscape_bin);
else
esl_sprintf(&args, "%s -D %f -L %d -W MIN -C %s -M %s -S %s %s %s &> /dev/null",
- cmd, cntmaxD, cntmind, tmpmapfile, tmpcfile, pdbfile, msafile, RSCAPE_BIN);
+ cmd, cntmaxD, cntmind, tmpmapfile, tmpcfile, pdbfile, msafile, rscape_bin);
}

if (1||verbose) printf("%s\n", args);
diff --git a/src/msatree.c b/src/msatree.c
index a5e268e..b2691ba 100644
--- a/src/msatree.c
+++ b/src/msatree.c
@@ -122,8 +122,11 @@ Tree_CreateExtFile(const ESL_MSA *msa, char **ret_treefile, char *errbuf, int ve
if ((status = esl_msafile_Write(msafp, (ESL_MSA *)msa, eslMSAFILE_AFA)) != eslOK) ESL_XFAIL(status, errbuf, "Failed to write AFA file\n");
fclose(msafp);

- if (RSCAPE_BIN) // look for the installed executable
- esl_sprintf(&cmd, "%s/FastTree", RSCAPE_BIN);
+ // override default RSCAPE_BIN with environment variable if it is set
+ char *env_rscape_bin = getenv("RSCAPE_BIN");
+ char *rscape_bin = env_rscape_bin ? env_rscape_bin : RSCAPE_BIN;
+ if (rscape_bin) // look for the installed executable
+ esl_sprintf(&cmd, "%s/FastTree", rscape_bin);
else
ESL_XFAIL(status, errbuf, "Failed to find FASTTREE executable\n");

diff --git a/src/r2rdepict.c b/src/r2rdepict.c
index b920439..ea3a9ba 100644
--- a/src/r2rdepict.c
+++ b/src/r2rdepict.c
@@ -92,7 +92,10 @@ r2r_Depict(ESL_RANDOMNESS *r, char *r2rfile, int r2rall, ESL_MSA *omsa, CTLIST *

// we need to modify a perfectly valid stockholm formatted msa into
// the weirdness that R2R accepts
- esl_sprintf(&args, "%s/r2r_msa_comply.pl %s", RSCAPE_BIN, r2rfile);
+ // override default RSCAPE_BIN with environment variable if it is set
+ char *env_rscape_bin = getenv("RSCAPE_BIN");
+ char *rscape_bin = env_rscape_bin ? env_rscape_bin : RSCAPE_BIN;
+ esl_sprintf(&args, "%s/r2r_msa_comply.pl %s", rscape_bin, r2rfile);
status = system(args);
if (status == -1) ESL_XFAIL(status, errbuf, "Failed to run r2r_msa_comply\n");

@@ -572,8 +575,11 @@ r2r_depict_pdf(char *r2rfile, char *metafile, int verbose, char *errbuf)
int status;

/* produce the R2R pdf */
- if (RSCAPE_BIN) // look for the installed executable
- esl_sprintf(&cmd, "%s/r2r --disable-usage-warning", RSCAPE_BIN);
+ // override default RSCAPE_BIN with environment variable if it is set
+ char *env_rscape_bin = getenv("RSCAPE_BIN");
+ char *rscape_bin = env_rscape_bin ? env_rscape_bin : RSCAPE_BIN;
+ if (rscape_bin) // look for the installed executable
+ esl_sprintf(&cmd, "%s/r2r --disable-usage-warning", rscape_bin);
else
ESL_XFAIL(status, errbuf, "Failed to find R2R executable\n");

@@ -606,8 +612,11 @@ r2r_depict_svg(char *r2rfile, char *metafile, int verbose, char *errbuf)
int status;

/* produce the R2R svg */
- if (RSCAPE_BIN) // look for the installed executable
- esl_sprintf(&cmd, "%s/r2r --disable-usage-warning", RSCAPE_BIN);
+ // override default RSCAPE_BIN with environment variable if it is set
+ char *env_rscape_bin = getenv("RSCAPE_BIN");
+ char *rscape_bin = env_rscape_bin ? env_rscape_bin : RSCAPE_BIN;
+ if (rscape_bin) // look for the installed executable
+ esl_sprintf(&cmd, "%s/r2r --disable-usage-warning", rscape_bin);
else
ESL_XFAIL(status, errbuf, "Failed to find R2R executable\n");

@@ -797,6 +806,10 @@ r2r_pseudoknot_callout(char *r2rfile, HITLIST *hitlist, int nct, char **r2rpkfil

if (nct == 1) return eslOK;

+ // override default RSCAPE_BIN with environment variable if it is set
+ char *env_rscape_bin = getenv("RSCAPE_BIN");
+ char *rscape_bin = env_rscape_bin ? env_rscape_bin : RSCAPE_BIN;
+
// run script to extract individual msa files for each pseudoknot
//
// (1) run script to extract the individual msa in files
@@ -806,15 +819,15 @@ r2r_pseudoknot_callout(char *r2rfile, HITLIST *hitlist, int nct, char **r2rpkfil
//
for (s = 1; s < nct; s ++) {
if (!r2rpkfile[s]) continue;
-
- esl_sprintf(&cmd, "%s/SelectSubFamilyFromStockholm.pl", RSCAPE_BIN);
+
+ esl_sprintf(&cmd, "%s/SelectSubFamilyFromStockholm.pl", rscape_bin);
esl_sprintf(&args, "%s %s pknot%d > %s", cmd, r2rfile, s, r2rpkfile[s]);
status = system(args);
if (status == -1) ESL_XFAIL(status, errbuf, "Failed to run R2R script SelectSubFamilyFromStockholm.pl\n");
free(args); args = NULL;

// now again run the script to modify a perfectly good stockholm file into something that R2R can digest
- esl_sprintf(&args, "%s/r2r_msa_comply.pl %s", RSCAPE_BIN, r2rpkfile[s]);
+ esl_sprintf(&args, "%s/r2r_msa_comply.pl %s", rscape_bin, r2rpkfile[s]);
status = system(args);
if (status == -1) ESL_XFAIL(status, errbuf, "Failed to run r2r_msa_comply\n");
free(cmd); cmd = NULL;
@@ -837,9 +850,13 @@ r2r_run_consensus_from_file(char *inmsafile, char *outmsafile, char *errbuf)
char *cmd = NULL;
char *args = NULL;
int status;
-
- if (RSCAPE_BIN) // look for the installed executable
- esl_sprintf(&cmd, "%s/r2r --cutEmptyLines", RSCAPE_BIN);
+
+ // override default RSCAPE_BIN with environment variable if it is set
+ char *env_rscape_bin = getenv("RSCAPE_BIN");
+ char *rscape_bin = env_rscape_bin ? env_rscape_bin : RSCAPE_BIN;
+
+ if (rscape_bin) // look for the installed executable
+ esl_sprintf(&cmd, "%s/r2r --cutEmptyLines", rscape_bin);
else
ESL_XFAIL(status, errbuf, "Failed to find R2R executable\n");