ultraplex/__main__.py
def score_barcode_for_dict(seq, barcodes, min_score, Ns_removed=False):
    """
	this function scores a given sequence against all the barcodes. It returns the winner with Ns included.
	"""

    if not Ns_removed:
        barcodes = remove_Ns_from_barcodes(barcodes)
    barcodes_no_N = barcodes.keys()

    if seq in barcodes_no_N:  # no need to check all barcodes
        winner = barcodes[seq]  # barcode WITH Ns included
    elif min_score == len(barcodes_no_N):  # i.e. no matches allowed, and seq not in barcodes
        winner = "no_match"
    else:  # mismatches allowed so need to check
        scores = {}

        for this_bc in barcodes_no_N:
            # score the barcode against the read, penalty for N in the read
            score = sum(a == b for a, b in zip(this_bc, seq))
            scores[this_bc] = score

        # Find the best score
        best_score = max(scores.values())

        if best_score < min_score:
            winner = "no_match"
        else:
            # check that there is only one barcode with the max score
            filtered = [a for a, b in scores.items() if b == best_score]
            if len(filtered) > 1:
                winner = "no_match"
            else:  # if there is only one
                winner = barcodes[filtered[0]]  # barcode WITH Ns included
    return winner

	this function scores a given sequence against all the barcodes. It returns the winner with Ns included.
	
this function scores a given sequence against all the barcodes. It returns the winner with Ns included.
this function scores a given sequence against all the barcodes . It returns the winner with Ns included .
def score_barcode_for_dict(seq, barcodes, min_score, Ns_removed=False):
    if not Ns_removed:
        barcodes = remove_Ns_from_barcodes(barcodes)
    barcodes_no_N = barcodes.keys()
    if seq in barcodes_no_N:  
        winner = barcodes[seq]  
    elif min_score == len(barcodes_no_N):  
        winner = "no_match"
    else:  
        scores = {}
        for this_bc in barcodes_no_N:
            score = sum(a == b for a, b in zip(this_bc, seq))
            scores[this_bc] = score
        best_score = max(scores.values())
        if best_score < min_score:
            winner = "no_match"
        else:
            filtered = [a for a, b in scores.items() if b == best_score]
            if len(filtered) > 1:
                winner = "no_match"
            else:  
                winner = barcodes[filtered[0]]  
    return winner
def score_barcode_for_dict ( seq , barcodes , min_score , Ns_removed = False ) : if not Ns_removed : barcodes = remove_Ns_from_barcodes ( barcodes ) barcodes_no_N = barcodes . keys ( ) if seq in barcodes_no_N : winner = barcodes [ seq ] elif min_score == len ( barcodes_no_N ) : winner = "no_match" else : scores = { } for this_bc in barcodes_no_N : score = sum ( a == b for a , b in zip ( this_bc , seq ) ) scores [ this_bc ] = score best_score = max ( scores . values ( ) ) if best_score < min_score : winner = "no_match" else : filtered = [ a for a , b in scores . items ( ) if b == best_score ] if len ( filtered ) > 1 : winner = "no_match" else : winner = barcodes [ filtered [ 0 ] ] return winner
this function scores a given sequence against all the barcodes.
this function scores a given sequence against all the barcodes .
"""
	this function scores a given sequence against all the barcodes. It returns the winner with Ns included.
	""" # no need to check all barcodes
 # barcode WITH Ns included
 # i.e. no matches allowed, and seq not in barcodes
 # mismatches allowed so need to check
 # score the barcode against the read, penalty for N in the read
 # Find the best score
 # check that there is only one barcode with the max score
 # if there is only one
 # barcode WITH Ns included

seq
barcodes
min_score
Ns_removed