Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F121357953
sequence_collection.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Jul 10, 06:44
Size
2 KB
Mime Type
text/x-python
Expires
Sat, Jul 12, 06:44 (2 d)
Engine
blob
Format
Raw Data
Handle
27296230
Attached To
R2010 molecular_data_processing
sequence_collection.py
View Options
#!/usr/bin/env python
# -*- coding: utf-8 -*-
" module containing class ClusterCollection"
##########################################################################
##########################################################################
class
SequenceCollection
(
object
):
"""
class SequenceCollection: stores the sequences and have several function to access these sequences
"""
# ------------------------------------------------------------------ #
# Constructors/Destructors #
# ------------------------------------------------------------------ #
def
__init__
(
self
):
"""__init__: the main member is an empty dictionnary that will be used to store the sequences"""
# Members ---------------------- #
# dictionnary containing the sequence collection
# la cle est une info contenue dans la sequence, mais je ne vois pas comment eviter ce doublon
# dictionnary dict
self
.
dict
=
{}
# int length
self
.
length
=
0
def
__del__
(
self
):
"""__del__: not implemented """
pass
def
addSequence
(
self
,
new_sequence
):
"""addSequence : add the sequence to the present collection) """
self
.
dict
[
new_sequence
.
seqID
]
=
new_sequence
return
0
def
removeSequences
(
self
,
list_of_seqIDs
):
"""removeSequence : remove the sequences which id correspond to the seqIDs in the list """
for
seqID
in
list_of_seqIDs
:
del
self
.
dict
[
seqID
]
return
0
def
getSequence
(
self
,
seqID
):
"""getSequence : return the sequence in the collection corresponding to the argument seqID """
return
self
.
dict
[
seqID
]
def
modifyClusterID
(
self
,
previous_cluster_id
,
new_cluster_id
):
"""modifyClusterID : modify the cluster id attributed to a sequence (is mainly useful if the cluster files is from 'dbc' clustering software) """
for
seqID
,
current_sequence
in
self
.
dict
.
iteritems
():
if
current_sequence
.
seq_cluster_id
==
previous_cluster_id
:
self
.
dict
[
seqID
]
.
seq_cluster_id
=
new_cluster_id
return
0
def
actualizeLenght
(
self
):
""" actualizeLenght : return the number of sequences of the sequence collection """
return
len
(
self
.
dict
)
##########################################################################
if
__name__
==
'__main__'
:
test
=
ClusterCollection
()
Event Timeline
Log In to Comment