Commit 562d4880 authored by Romain Feron's avatar Romain Feron
Browse files

Fixed small bug in loading catalog file

parent 19189b44
...@@ -67,7 +67,7 @@ def get_info_from_catalog(catalog_path, ...@@ -67,7 +67,7 @@ def get_info_from_catalog(catalog_path,
return frequencies_data return frequencies_data
def get_haplotypes(parameters, individuals_only=False): def get_haplotypes(parameters, sequence=False, correspondance=False, numbers=True):
''' '''
Extract haplotypes information, sorted by sex, from a catalog file Extract haplotypes information, sorted by sex, from a catalog file
...@@ -87,22 +87,20 @@ def get_haplotypes(parameters, individuals_only=False): ...@@ -87,22 +87,20 @@ def get_haplotypes(parameters, individuals_only=False):
tabs = line.split('\t') tabs = line.split('\t')
locus_id = tabs[2] locus_id = tabs[2]
indiv_ids = tabs[8].split(',') indiv_ids = tabs[8].split(',')
haplotypes_data[locus_id] = {} haplotypes_data[locus_id] = {'n_males': 0, 'n_females': 0}
if not individuals_only: for individual in indiv_ids:
haplotypes_data[locus_id]['sequence'] = tabs[9] temp = individual.split('_')[0]
haplotypes_data[locus_id]['individuals'] = {} if correspondance:
for individual in indiv_ids:
haplotypes_data[locus_id]['individuals'][individual.split('_')[0]] = individual.split('_')[1] haplotypes_data[locus_id]['individuals'][individual.split('_')[0]] = individual.split('_')[1]
haplotypes_data[locus_id]['n_males'] = len({i for i in haplotypes_data[locus_id]['individuals'].keys() if else:
parameters.popmap[parameters.order[i]] is 'M'}) haplotypes_data[locus_id]['individuals'] = [individual.split('_')[0] for individual in indiv_ids]
haplotypes_data[locus_id]['n_females'] = len({i for i in haplotypes_data[locus_id]['individuals'].keys() if if numbers:
parameters.popmap[parameters.order[i]] is 'F'}) if parameters.popmap[parameters.order[temp[0]]] is 'M':
else: haplotypes_data[locus_id]['n_males'] += 1
haplotypes_data[locus_id]['individuals'] = [individual.split('_')[0] for individual in indiv_ids] elif parameters.popmap[parameters.order[temp[0]]] is 'F':
haplotypes_data[locus_id]['n_males'] = len({i for i in haplotypes_data[locus_id]['individuals'] if haplotypes_data[locus_id]['n_females'] += 1
parameters.popmap[parameters.order[i]] is 'M'}) if sequence:
haplotypes_data[locus_id]['n_females'] = len({i for i in haplotypes_data[locus_id]['individuals'] if haplotypes_data[locus_id]['sequence'] = tabs[9]
parameters.popmap[parameters.order[i]] is 'F'})
catalog.close() catalog.close()
......
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