Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
notebook
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
UNLOCK
notebook
Commits
e25e2ad7
Commit
e25e2ad7
authored
4 years ago
by
Bart
Browse files
Options
Downloads
Patches
Plain Diff
small fixes
parent
24f13880
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
notebooks/samsa2-prepare.ipynb
+14
-69
14 additions, 69 deletions
notebooks/samsa2-prepare.ipynb
with
14 additions
and
69 deletions
notebooks/samsa2-prepare.ipynb
+
14
−
69
View file @
e25e2ad7
{
{
"cells": [
"cells": [
{
"cell_type": "markdown",
"id": "seven-dairy",
"metadata": {},
"source": [
"# Retrieve SAMSA2 Output Files"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "lasting-asset",
"metadata": {},
"outputs": [],
"source": [
"# Dependencies\n",
"import os\n",
"import logging\n",
"from irods.models import DataObject, DataObjectMeta, Collection, CollectionMeta\n",
"from irods.column import Criterion\n",
"import getpass\n",
"from shutil import copyfileobj\n",
"import pathlib\n"
]
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 21,
"execution_count": 21,
"id": "
private-proposal
",
"id": "
unique-creek
",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -47,7 +22,7 @@
...
@@ -47,7 +22,7 @@
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": null,
"execution_count": null,
"id": "
informal-albert
",
"id": "
shaped-perry
",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -56,25 +31,10 @@
...
@@ -56,25 +31,10 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
3
,
"execution_count":
null
,
"id": "
pacific-peter
",
"id": "
formed-parliament
",
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"Username\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
" nijsse\n"
]
}
],
"source": [
"source": [
"print(\"Username\")\n",
"print(\"Username\")\n",
"username=input()"
"username=input()"
...
@@ -82,25 +42,10 @@
...
@@ -82,25 +42,10 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
4
,
"execution_count":
null
,
"id": "
minus-stuff
",
"id": "
turkish-probe
",
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"Password\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
" ············\n"
]
}
],
"source": [
"source": [
"print(\"Password\")\n",
"print(\"Password\")\n",
"password = getpass.getpass()"
"password = getpass.getpass()"
...
@@ -109,7 +54,7 @@
...
@@ -109,7 +54,7 @@
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 22,
"execution_count": 22,
"id": "
functioning-climb
",
"id": "
standing-shannon
",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -142,15 +87,15 @@
...
@@ -142,15 +87,15 @@
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 23,
"execution_count": 23,
"id": "
tested-detector
",
"id": "
analyzed-wheat
",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"# Set the study\n",
"# Set the study\n",
"\n",
"\n",
"project = \"P_
Deltares
\"\n",
"project = \"P_
UNLOCK
\"\n",
"investigation = \"I_
vitens
\"\n",
"investigation = \"I_
INVESTIGATION_TEST
\"\n",
"study = \"S_
ground_surface_water
\"\n",
"study = \"S_
TEST_STUDY
\"\n",
"\n",
"\n",
"studyPath = \"/unlock/projects/\"+project+\"/\"+investigation+\"/\"+study"
"studyPath = \"/unlock/projects/\"+project+\"/\"+investigation+\"/\"+study"
]
]
...
@@ -158,7 +103,7 @@
...
@@ -158,7 +103,7 @@
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 42,
"execution_count": 42,
"id": "
excessive-injur
y",
"id": "
overall-possibilit
y",
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
...
%% Cell type:markdown id:seven-dairy tags:
%% Cell type:code id:unique-creek tags:
# Retrieve SAMSA2 Output Files
%% Cell type:code id:lasting-asset tags:
```
python
# Dependencies
import
os
import
logging
from
irods.models
import
DataObject
,
DataObjectMeta
,
Collection
,
CollectionMeta
from
irods.column
import
Criterion
import
getpass
from
shutil
import
copyfileobj
import
pathlib
```
%% Cell type:code id:private-proposal tags:
```
python
```
python
# Generic functions
# Generic functions
LOGGING_FORMAT
=
'
[%(asctime)-15s][%(levelname)-7s] %(message)s
'
LOGGING_FORMAT
=
'
[%(asctime)-15s][%(levelname)-7s] %(message)s
'
def
get_logger
(
name
):
def
get_logger
(
name
):
logging
.
basicConfig
(
format
=
LOGGING_FORMAT
)
logging
.
basicConfig
(
format
=
LOGGING_FORMAT
)
logger
=
logging
.
getLogger
(
name
)
logger
=
logging
.
getLogger
(
name
)
logger
.
setLevel
(
'
DEBUG
'
)
logger
.
setLevel
(
'
DEBUG
'
)
return
logger
return
logger
logger
=
get_logger
(
"
jupyter
"
)
logger
=
get_logger
(
"
jupyter
"
)
```
```
%% Cell type:code id:
informal-albert
tags:
%% Cell type:code id:
shaped-perry
tags:
```
python
```
python
# iRODS authentication
# iRODS authentication
```
```
%% Cell type:code id:
pacific-peter
tags:
%% Cell type:code id:
formed-parliament
tags:
```
python
```
python
print
(
"
Username
"
)
print
(
"
Username
"
)
username
=
input
()
username
=
input
()
```
```
%% Output
%% Cell type:code id:turkish-probe tags:
Username
nijsse
%% Cell type:code id:minus-stuff tags:
```
python
```
python
print
(
"
Password
"
)
print
(
"
Password
"
)
password
=
getpass
.
getpass
()
password
=
getpass
.
getpass
()
```
```
%% Output
%% Cell type:code id:standing-shannon tags:
Password
············
%% Cell type:code id:functioning-climb tags:
```
python
```
python
from
irods.session
import
iRODSSession
from
irods.session
import
iRODSSession
import
ssl
import
ssl
# iRODS authentication information
# iRODS authentication information
host
=
"
unlock-icat.irods.surfsara.nl
"
host
=
"
unlock-icat.irods.surfsara.nl
"
port
=
"
1247
"
port
=
"
1247
"
zone
=
"
unlock
"
zone
=
"
unlock
"
context
=
ssl
.
create_default_context
(
purpose
=
ssl
.
Purpose
.
SERVER_AUTH
,
cafile
=
None
,
capath
=
None
,
cadata
=
None
)
context
=
ssl
.
create_default_context
(
purpose
=
ssl
.
Purpose
.
SERVER_AUTH
,
cafile
=
None
,
capath
=
None
,
cadata
=
None
)
ssl_settings
=
{
'
irods_client_server_negotiation
'
:
'
request_server_negotiation
'
,
ssl_settings
=
{
'
irods_client_server_negotiation
'
:
'
request_server_negotiation
'
,
'
irods_client_server_policy
'
:
'
CS_NEG_REQUIRE
'
,
'
irods_client_server_policy
'
:
'
CS_NEG_REQUIRE
'
,
'
irods_encryption_algorithm
'
:
'
AES-256-CBC
'
,
'
irods_encryption_algorithm
'
:
'
AES-256-CBC
'
,
'
irods_encryption_key_size
'
:
32
,
'
irods_encryption_key_size
'
:
32
,
'
irods_encryption_num_hash_rounds
'
:
16
,
'
irods_encryption_num_hash_rounds
'
:
16
,
'
irods_encryption_salt_size
'
:
8
,
'
irods_encryption_salt_size
'
:
8
,
'
ssl_context
'
:
context
}
'
ssl_context
'
:
context
}
session
=
iRODSSession
(
host
=
host
,
session
=
iRODSSession
(
host
=
host
,
port
=
port
,
port
=
port
,
user
=
username
,
user
=
username
,
password
=
password
,
password
=
password
,
zone
=
zone
,
zone
=
zone
,
**
ssl_settings
)
**
ssl_settings
)
```
```
%% Cell type:code id:
tested-detector
tags:
%% Cell type:code id:
analyzed-wheat
tags:
```
python
```
python
# Set the study
# Set the study
project
=
"
P_
Deltares
"
project
=
"
P_
UNLOCK
"
investigation
=
"
I_
vitens
"
investigation
=
"
I_
INVESTIGATION_TEST
"
study
=
"
S_
ground_surface_water
"
study
=
"
S_
TEST_STUDY
"
studyPath
=
"
/unlock/projects/
"
+
project
+
"
/
"
+
investigation
+
"
/
"
+
study
studyPath
=
"
/unlock/projects/
"
+
project
+
"
/
"
+
investigation
+
"
/
"
+
study
```
```
%% Cell type:code id:
excessive-injur
y tags:
%% Cell type:code id:
overall-possibilit
y tags:
```
python
```
python
# Obtain all SAMSA2 files for a given study
# Obtain all SAMSA2 files for a given study
logger
.
info
(
"
Started collecting SAMSA2 output files
"
)
logger
.
info
(
"
Started collecting SAMSA2 output files
"
)
types
=
[
'
function
'
,
'
organism
'
]
types
=
[
'
function
'
,
'
organism
'
]
for
type
in
types
:
for
type
in
types
:
org_results
=
session
.
query
(
Collection
,
DataObject
).
filter
(
\
org_results
=
session
.
query
(
Collection
,
DataObject
).
filter
(
\
Criterion
(
'
like
'
,
DataObject
.
path
,
"
%_
"
+
type
+
"
.tsv
"
)).
filter
(
\
Criterion
(
'
like
'
,
DataObject
.
path
,
"
%_
"
+
type
+
"
.tsv
"
)).
filter
(
\
Criterion
(
'
like
'
,
Collection
.
name
,
studyPath
+
"
/%
"
))
Criterion
(
'
like
'
,
Collection
.
name
,
studyPath
+
"
/%
"
))
# create output folders
# create output folders
output_dir
=
"
./data/
"
+
project
+
"
/
"
+
investigation
+
"
/
"
+
study
+
"
/samsa2_
"
+
type
+
"
/
"
output_dir
=
"
./data/
"
+
project
+
"
/
"
+
investigation
+
"
/
"
+
study
+
"
/samsa2_
"
+
type
+
"
/
"
pathlib
.
Path
(
output_dir
).
mkdir
(
parents
=
True
,
exist_ok
=
True
)
pathlib
.
Path
(
output_dir
).
mkdir
(
parents
=
True
,
exist_ok
=
True
)
# Obtaining all files
# Obtaining all files
index
=
0
index
=
0
for
index
,
r
in
enumerate
(
org_results
):
for
index
,
r
in
enumerate
(
org_results
):
irods_filepath
=
r
.
get
(
Collection
.
name
)
+
"
/
"
+
r
.
get
(
DataObject
.
name
)
irods_filepath
=
r
.
get
(
Collection
.
name
)
+
"
/
"
+
r
.
get
(
DataObject
.
name
)
obj
=
session
.
data_objects
.
get
(
irods_filepath
)
obj
=
session
.
data_objects
.
get
(
irods_filepath
)
output_file
=
output_dir
+
"
/
"
+
r
.
get
(
DataObject
.
name
)
output_file
=
output_dir
+
"
/
"
+
r
.
get
(
DataObject
.
name
)
with
open
(
output_file
,
'
wb
'
)
as
output
,
obj
.
open
(
'
r+
'
)
as
input
:
with
open
(
output_file
,
'
wb
'
)
as
output
,
obj
.
open
(
'
r+
'
)
as
input
:
copyfileobj
(
input
,
output
)
copyfileobj
(
input
,
output
)
logger
.
info
(
"
\n
Obtained
"
+
str
(
index
)
+
"
SAMSA2
"
+
type
+
"
files from study
"
+
study
+
"
\n
Files can be found here:
"
+
output_dir
)
logger
.
info
(
"
\n
Obtained
"
+
str
(
index
)
+
"
SAMSA2
"
+
type
+
"
files from study
"
+
study
+
"
\n
Files can be found here:
"
+
output_dir
)
```
```
%% Output
%% Output
[2021-03-31 15:07:48,336][INFO ] Started collecting SAMSA2 output files
[2021-03-31 15:07:48,336][INFO ] Started collecting SAMSA2 output files
[2021-03-31 15:08:22,388][INFO ]
[2021-03-31 15:08:22,388][INFO ]
Obtained 27 SAMSA2 function files from study S_ground_surface_water
Obtained 27 SAMSA2 function files from study S_ground_surface_water
Files can be found here: ./data/P_Deltares/I_vitens/S_ground_surface_water/samsa2_function/
Files can be found here: ./data/P_Deltares/I_vitens/S_ground_surface_water/samsa2_function/
[2021-03-31 15:08:45,119][INFO ]
[2021-03-31 15:08:45,119][INFO ]
Obtained 27 SAMSA2 organism files from study S_ground_surface_water
Obtained 27 SAMSA2 organism files from study S_ground_surface_water
Files can be found here: ./data/P_Deltares/I_vitens/S_ground_surface_water/samsa2_organism/
Files can be found here: ./data/P_Deltares/I_vitens/S_ground_surface_water/samsa2_organism/
...
...
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