Exemplo n.º 1
0
def insert_sequence_pos(pan_sequence, second_sequence):
    sequence_id = ''
    #check if blocks exist with the given position in pan genome, strain
    #get block from strain position
    block_strain = build_block(None, second_sequence.start, second_sequence.strain_name, second_sequence.sequence_name, pan_sequence.sequence_name)
    #get block from pan position
    block_pan = build_block(pan_sequence.start, None, second_sequence.strain_name, second_sequence.sequence_name, pan_sequence.sequence_name)

    block_encase_pan = encase_block(pan_sequence.start, None, pan_sequence.end, second_sequence.strain_name, second_sequence.sequence_name, pan_sequence.sequence_name)
    block_encase_strain = encase_block(None, second_sequence.start, second_sequence.end, second_sequence.strain_name, second_sequence.sequence_name, pan_sequence.sequence_name)

    if (block_encase_pan != None) or (block_encase_strain != None):
        print "encase %s, %s, %s, %s, %s" % (pan_sequence.start, second_sequence.start, second_sequence.length, pan_sequence.length, pan_sequence.sequence_string)
    elif (block_strain == None) and (block_pan == None):
        sequence_id = insert_sequence(pan_sequence, second_sequence)
        insert_position(pan_sequence.start, second_sequence.start, second_sequence.strain_name, second_sequence.sequence_name, pan_sequence.sequence_name, sequence_id)
        #map end from pan -> strain
        check_end_block_surrounding(pan_sequence, second_sequence)
        #map end from strain -> pan        
        check_end_block_surrounding_strain(pan_sequence, second_sequence)
    elif (block_strain.length == 0) and (block_pan.length == 0):
        sequence_id = insert_sequence(pan_sequence, second_sequence)
        insert_position(pan_sequence.start, second_sequence.start, second_sequence.strain_name, second_sequence.sequence_name, pan_sequence.sequence_name, sequence_id)
        #map end from pan -> strain
        check_end_block_surrounding(pan_sequence, second_sequence)
        #map end from strain -> pan        
        check_end_block_surrounding_strain(pan_sequence, second_sequence)
Exemplo n.º 2
0
def check_end_block_surrounding_strain(pan_sequence, second_sequence):
    start = second_sequence.end + 1
    total_length = int(second_sequence.total_length)
    if start < total_length:
        start_block = position_end_block(None, start, second_sequence.strain_name, second_sequence.sequence_name, pan_sequence.sequence_name)
        if start_block == None:
            insert_position('-1', start, second_sequence.strain_name, second_sequence.sequence_name, pan_sequence.sequence_name)
    #the end of the sequence is reached
    elif start >= total_length:
        start_block = position_end_block(None, start, second_sequence.strain_name, second_sequence.sequence_name, pan_sequence.sequence_name)
        if start_block == None:
            #'-1' should we mark the end of a sequence differently?
            insert_position('-1', start, second_sequence.strain_name, second_sequence.sequence_name, pan_sequence.sequence_name)
Exemplo n.º 3
0
def check_mapping_sequence_start(pan_sequence, second_sequence):
    block_position_start = position_exist(0, None, second_sequence.strain_name, second_sequence.sequence_name, pan_sequence.sequence_name)
    if block_position_start == None:
        insert_position('0', '-1', second_sequence.strain_name, second_sequence.sequence_name, pan_sequence.sequence_name)    
Exemplo n.º 4
0
def check_mapping_sequence_end(pan_sequence, second_sequence):
    last_position = int(pan_sequence.total_length) + 1
    block_position_end = position_end_block(last_position, None, second_sequence.strain_name, second_sequence.sequence_name, pan_sequence.sequence_name)
    if block_position_end == None:
        insert_position(last_position, '-1', second_sequence.strain_name, second_sequence.sequence_name, pan_sequence.sequence_name)    
Exemplo n.º 5
0
def check_start_block_surrounding(pan_sequence, second_sequence):
    start = int(pan_sequence.start) - 1
    if start > 0:
        start_block = position_start_block(start, None, second_sequence.strain_name, pan_sequence.sequence_name, second_sequence.sequence_name)
        if start_block == None:
            insert_position(start, '-2', second_sequence.strain_name, second_sequence.sequence_name, pan_sequence.sequence_name)