Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F121829391
cluster_file_reader.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
Mon, Jul 14, 05:51
Size
2 KB
Mime Type
text/x-python
Expires
Wed, Jul 16, 05:51 (2 d)
Engine
blob
Format
Raw Data
Handle
27366429
Attached To
R2010 molecular_data_processing
cluster_file_reader.py
View Options
#!/usr/bin/env python
# -*- coding: utf-8 -*-
" todo:: documentation for module containing class clusterFileReader"
##########################################################################
from
sequence_collection
import
SequenceCollection
##########################################################################
class
ClusterFileReader
(
object
):
"""
class ClusterFileReader: general class of readers for clustering algorithm output files
"""
# ------------------------------------------------------------------ #
# Constructors/Destructors #
# ------------------------------------------------------------------ #
def
__init__
(
self
,
filename
):
"""__init__: initialize the cluster reader """
# Members ---------------------- #
# string filename
self
.
filename
=
filename
# string list list_sample_id
self
.
list_sample_id
=
[]
# SequenceCollection sequence_collection
self
.
sequence_collection
=
SequenceCollection
()
def
__del__
(
self
):
"""__del__: not implemented """
pass
# ------------------------------------------------------------------ #
# Methods #
# ------------------------------------------------------------------ #
# public:
def
read
(
self
,
filter_reader
,
key_string
):
"""read: interface function """
pass
def
incrementAbundancePerSample
(
self
,
cluster
,
sampleID
):
"""incrementAbundancePerSample: increment the dictionnary that stores the number of sequences per sample in each cluster and increment the total cluster size """
# add 1 to the number of sequences from sampleID in the cluster
if
sampleID
not
in
cluster
.
d_abundance_per_sample
:
cluster
.
d_abundance_per_sample
[
sampleID
]
=
1
else
:
cluster
.
d_abundance_per_sample
[
sampleID
]
+=
1
# add 1 to the total cluster size
cluster
.
size
+=
1
##########################################################################
if
__name__
==
'__main__'
:
test
=
clusterFileReader
()
Event Timeline
Log In to Comment