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
439b9745
Commit
439b9745
authored
10 years ago
by
juanf
Browse files
Options
Downloads
Patches
Plain Diff
SSDM-1070 : PAPER - OPENBIS - Migrate Manage Properties YeastLab (Configurable)
SVN: 33387
parent
f1f6bdda
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plasmid/source/core-plugins/stellingmigration/1/dss/drop-boxes/stellingmigration/migration.py
+42
-30
42 additions, 30 deletions
...migration/1/dss/drop-boxes/stellingmigration/migration.py
with
42 additions
and
30 deletions
plasmid/source/core-plugins/stellingmigration/1/dss/drop-boxes/stellingmigration/migration.py
+
42
−
30
View file @
439b9745
...
...
@@ -7,32 +7,44 @@ import xml.etree.ElementTree as ET
##
## Generic Process Method
##
sampleTypes
=
[
"
GENERAL_PROTOCOL
"
,
"
MEDIA
"
,
"
PCR
"
,
"
POMBE
"
,
"
READOUT
"
,
"
RESULT
"
,
"
SOLUTIONS_BUFFERS
"
,
"
WESTERN_BLOTTING
"
,
"
YEAST
"
];
properties
=
[
"
CHEMICALS
"
,
"
SOLUTIONS_BUFFERS
"
,
"
ENZYMES
"
,
"
MEDIA
"
,
"
GENERAL_PROTOCOL
"
,
"
PLASMIDS
"
,
"
POMBE-PARENTS
"
,
"
ANNOTATIONS
"
,
"
ANTIBODIES
"
,
"
YEAST_PARENTS
"
];
definitions
=
{
"
GENERAL_PROTOCOL
"
:
{
"
CHEMICALS
"
:
{
"
quantity
"
:
"
QUANTITY
"
,
"
name
"
:
"
CHEMICAL_NAME
"
}
}
};
# sampleTypes = [
# "GENERAL_PROTOCOL",
# "MEDIA",
# "PCR",
# "POMBE",
# "READOUT",
# "RESULT",
# "SOLUTIONS_BUFFERS",
# "WESTERN_BLOTTING",
# "YEAST"];
#
# properties = [
# "CHEMICALS",
# "SOLUTIONS_BUFFERS",
# "ENZYMES",
# "MEDIA",
# "GENERAL_PROTOCOL",
# "PLASMIDS",
# "POMBE-PARENTS",
# "ANNOTATIONS",
# "ANTIBODIES",
# "YEAST_PARENTS"];
def
process
(
tr
):
print
"
START!
"
for
sampleType
in
sampleTypes
:
for
sampleType
in
definitions
:
properties
=
definitions
[
sampleType
]
samples
=
getSamplesByType
(
tr
,
sampleType
)
print
sampleType
+
"
:
"
+
str
(
len
(
samples
))
for
sample
in
samples
:
...
...
@@ -65,6 +77,7 @@ def translate(tr, sample, properties):
# Read old annotations
for
property
in
properties
:
propertyDefinitions
=
properties
[
property
]
oldAnnotationsRoot
=
None
try
:
propertyValue
=
unicode
(
sample
.
getPropertyValue
(
property
),
"
utf-8
"
)
...
...
@@ -72,9 +85,9 @@ def translate(tr, sample, properties):
oldAnnotationsRoot
=
ET
.
fromstring
(
propertyValue
)
except
Exception
:
print
"
Exception on
"
+
sample
.
code
+
"
"
+
property
if
oldAnnotationsRoot
is
not
None
:
for
child
in
oldAnnotationsRoot
:
if
property
==
"
CHEMICALS
"
:
newAnnotationsNode
=
ET
.
SubElement
(
newAnnotationsRoot
,
"
Sample
"
)
permId
=
child
.
attrib
[
"
permId
"
]
print
sample
.
code
+
"
"
+
permId
...
...
@@ -82,12 +95,11 @@ def translate(tr, sample, properties):
linkedSample
=
getSampleByPermId
(
tr
,
permId
)
newAnnotationsNode
.
attrib
[
"
identifier
"
]
=
linkedSample
.
getSampleIdentifier
()
quantity
=
getValueOrNull
(
child
.
attrib
,
"
quantity
"
)
if
(
quantity
is
not
None
):
newAnnotationsNode
.
attrib
[
"
QUANTITY
"
]
=
quantity
chemicalName
=
getValueOrNull
(
child
.
attrib
,
"
name
"
)
if
(
chemicalName
is
not
None
):
newAnnotationsNode
.
attrib
[
"
CHEMICAL_NAME
"
]
=
chemicalName
for
oldName
in
propertyDefinitions
:
newName
=
propertyDefinitions
[
oldName
]
value
=
getValueOrNull
(
child
.
attrib
,
oldName
)
if
(
value
is
not
None
):
newAnnotationsNode
.
attrib
[
newName
]
=
value
save
(
tr
,
sample
,
"
ANNOTATIONS_STATE
"
,
ET
.
tostring
(
newAnnotationsRoot
,
encoding
=
'
utf-8
'
))
def
save
(
tr
,
sample
,
property
,
propertyValue
):
...
...
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