Commit 25d8abd3 authored by Penom Nom's avatar Penom Nom
Browse files

Clean lib.

parent a52a4405
......@@ -82,7 +82,6 @@ def _bootstrap_selection( OTU_count, nb_total_elts, nb_selected_elts ):
OTU_idx += 1
return selected_OTU
class DenseData( list ):
def get_matrix_type( self ):
"""
......@@ -663,6 +662,14 @@ class Biom:
"""
for col in self.columns:
yield col["id"]
def get_observations_names( self ):
"""
@summary : Returns a generator to iterate on observations names.
@return : [generator] the generator to iterate on observations names.
"""
for col in self.rows:
yield col["id"]
def _hash_OTU_by_sample( self ):
"""
......@@ -691,7 +698,11 @@ class Biom:
"""
nb_OTU_by_sample, sum_by_sample = self._hash_OTU_by_sample()
self.data.clear()
self.generated_by += " | normalisation[delete : " + str(nb_removed_elts) + "; select : " + str(nb_selected_elts) + "; round : " + str(nb_selection_round) + "]"
if self.generated_by is None:
self.generated_by = ""
else:
self.generated_by += ' | '
self.generated_by += "sampling[delete : " + str(nb_removed_elts) + "; select : " + str(nb_selected_elts) + "; round : " + str(nb_selection_round) + "]"
for i in range(nb_selection_round):
for current_sample in self.columns:
sample_id = current_sample['id']
......@@ -704,9 +715,6 @@ class Biom:
OTU_idx = self.find_idx( self.rows, OTU_id )
sample_idx = self.find_idx( self.columns, current_sample['id'] )
self.data.add( OTU_idx, sample_idx, selected[OTU_id] )
##################################################
# self.data.sort()
##################################################
def to_count( self ):
"""
......@@ -786,7 +794,7 @@ class BiomIO:
col_idx = 0
for count in line_fields[1:]:
if int(count) != 0:
biom.data.append( [row_idx, col_idx, int(count)] )
biom.data.add( row_idx, col_idx, int(count) )
col_idx += 1
row_idx += 1
count_fh.close()
......@@ -866,7 +874,7 @@ class BiomIO:
for row_idx in range(len(biom.rows)):
count = biom.data.nb_at( row_idx, col_idx )
if count > 0:
tax = biom.rows[idx]["metadata"]["taxonomy"]
tax = biom.rows[row_idx]["metadata"]["taxonomy"]
if isinstance(tax, list) or isinstance(tax, tuple):
tax = "\t".join( map(str, tax) )
else:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment