I have a list (df_pop_initial_list)
, and it looks like this:
[['000000000000000000000000000001011000000'],
['000000001000000000000001000000000010000'],
['000000000000000000000000000000010011000'],
['000000000000001001000000000000010000000'],
['000000000000000000010000001000000010000'],
['1000000000100000000010000000000000000000'],
['1000000010000000000001000000000000000000'],
['1001000000000000000010000000000000000000'],
['000000000000100000000000100000000000010'],
['000000000110000000000000000000001000000'],
['000000101000000010000000000000000000000'],
['000000000000001000000010000100000000000'],
['000000000000000010000101000000000000000'],
['000000001000100000000000000000000100000'],
['000000100000000000000000010000001000000'],
['000000000000001100000000000010000000000'],
['010000000000000000000000000001001000000'],
['000000010100000001000000000000000000000'],
['000000000000000000001000000001100000000'],
['000100000000000100000000000000000000010']]
I am trying to count 1's in this 39 bits
string list and converting each string value into 3 integer numbers where bits are on
(mean finding 1's
).
My code looks like this:
#Finding locations (3 MSUs) using 39 bit encoded string (counting 1's in a chromosome)
def indices_initial_pop(chromosome):
return {i+1 for i,c in enumerate(chromosome) if c=='1'}
#setting dynamic locations according to Chromosomes
def intial_population_bit_to_int(df_pop_initial_list):
for x in range(0, len(df_pop_initial_list), 1):
chrome = df_pop_initial_list[x]
msu_locations = indices_initial_pop(chrome)
initial_chromosomes_list.append(msu_locations)
return initial_chromosomes_list
initial_chromosomes_in_int_list = intial_population_bit_to_int(df_pop_initial_list)
print (initial_chromosomes_in_int_list)
Output:
[set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set()]
Why it is giving me a set()?