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
ba29d385
Commit
ba29d385
authored
6 years ago
by
Swen Vermeul
Browse files
Options
Downloads
Patches
Plain Diff
search samples with identifier added
parent
d04ff276
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
pybis/src/python/pybis/pybis.py
+22
-7
22 additions, 7 deletions
pybis/src/python/pybis/pybis.py
with
22 additions
and
7 deletions
pybis/src/python/pybis/pybis.py
+
22
−
7
View file @
ba29d385
...
@@ -121,6 +121,7 @@ def get_attrs_for_entity(entity):
...
@@ -121,6 +121,7 @@ def get_attrs_for_entity(entity):
def
_type_for_id
(
ident
,
entity
):
def
_type_for_id
(
ident
,
entity
):
ident
=
ident
.
strip
()
"""
Returns the data type for a given identifier/permId for use with the API call, e.g.
"""
Returns the data type for a given identifier/permId for use with the API call, e.g.
{
{
"
identifier
"
:
"
/DEFAULT/SAMPLE_NAME
"
,
"
identifier
"
:
"
/DEFAULT/SAMPLE_NAME
"
,
...
@@ -161,6 +162,9 @@ def _type_for_id(ident, entity):
...
@@ -161,6 +162,9 @@ def _type_for_id(ident, entity):
entity_capitalize
=
entity
.
capitalize
()
entity_capitalize
=
entity
.
capitalize
()
if
is_identifier
(
ident
):
if
is_identifier
(
ident
):
# people tend to omit the / prefix of an identifier...
if
not
ident
.
startswith
(
'
/
'
):
ident
=
'
/
'
+
ident
search_request
=
{
search_request
=
{
"
identifier
"
:
ident
.
upper
(),
"
identifier
"
:
ident
.
upper
(),
"
@type
"
:
"
as.dto.{}.id.{}Identifier
"
.
format
(
entity
.
lower
(),
entity_capitalize
)
"
@type
"
:
"
as.dto.{}.id.{}Identifier
"
.
format
(
entity
.
lower
(),
entity_capitalize
)
...
@@ -1310,7 +1314,7 @@ class Openbis:
...
@@ -1310,7 +1314,7 @@ class Openbis:
def
get_samples
(
def
get_samples
(
self
,
code
=
None
,
permId
=
None
,
space
=
None
,
project
=
None
,
experiment
=
None
,
type
=
None
,
self
,
identifier
=
None
,
code
=
None
,
permId
=
None
,
space
=
None
,
project
=
None
,
experiment
=
None
,
type
=
None
,
start_with
=
None
,
count
=
None
,
start_with
=
None
,
count
=
None
,
withParents
=
None
,
withChildren
=
None
,
tags
=
None
,
props
=
None
,
**
properties
withParents
=
None
,
withChildren
=
None
,
tags
=
None
,
props
=
None
,
**
properties
):
):
...
@@ -1318,13 +1322,24 @@ class Openbis:
...
@@ -1318,13 +1322,24 @@ class Openbis:
"""
"""
sub_criteria
=
[]
sub_criteria
=
[]
# v3 API does not offer a search for identifiers. We need to do a combined search instead:
# space && code or
# space && project && code
if
identifier
:
identifier
=
identifier
.
lstrip
(
'
/
'
)
elements
=
identifier
.
split
(
'
/
'
)
if
len
(
elements
)
==
2
:
space
=
elements
[
0
]
code
=
elements
[
1
]
elif
len
(
elements
)
==
3
:
space
=
elements
[
0
]
code
=
elements
[
2
]
else
:
raise
ValueError
(
"
{} is not a valid sample identifier.
"
.
format
(
identifier
))
if
space
:
if
space
:
sub_criteria
.
append
(
_gen_search_criteria
({
sub_criteria
.
append
(
_subcriteria_for_code
(
space
,
'
space
'
))
"
space
"
:
"
Space
"
,
"
operator
"
:
"
AND
"
,
"
code
"
:
space
})
)
if
project
:
if
project
:
proj_crit
=
_subcriteria_for_code
(
project
,
'
project
'
)
proj_crit
=
_subcriteria_for_code
(
project
,
'
project
'
)
sub_criteria
.
append
(
proj_crit
)
sub_criteria
.
append
(
proj_crit
)
...
...
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