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'
    consequence = 'Variant_effect'
    
    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)
        
        #We get consequence column
        consequence_col = columns.index(consequence)
        
        #We create the sample object
        new_sample = Sample(sample_name, genotype_col, depth_col, ratio_col)
        
        #We set the consequence column
        new_sample.set_consequence_col(consequence_col)
        
        #We create and set a ConsequenceCounter object to the Sample.
        consequence_counter = ConsequenceCounter()
        
        #We set the ConsequenceCounter object to Sample object
        new_sample.set_consequence_counter(consequence_counter)
        
        sample_return_list.append(new_sample)
            
    return sample_return_list