annotate find_indiv.py @ 2:013ff9bb23aa draft

Uploaded
author dereeper
date Fri, 05 Aug 2016 10:26:44 -0400
parents fe39a4677281
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
1 import sys
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
2 import os
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
3 import re
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
4
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
5 def get_field_samples_options(dataset):
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
6 options = []
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
7 line=os.popen("grep '#CHROM' %s"%dataset.file_name).read()[:-1].split('\t')
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
8 index=line.index('FORMAT')
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
9 for opt in line[index+1:] :
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
10 options.append((opt,opt, True))
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
11 return options
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
12
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
13 def get_field_chrs_options(dataset):
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
14 options = []
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
15 chrs=os.popen("grep '##contig' %s"%dataset.file_name).read()[:-1].split('\n')
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
16 for line in chrs:
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
17 opt=re.search('^##contig=<ID=(\w+),length=',line).group(1)
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
18 options.append((opt,opt, True))
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
19 return options
fe39a4677281 Uploaded
dereeper
parents:
diff changeset
20