Page MenuHomec4science

cluster_file_reader.py
No OneTemporary

File Metadata

Created
Mon, Jul 14, 05:51

cluster_file_reader.py

#!/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