scripts/preprocessing/relabel_seed.py
def map_sequence_segments(seed_seq, rnac_seq, no_segments=4):
    """
    Splits a seed sequence into smaller segments and maps the
    individual segments to the RNAcentral sequence
    param seed_seq:
    param rnac_seq:
    no_segments:

    return: RNAcentral subsequence if segments match by 75%, None otherwise
    """

    segment_hits = {}
    output = {}
    seq_match_score = 0
    seed_length = len(seed_seq)

    reference_start = None

    # calculate number of remaining nts the last segment will be extended by
    remainder = seed_length % no_segments

    # calculate even segment sizes based on no_segments
    segment_size = int((seed_length - remainder) / no_segments)

    # initialize all segment hits to 0
    index = 0
    start = 0
    end = segment_size

    # initialize
    while index < no_segments:
        # check if segment is not the last
        if index != no_segments:
            segment_hits[index + 1] = [seed_seq[start:end], 0]
        else:
            segment_hits[index + 1] = [seed_seq[start:], 0]

        start = end
        end = end + segment_size

        index += 1

    # Now map the segments to the original sequence
    for position in sorted(segment_hits.keys()):
        segment = segment_hits[position][0]

        coords = fetch_seed_sequence_coordinates(segment, rnac_seq)

        # set mapping score to 1 - the segment matches
        if coords[0] != 0 or coords[1] != 0:
            segment_hits[position][1] = 1
            seq_match_score += 1

        # set reference_start
        #if position == 1:
            #reference_start = coords[0]

    # get percentage of matches
    percentage = seq_match_score * no_segments / 100

    # check if at least 75% of the sequence segments
    # match the target sequence
    if percentage >= 75:
        """
        # need to split this to more cases
        return rnac_seq[reference_start: reference_start + seed_length]
        """
        pass

    return None

    Splits a seed sequence into smaller segments and maps the
    individual segments to the RNAcentral sequence
    param seed_seq:
    param rnac_seq:
    no_segments:

    return: RNAcentral subsequence if segments match by 75%, None otherwise
    
Splits a seed sequence into smaller segments and maps the
individual segments to the RNAcentral sequence
param seed_seq:
param rnac_seq:
no_segments.

RNAcentral subsequence if segments match by 75%, None otherwise
Splits a seed sequence into smaller segments and maps the individual segments to the RNAcentral sequence param seed_seq : param rnac_seq : no_segments . RNAcentral subsequence if segments match by 75% None otherwise
def map_sequence_segments(seed_seq, rnac_seq, no_segments=4):
    segment_hits = {}
    output = {}
    seq_match_score = 0
    seed_length = len(seed_seq)
    reference_start = None
    remainder = seed_length % no_segments
    segment_size = int((seed_length - remainder) / no_segments)
    index = 0
    start = 0
    end = segment_size
    while index < no_segments:
        if index != no_segments:
            segment_hits[index + 1] = [seed_seq[start:end], 0]
        else:
            segment_hits[index + 1] = [seed_seq[start:], 0]
        start = end
        end = end + segment_size
        index += 1
    for position in sorted(segment_hits.keys()):
        segment = segment_hits[position][0]
        coords = fetch_seed_sequence_coordinates(segment, rnac_seq)
        if coords[0] != 0 or coords[1] != 0:
            segment_hits[position][1] = 1
            seq_match_score += 1
    percentage = seq_match_score * no_segments / 100
    if percentage >= 75:
        pass
    return None
def map_sequence_segments ( seed_seq , rnac_seq , no_segments = 4 ) : segment_hits = { } output = { } seq_match_score = 0 seed_length = len ( seed_seq ) reference_start = None remainder = seed_length % no_segments segment_size = int ( ( seed_length - remainder ) / no_segments ) index = 0 start = 0 end = segment_size while index < no_segments : if index != no_segments : segment_hits [ index + 1 ] = [ seed_seq [ start : end ] , 0 ] else : segment_hits [ index + 1 ] = [ seed_seq [ start : ] , 0 ] start = end end = end + segment_size index += 1 for position in sorted ( segment_hits . keys ( ) ) : segment = segment_hits [ position ] [ 0 ] coords = fetch_seed_sequence_coordinates ( segment , rnac_seq ) if coords [ 0 ] != 0 or coords [ 1 ] != 0 : segment_hits [ position ] [ 1 ] = 1 seq_match_score += 1 percentage = seq_match_score * no_segments / 100 if percentage >= 75 : """
        # need to split this to more cases
        return rnac_seq[reference_start: reference_start + seed_length]
        """ pass return None
Splits a seed sequence into smaller segments and maps the
individual segments to the RNAcentral sequence
param seed_seq:
param rnac_seq:
no_segments:
Splits a seed sequence into smaller segments and maps the individual segments to the RNAcentral sequence param seed_seq : param rnac_seq : no_segments :
"""
    Splits a seed sequence into smaller segments and maps the
    individual segments to the RNAcentral sequence
    param seed_seq:
    param rnac_seq:
    no_segments:

    return: RNAcentral subsequence if segments match by 75%, None otherwise
    """ # calculate number of remaining nts the last segment will be extended by # calculate even segment sizes based on no_segments # initialize all segment hits to 0 # initialize # check if segment is not the last # Now map the segments to the original sequence # set mapping score to 1 - the segment matches # set reference_start #if position == 1: #reference_start = coords[0] # get percentage of matches # check if at least 75% of the sequence segments # match the target sequence """
        # need to split this to more cases
        return rnac_seq[reference_start: reference_start + seed_length]
        """
seed_seq
rnac_seq
no_segments