ultraplex/__main__.py
def five_p_demulti(read, five_p_bc_pos, five_p_umi_poses,
                   five_p_bc_dict, add_umi, keep_barcode, barcodes_no_N=[], min_score=0):
    """
    this function demultiplexes on the 5' end
    """
    sequence_length = len(read.sequence)
    this_five_p_umi = ""

    # check if "rbc:" already in header
    if "rbc:" in read.name:
        to_add = ""
    else:  # if not
        to_add = "rbc:"

    if sequence_length > max(five_p_bc_pos):
        # find best barcode match
        this_bc_seq = ''.join([read.sequence[i] for i in five_p_bc_pos])

        if "dont_build" in five_p_bc_dict:
            winner = score_barcode_for_dict(this_bc_seq, barcodes_no_N, min_score, Ns_removed=True)
        else:
            winner = five_p_bc_dict[this_bc_seq]

        # store what sequence will be removed
        if sequence_length < len(winner):  # read is too short to contain barcode
            winner = "no_match"
            to_remove = ""
        else:
            to_remove = read.sequence[0:len(winner)]

        if not winner == "no_match":
            # /# find umi sequence
            this_five_p_umi = ''.join([read.sequence[i] for i in five_p_umi_poses[winner]])

            if not keep_barcode:
                # /# update read and read header
                read.sequence = read.sequence[len(winner):]
                read.qualities = read.qualities[len(winner):]

            if add_umi:
                # to read header add umi and 5' barcode info
                read.name = (read.name.replace(" ", "") + to_add + this_five_p_umi)
        else:  # if no match
            read.name = read.name + to_add

    else:  # if read was too short to assign
        winner = "no_match"
        read.name = read.name + to_add
        to_remove = ""

    return read, winner, this_five_p_umi, to_remove

    this function demultiplexes on the 5' end
    
this function demultiplexes on the 5' end
this function demultiplexes on the 5 ' end
def five_p_demulti(read, five_p_bc_pos, five_p_umi_poses,
                   five_p_bc_dict, add_umi, keep_barcode, barcodes_no_N=[], min_score=0):
    sequence_length = len(read.sequence)
    this_five_p_umi = ""
    if "rbc:" in read.name:
        to_add = ""
    else:  
        to_add = "rbc:"
    if sequence_length > max(five_p_bc_pos):
        this_bc_seq = ''.join([read.sequence[i] for i in five_p_bc_pos])
        if "dont_build" in five_p_bc_dict:
            winner = score_barcode_for_dict(this_bc_seq, barcodes_no_N, min_score, Ns_removed=True)
        else:
            winner = five_p_bc_dict[this_bc_seq]
        if sequence_length < len(winner):  
            winner = "no_match"
            to_remove = ""
        else:
            to_remove = read.sequence[0:len(winner)]
        if not winner == "no_match":
            this_five_p_umi = ''.join([read.sequence[i] for i in five_p_umi_poses[winner]])
            if not keep_barcode:
                read.sequence = read.sequence[len(winner):]
                read.qualities = read.qualities[len(winner):]
            if add_umi:
                read.name = (read.name.replace(" ", "") + to_add + this_five_p_umi)
        else:  
            read.name = read.name + to_add
    else:  
        winner = "no_match"
        read.name = read.name + to_add
        to_remove = ""
    return read, winner, this_five_p_umi, to_remove
def five_p_demulti ( read , five_p_bc_pos , five_p_umi_poses , five_p_bc_dict , add_umi , keep_barcode , barcodes_no_N = [ ] , min_score = 0 ) : sequence_length = len ( read . sequence ) this_five_p_umi = "" if "rbc:" in read . name : to_add = "" else : to_add = "rbc:" if sequence_length > max ( five_p_bc_pos ) : this_bc_seq = '' . join ( [ read . sequence [ i ] for i in five_p_bc_pos ] ) if "dont_build" in five_p_bc_dict : winner = score_barcode_for_dict ( this_bc_seq , barcodes_no_N , min_score , Ns_removed = True ) else : winner = five_p_bc_dict [ this_bc_seq ] if sequence_length < len ( winner ) : winner = "no_match" to_remove = "" else : to_remove = read . sequence [ 0 : len ( winner ) ] if not winner == "no_match" : this_five_p_umi = '' . join ( [ read . sequence [ i ] for i in five_p_umi_poses [ winner ] ] ) if not keep_barcode : read . sequence = read . sequence [ len ( winner ) : ] read . qualities = read . qualities [ len ( winner ) : ] if add_umi : read . name = ( read . name . replace ( " " , "" ) + to_add + this_five_p_umi ) else : read . name = read . name + to_add else : winner = "no_match" read . name = read . name + to_add to_remove = "" return read , winner , this_five_p_umi , to_remove
this function demultiplexes on the 5' end
this function demultiplexes on the 5 ' end
"""
    this function demultiplexes on the 5' end
    """ # check if "rbc:" already in header
 # if not
 # find best barcode match
 # store what sequence will be removed
 # read is too short to contain barcode
 # /# find umi sequence
 # /# update read and read header
 # to read header add umi and 5' barcode info
 # if no match
 # if read was too short to assign

read
five_p_bc_pos
five_p_umi_poses
five_p_bc_dict
add_umi
keep_barcode
barcodes_no_N
min_score