Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
203c2e56
Commit
203c2e56
authored
13 years ago
by
cramakri
Browse files
Options
Downloads
Patches
Plain Diff
SE-341 Improvements to handling the metabolomics data.
SVN: 21597
parent
eab56134
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
eu_basynthec/dist/etc/metabolomics/data-set-handler.py
+56
-30
56 additions, 30 deletions
eu_basynthec/dist/etc/metabolomics/data-set-handler.py
eu_basynthec/source/java/eu/basynthec/cisd/dss/TimeSeriesDataExcel.java
+6
-1
6 additions, 1 deletion
...ource/java/eu/basynthec/cisd/dss/TimeSeriesDataExcel.java
with
62 additions
and
31 deletions
eu_basynthec/dist/etc/metabolomics/data-set-handler.py
+
56
−
30
View file @
203c2e56
from
datetime
import
datetime
from
datetime
import
datetime
from
eu.basynthec.cisd.dss
import
TimeSeriesDataExcel
from
eu.basynthec.cisd.dss
import
TimeSeriesDataExcel
def
retrieve_or_create_experiment
(
tr
):
def
retrieve_or_create_experiment
(
tr
,
exp_id
):
# Create an experiment
"""
Get the specified experiment form the server, or create a new one if no experiment is specified. Return the experiment.
"""
now_str
=
datetime
.
today
().
strftime
(
'
%Y%m%d-%H%M%S
'
)
if
exp_id
is
None
:
expid
=
"
/SHARED/SHARED/
"
+
now_str
now_str
=
datetime
.
today
().
strftime
(
'
%Y%m%d
'
)
exp
=
tr
.
getExperiment
(
expid
)
exp_id
=
"
/SHARED/SHARED/
"
+
now_str
exp
=
tr
.
getExperiment
(
exp_id
)
if
None
==
exp
:
exp
=
tr
.
createNewExperiment
(
expid
,
'
BASYNTHEC
'
)
exp
.
setPropertyValue
(
"
DESCRIPTION
"
,
"
An experiment created on
"
+
now_str
)
else
:
exp
=
tr
.
getExperiment
(
exp_id
)
return
exp
if
None
==
exp
:
def
assign_properties
(
dataset
,
metadata
):
exp
=
tr
.
createNewExperiment
(
expid
,
'
BASYNTHEC
'
)
"""
Assign properties to the data set from information in the data.
"""
exp
.
setPropertyValue
(
"
DESCRIPTION
"
,
"
An experiment created on
"
+
now_str
)
propertyNameMap
=
{
"
STRAIN
"
:
"
STRAIN
"
,
"
TIMEPOINT TYPE
"
:
"
TIMEPOINT_TYPE
"
,
"
CELL LOCATION
"
:
"
CELL_LOCATION
"
,
"
VALUE TYPE
"
:
"
VALUE_TYPE
"
,
"
VALUE UNIT
"
:
"
VALUE_UNIT
"
,
"
SCALE
"
:
"
SCALE
"
}
return
exp
for
prop
in
metadata
.
keySet
():
key
=
propertyNameMap
.
get
(
prop
)
if
key
is
not
None
:
value
=
metadata
.
get
(
prop
)
if
(
key
==
"
STRAIN
"
):
value
=
value
+
"
(STRAIN)
"
dataset
.
setPropertyValue
(
key
,
value
.
upper
())
def
convert_data_to_tsv
(
tr
,
dataset
,
location
):
"""
Create a tsv file containing the data and add it to the data set.
"""
tr
.
createNewDirectory
(
dataset
,
location
)
tsvFileName
=
tr
.
createNewFile
(
dataset
,
location
,
incoming
.
getName
()
+
"
.tsv
"
)
tsv
=
open
(
tsvFileName
,
'
w
'
)
for
line
in
timeSeriesData
.
getRawDataLines
():
for
i
in
range
(
0
,
len
(
line
)
-
1
):
tsv
.
write
(
line
[
i
])
tsv
.
write
(
"
\t
"
)
tsv
.
write
(
line
[
len
(
line
)
-
1
])
tsv
.
write
(
"
\n
"
)
tsv
.
close
()
def
store_original_data
(
tr
,
dataset
,
location
):
"""
Put the original data into the data set.
"""
tr
.
createNewDirectory
(
dataset
,
location
)
tr
.
moveFile
(
incoming
.
getAbsolutePath
(),
dataset
,
location
+
"
/
"
+
incoming
.
getName
())
propertyNameMap
=
{
"
STRAIN
"
:
"
STRAIN
"
,
"
TIMEPOINT TYPE
"
:
"
TIMEPOINT_TYPE
"
,
"
CELL LOCATION
"
:
"
CELL_LOCATION
"
,
"
VALUE TYPE
"
:
"
VALUE_TYPE
"
,
"
VALUE UNIT
"
:
"
VALUE_UNIT
"
,
"
SCALE
"
:
"
SCALE
"
}
tr
=
service
.
transaction
(
incoming
)
tr
=
service
.
transaction
(
incoming
)
exp
=
retrieve_or_create_experiment
(
tr
)
timeSeriesData
=
TimeSeriesDataExcel
.
createTimeSeriesDataExcel
(
incoming
.
getAbsolutePath
())
timeSeriesData
=
TimeSeriesDataExcel
.
createTimeSeriesDataExcel
(
incoming
.
getAbsolutePath
())
# create the data set and assign the metadata from the file
# create the data set and assign the metadata from the file
data
S
et
=
tr
.
createNewDataSet
(
"
METABOLITE_INTENSITIES
"
)
data
s
et
=
tr
.
createNewDataSet
(
"
METABOLITE_INTENSITIES
"
)
metadata
=
timeSeriesData
.
getMetadataMap
()
metadata
=
timeSeriesData
.
getMetadataMap
()
assign_properties
(
dataset
,
metadata
)
# Convert the data into a tsv file, and put that and the original data into the data set
convert_data_to_tsv
(
tr
,
dataset
,
"
data/tsv
"
)
store_original_data
(
tr
,
dataset
,
"
data/xls
"
)
for
prop
in
metadata
.
keySet
():
expCode
=
metadata
.
get
(
"
EXPERIMENT
"
)
key
=
propertyNameMap
.
get
(
prop
)
exp
=
retrieve_or_create_experiment
(
tr
,
expCode
)
if
key
is
not
None
:
dataset
.
setExperiment
(
exp
)
value
=
metadata
.
get
(
prop
)
if
(
key
==
"
STRAIN
"
):
value
=
value
+
"
(STRAIN)
"
dataSet
.
setPropertyValue
(
key
,
value
.
upper
())
dataSet
.
setExperiment
(
exp
)
tr
.
moveFile
(
incoming
.
getAbsolutePath
(),
dataSet
)
This diff is collapsed.
Click to expand it.
eu_basynthec/source/java/eu/basynthec/cisd/dss/TimeSeriesDataExcel.java
+
6
−
1
View file @
203c2e56
...
@@ -133,7 +133,12 @@ public class TimeSeriesDataExcel
...
@@ -133,7 +133,12 @@ public class TimeSeriesDataExcel
for
(
int
i
=
1
;
i
<
metadataLines
.
size
();
++
i
)
for
(
int
i
=
1
;
i
<
metadataLines
.
size
();
++
i
)
{
{
String
[]
line
=
metadataLines
.
get
(
i
);
String
[]
line
=
metadataLines
.
get
(
i
);
metadataMap
.
put
(
line
[
0
].
toUpperCase
(),
line
[
1
]);
String
value
=
line
[
1
];
if
(
"BLANK"
.
equals
(
value
))
{
value
=
null
;
}
metadataMap
.
put
(
line
[
0
].
toUpperCase
(),
value
);
}
}
return
metadataMap
;
return
metadataMap
;
...
...
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