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
5f94925c
Commit
5f94925c
authored
12 years ago
by
kohleman
Browse files
Options
Downloads
Patches
Plain Diff
openBIS script for checking uniqueness of indices in a single- or dual-indexed sample pool
SVN: 26304
parent
d7b983fa
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
deep_sequencing_unit/source/Jython/duplicateBarcodeChecker.py
+104
-0
104 additions, 0 deletions
..._sequencing_unit/source/Jython/duplicateBarcodeChecker.py
with
104 additions
and
0 deletions
deep_sequencing_unit/source/Jython/duplicateBarcodeChecker.py
0 → 100644
+
104
−
0
View file @
5f94925c
import
smtplib
import
string
import
copy
def
sendMail
(
registratorEmail
,
indexStrings
=
''
,
sampleIdentifier
=
''
,
additionalText
=
''
):
'''
Send out an email to the specified recipients
'''
COMMASPACE
=
"
,
"
loe
=
[
"
manuel.kohler@bsse.ethz.ch
"
]
if
registratorEmail
and
registratorEmail
not
in
loe
:
loe
.
append
(
registratorEmail
)
TO
=
COMMASPACE
.
join
(
loe
)
SUBJECT
=
"
WARNING! For pooled sample
"
+
sampleIdentifier
FROM
=
"
qgf@openbis-dsu.ethz.ch
"
HOST
=
"
smtp0.ethz.ch
"
text
=
"
Sample:
"
+
sampleIdentifier
+
"
\n
Barcode:
"
+
indexStrings
+
"
\n
"
+
additionalText
BODY
=
string
.
join
((
"
From: %s
"
%
FROM
,
"
To: %s
"
%
TO
,
"
Subject: %s
"
%
SUBJECT
,
""
,
text
),
"
\r\n
"
)
server
=
smtplib
.
SMTP
(
HOST
)
server
.
sendmail
(
FROM
,
[
TO
],
BODY
)
server
.
quit
()
def
checkDuplicateBarcodes
():
'''
'
parents
'
are a HashSet of SamplePropertyPE
'''
VOCABULARY_INDEX1
=
'
BARCODE
'
VOCABULARY_INDEX2
=
'
INDEX2
'
SUCCESS_MESSAGE
=
"
OK
"
registratorEmail
=
entity
.
entityPE
().
registrator
.
email
poolName
=
entity
.
entityPE
().
sampleIdentifier
listofIndices
=
[]
listofIndices2
=
[]
returnString
=
"
"
for
e
in
entity
.
entityPE
().
parents
:
for
s
in
e
.
properties
:
if
s
.
entityTypePropertyType
.
propertyType
.
simpleCode
==
VOCABULARY_INDEX1
:
index
=
s
.
getVocabularyTerm
().
code
listofIndices
.
append
(
index
)
if
s
.
entityTypePropertyType
.
propertyType
.
simpleCode
==
VOCABULARY_INDEX2
:
index
=
s
.
getVocabularyTerm
().
code
listofIndices2
.
append
(
index
)
sampleIdentifier
=
e
.
sampleIdentifier
# if dual-indexed
if
listofIndices2
:
dualIndexList
=
[]
if
len
(
listofIndices
)
!=
len
(
listofIndices2
):
indices
=
"
\n
Index1 :
"
+
str
(
listofIndices
)
+
"
\n
Index2:
"
+
str
(
listofIndices2
)
returnString
=
"
Dual indexing assignment is not complete for pool sample
"
+
str
(
poolName
)
sendMail
(
registratorEmail
,
indices
,
str
(
poolName
),
returnString
)
return
returnString
# build up a list of dual indices
for
l
in
range
(
len
(
listofIndices
)):
try
:
dualIndexList
.
insert
(
l
,
[
listofIndices
[
l
],
listofIndices2
[
l
]])
except
:
pass
# copy, needed by the for loop
dualIndexListOrig
=
copy
.
deepcopy
(
dualIndexList
)
for
dualIndex
in
dualIndexListOrig
:
dualIndexList
.
remove
(
dualIndex
)
if
dualIndex
in
dualIndexList
:
returnString
=
"
WARNING! You assigned duplicate indices
\n
"
+
str
(
dualIndex
)
+
\
"
in the dual-indexed pooled sample!
"
sendMail
(
registratorEmail
,
str
(
dualIndex
),
str
(
poolName
),
returnString
)
return
returnString
else
:
returnString
=
SUCCESS_MESSAGE
return
returnString
# else single index
else
:
uniqueList
=
list
(
set
(
listofIndices
))
if
len
(
listofIndices
)
!=
len
(
uniqueList
):
for
index
in
uniqueList
:
listofIndices
.
remove
(
index
)
returnString
=
"
WARNING! You assigned duplicate indices
\n
"
+
str
(
listofIndices
)
+
\
"
in the single-indexed pooled sample!
"
sendMail
(
registratorEmail
,
str
(
listofIndices
),
str
(
poolName
),
returnString
)
else
:
returnString
=
SUCCESS_MESSAGE
return
returnString
def
calculate
():
"""
Main script function. The result will be used as the value of appropriate dynamic property.
"""
return
checkDuplicateBarcodes
()
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