Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simulateDCE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dj44vuri
simulateDCE
Commits
42d6ff2d
Commit
42d6ff2d
authored
10 months ago
by
dj44vuri
Browse files
Options
Downloads
Patches
Plain Diff
autodetect in readdesign
parent
fc6b1247
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
R/readdesign.R
+16
-16
16 additions, 16 deletions
R/readdesign.R
inst/extdata/spdesigns/designs/twoattr.RDS
+0
-0
0 additions, 0 deletions
inst/extdata/spdesigns/designs/twoattr.RDS
tests/testthat/test-readdesign.R
+14
-1
14 additions, 1 deletion
tests/testthat/test-readdesign.R
with
30 additions
and
17 deletions
R/readdesign.R
+
16
−
16
View file @
42d6ff2d
...
@@ -22,22 +22,22 @@
...
@@ -22,22 +22,22 @@
readdesign
<-
function
(
design
=
designfile
,
designtype
=
NULL
)
{
readdesign
<-
function
(
design
=
designfile
,
designtype
=
NULL
)
{
#
if (is.null(designtype)) {
if
(
is.null
(
designtype
))
{
#
#
#
#
# Check if the string ends with ".ngd"
# Check if the string ends with ".ngd"
#
if (grepl("\\.ngd$", designfile)) {
if
(
grepl
(
"\\.ngd$"
,
designfile
))
{
#
# Code to execute if condition is true
# Code to execute if condition is true
#
designtype = "ngene"
designtype
=
"ngene"
#
print("I guessed it is an ngene file")
print
(
"I guessed it is an ngene file"
)
#
} else {
}
else
{
#
# Code to execute if condition is false
# Code to execute if condition is false
#
designtype = "spdesign"
designtype
=
"spdesign"
#
print("I assume it is a spdesign")
print
(
"I assume it is a spdesign"
)
#
}
}
#
#
}
}
design
<-
switch
(
designtype
,
design
<-
switch
(
designtype
,
"ngene"
=
suppressWarnings
(
readr
::
read_delim
(
design
,
"ngene"
=
suppressWarnings
(
readr
::
read_delim
(
design
,
...
...
This diff is collapsed.
Click to expand it.
inst/extdata/spdesigns/designs/twoattr.RDS
LFS
+
0
−
0
View file @
42d6ff2d
No preview for this file type
This diff is collapsed.
Click to expand it.
tests/testthat/test-readdesign.R
+
14
−
1
View file @
42d6ff2d
...
@@ -15,14 +15,27 @@ test_that("all is correct", {
...
@@ -15,14 +15,27 @@ test_that("all is correct", {
expect_no_error
(
readdesign
(
design
=
design_path
,
designtype
=
"ngene"
))
expect_no_error
(
readdesign
(
design
=
design_path
,
designtype
=
"ngene"
))
})
})
# test if autodetect ngd design
test_that
(
"all is correct"
,
{
expect_no_error
(
readdesign
(
design
=
design_path
))
})
### Tests for spdesign
### Tests for spdesign
design_path
<-
system.file
(
"extdata"
,
"CSA"
,
"
design2
.RDS"
,
package
=
"simulateDCE"
)
design_path
<-
system.file
(
"extdata"
,
"CSA"
,
"
linear"
,
"BLIbay
.RDS"
,
package
=
"simulateDCE"
)
test_that
(
"all is correct"
,
{
test_that
(
"all is correct"
,
{
expect_no_error
(
readdesign
(
design
=
design_path
,
designtype
=
"spdesign"
))
expect_no_error
(
readdesign
(
design
=
design_path
,
designtype
=
"spdesign"
))
})
})
# Same Tests for spdesign, but detect automatically if it is spdesign
test_that
(
"all is correct"
,
{
expect_no_error
(
readdesign
(
design
=
design_path
))
})
## trying objects that do not work
## trying objects that do not work
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment