Skip to Content
Bioinformatics with Python Cookbook - Second Edition
book

Bioinformatics with Python Cookbook - Second Edition

by Tiago Antao
November 2018
Intermediate to advanced
360 pages
9h 36m
English
Packt Publishing
Content preview from Bioinformatics with Python Cookbook - Second Edition

How to do it...

Take a look at the following steps:

  1. Let's get the metadata for our samples. We will load the population of each sample and note all individuals that are offspring of others in the dataset:
from collections import defaultdictf = open('relationships_w_pops_121708.txt')pop_ind = defaultdict(list)f.readline() # headeroffspring = []for l in f:    toks = l.rstrip().split('\t')    fam_id = toks[0]    ind_id = toks[1]    mom = toks[2]    dad = toks[3]    if mom != '0' or dad != '0':        offspring.append((fam_id, ind_id))    pop = toks[-1]pop_ind[pop].append((fam_id, ind_id))f.close()

This will load a dictionary where population is the key (CEU, YRI, and so on) and its value is the list of individuals in that population. This dictionary will also store information ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Bioinformatics with Python Cookbook

Bioinformatics with Python Cookbook

Tiago Antao

Publisher Resources

ISBN: 9781789344691Supplemental Content