Ejemplo n.º 1
0
def create_Samples_from_header(line):
    
    """Creates sample objects for input file.
    It uses CN and CP input lists from users.
    
    It creates a sample object for each one containing the name
    and the column index for genotype, depth amd var/depth (ratio) columns    
    """
    samples_name_list = []
    sample_return_list = []
    
    geno_sufix = '.replicate1_Genotype'
    depth_sufix = '.replicate1_Depth'
    ratio_sufix = '.replicate1_Var/Depth'
    
    columns = line.split('|')

    for i in columns:
        res = re.search('(.*)\.replicate1_Genotype$', i)
        if res: samples_name_list.append(res.group(1))

    for sample_name in samples_name_list:
        genotype_col = columns.index(sample_name+geno_sufix) 
        depth_col = columns.index(sample_name+depth_sufix)
        ratio_col = columns.index(sample_name+ratio_sufix)
            
        new_sample = Sample(sample_name, genotype_col, depth_col, ratio_col)
        
        #We create and set a VariantCounter object to the Sample.      
        new_sample.set_variant_counter(VariantCounter())
        sample_return_list.append(new_sample)
            
    return sample_return_list
Ejemplo n.º 2
0
def create_Samples_from_header(line):
    """Creates sample objects for input file.
    It uses CN and CP input lists from users.
    
    It creates a sample object for each one containing the name
    and the column index for genotype, depth amd var/depth (ratio) columns    
    """
    samples_name_list = []
    sample_return_list = []

    geno_sufix = '.replicate1_Genotype'
    depth_sufix = '.replicate1_Depth'
    ratio_sufix = '.replicate1_Var/Depth'

    columns = line.split('|')

    for i in columns:
        res = re.search('(.*)\.replicate1_Genotype$', i)
        if res: samples_name_list.append(res.group(1))

    for sample_name in samples_name_list:
        genotype_col = columns.index(sample_name + geno_sufix)
        depth_col = columns.index(sample_name + depth_sufix)
        ratio_col = columns.index(sample_name + ratio_sufix)

        new_sample = Sample(sample_name, genotype_col, depth_col, ratio_col)

        #We create and set a VariantCounter object to the Sample.
        new_sample.set_variant_counter(VariantCounter())
        sample_return_list.append(new_sample)

    return sample_return_list