view find_indiv.py @ 8:f733bf4f49ca draft default tip

planemo upload commit 475f4d7d8442a0d75e103af326ae5881c4d2a4ac
author dereeper
date Mon, 16 Apr 2018 08:58:55 -0400
parents fe39a4677281
children
line wrap: on
line source

import sys
import os
import re

def get_field_samples_options(dataset):
	options = []
	line=os.popen("grep '#CHROM' %s"%dataset.file_name).read()[:-1].split('\t')
	index=line.index('FORMAT')
	for opt in line[index+1:] :
		options.append((opt,opt, True))
	return options

def get_field_chrs_options(dataset):
        options = []
        chrs=os.popen("grep '##contig' %s"%dataset.file_name).read()[:-1].split('\n')
        for line in chrs:
		opt=re.search('^##contig=<ID=(\w+),length=',line).group(1)
                options.append((opt,opt, True))
        return options