Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Riricdata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
bioinfo_iric
Riricdata
Commits
b7bd5ec0
Commit
b7bd5ec0
authored
4 years ago
by
LouisGendron
Browse files
Options
Downloads
Patches
Plain Diff
structured dwnl file & annotations like pyriricdata
parent
dcb72137
No related branches found
Branches containing commit
Tags
0.76.3
Tags containing commit
1 merge request
!4
Draft: Resolve "Restructure checks and download like pyiricdata"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
R/IRICData-class.R
+38
-37
38 additions, 37 deletions
R/IRICData-class.R
with
38 additions
and
37 deletions
R/IRICData-class.R
+
38
−
37
View file @
b7bd5ec0
...
...
@@ -77,67 +77,67 @@ setMethod(
#Download file from db_id or slug_id
setGeneric
(
name
=
"
DL
_file"
,
def
=
function
(
object
,
session
,
f
ile_id
,
path_out
){
standardGeneric
(
"
DL
_file"
)
name
=
"
dwnl
_file
_content
"
,
def
=
function
(
object
,
session
,
f
older_out
,
filename
){
standardGeneric
(
"
dwnl
_file
_content
"
)
}
)
setMethod
(
f
=
"
DL
_file"
,
f
=
"
dwnl
_file
_content
"
,
signature
=
"IRICData"
,
definition
=
function
(
object
,
session
,
f
ile_id
,
path_out
)
{
definition
=
function
(
object
,
session
,
f
older_out
=
''
,
filename
=
''
)
{
# create directory output
dir.create
(
path
_out
,
showWarnings
=
FALSE
)
resp
=
rvest
::
jump_to
(
session
,
paste
(
object
@
url
,
'secure/datafiles/download'
,
file
_id
,
sep
=
'/'
))
file_name
=
unlist
(
resp
$
response
$
headers
[
grep
(
"content-disposition"
,
names
((
resp
$
response
$
headers
)))])
file_name
=
unlist
(
strsplit
(
file_name
,
"UTF-8''"
))[
2
]
file_out
=
file.path
(
path
_out
,
file_name
)
cat
(
paste
(
'Downloading'
,
file_name
,
'\n'
))
dir.create
(
folder
_out
,
showWarnings
=
FALSE
)
resp
=
rvest
::
jump_to
(
session
,
paste
(
object
@
url
,
'secure/datafiles/download'
,
file
name
,
sep
=
'/'
))
data
file_name
=
unlist
(
resp
$
response
$
headers
[
grep
(
"content-disposition"
,
names
((
resp
$
response
$
headers
)))])
data
file_name
=
unlist
(
strsplit
(
data
file_name
,
"UTF-8''"
))[
2
]
file_out
=
file.path
(
folder
_out
,
data
file_name
)
cat
(
paste
(
'Downloading'
,
data
file_name
,
'\n'
))
writeBin
(
resp
$
response
$
content
,
file_out
)
}
)
#Download file annotation as JSON from db_id or slug_id
setGeneric
(
name
=
"
DL
_file_annotation"
,
def
=
function
(
object
,
session
,
f
ile_id
,
path_out
){
standardGeneric
(
"
DL
_file_annotation"
)
name
=
"
dwnl
_file_annotation"
,
def
=
function
(
object
,
session
,
f
older_out
,
filename
){
standardGeneric
(
"
dwnl
_file_annotation"
)
}
)
setMethod
(
f
=
"
DL
_file_annotation"
,
f
=
"
dwnl
_file_annotation"
,
signature
=
"IRICData"
,
definition
=
function
(
object
,
session
,
file_id
,
path_out
)
{
# create directory output
dir.create
(
path_out
,
showWarnings
=
FALSE
)
annotations
=
get_file_annotation
(
object
,
session
,
file_id
)
file_name
=
unlist
(
resp
$
response
$
headers
[
grep
(
"content-disposition"
,
names
((
resp
$
response
$
headers
)))])
file_name
=
unlist
(
strsplit
(
file_name
,
"UTF-8''"
))[
2
]
file_out
=
file.path
(
path_out
,
file_name
)
cat
(
paste
(
'Downloading'
,
file_name
,
'\n'
))
definition
=
function
(
object
,
session
,
folder_out
=
''
,
filename
=
''
)
{
dir.create
(
folder_out
,
showWarnings
=
FALSE
)
annotations
=
get_file_annotation
(
object
,
session
,
filename
)
datafile_name
=
unlist
(
resp
$
response
$
headers
[
grep
(
"content-disposition"
,
names
((
resp
$
response
$
headers
)))])
datafile_name
=
unlist
(
strsplit
(
datafile_name
,
"UTF-8''"
))[
2
]
file_out
=
file.path
(
folder_out
,
datafile_name
)
cat
(
paste
(
'Downloading'
,
datafile_name
,
'\n'
))
writeBin
(
annotations
,
file_out
)
}
)
#Download an entire dataset
setGeneric
(
name
=
"
DL
_dataset"
,
def
=
function
(
object
,
session
,
id_dataset
,
path_out
){
standardGeneric
(
"
DL
_dataset"
)
name
=
"
dwnl
_dataset"
,
def
=
function
(
object
,
session
,
folder_out
,
datasetname
){
standardGeneric
(
"
dwnl
_dataset"
)
}
)
setMethod
(
f
=
"
DL
_dataset"
,
f
=
"
dwnl
_dataset"
,
signature
=
"IRICData"
,
definition
=
function
(
object
,
session
,
id_dataset
,
path_out
)
{
# create directory output
#Get all files of a dataset
resp
=
rvest
::
jump_to
(
session
,
paste
(
object
@
url
,
"/secure/dataset/"
,
id_dataset
,
"/file-list"
,
sep
=
""
))
definition
=
function
(
object
,
session
,
folder_out
=
''
,
datasetname
=
''
)
{
dir.create
(
folder_out
,
showWarnings
=
FALSE
)
resp
=
rvest
::
jump_to
(
session
,
paste
(
object
@
url
,
"/secure/dataset/"
,
datasetname
,
"/file-list"
,
sep
=
""
))
files_to_DL
=
unlist
(
strsplit
(
rawToChar
(
resp
$
response
$
content
),
"\n"
))
files_id
=
unique
(
unlist
(
lapply
(
files_to_DL
,
function
(
x
)
tail
(
unlist
(
strsplit
(
x
,
'/'
)),
1
))))
#DL all file in path_out
if
(
folder_out
!=
""
){
folder_out
=
file.path
(
folder_out
,
datasetname
)
}
else
{
folder_out
=
datasetname
}
for
(
id_
in
files_id
)
{
DL_file
(
object
,
session
,
id_
,
path_out
)
dwnl_file_content
(
object
,
session
,
folder_out
,
id_
)
dwnl_file_annotation
(
object
,
session
,
folder_out
,
id_
)
}
}
)
...
...
@@ -283,13 +283,13 @@ setMethod(
#Return a data.table of file_name, file_id and hash for every files in dataset
setGeneric
(
name
=
'get_dataset_
hash
'
,
name
=
'get_dataset_
filelist
'
,
def
=
function
(
object
,
session
,
dataset_id
){
standardGeneric
(
'get_dataset_
hash
'
)
standardGeneric
(
'get_dataset_
filelist
'
)
}
)
setMethod
(
f
=
'get_dataset_
hash
'
,
f
=
'get_dataset_
filelist
'
,
signature
=
'IRICData'
,
definition
=
function
(
object
,
session
,
dataset_id
){
ds_details
<-
data.table
()
...
...
@@ -307,7 +307,8 @@ setMethod(
ds_details
<-
rbind
(
ds_details
,
data.table
(
file_name
=
metas
[[
ix
]]
$
filename
,
file_id
=
files_id
[[
ix
]],
hash
=
metas
[[
ix
]]
$
hash
))
file_hash
=
metas
[[
ix
]]
$
hash
,
file_slug
=
metas
[[
ix
]]
$
iric_data_id
))
}
}
return
(
ds_details
)
...
...
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