parsing_quads_v2.py
def check_bulk_plasmid_lib(read1):
    '''
    General information: spike-in library checks are done with 2by150 reads, so
    Read1 Alone is enough for giving all the information.
    Sample Read is stored at ./sample_read.dna in the same folder 
    Input: read-in line from read1. 
    Output: parsed promBC and rBC
    '''
    # Global Variables for extracting the barcodes
    # They are all 8 pbs, but I can always increase them anytime
    BEFORE_PBC = 'AATCTAGA'
    AFTER_PBC = 'GTCGAGAT'
    BEFORE_RBC = 'AAGTTATG'
    AFTER_RBC = 'GCTTTAAG'
    # Initiate a dictionary to hold results
    pop = {}
    # Initiate zero values for counting 
    pop['wrong'] = 0
    # Find the before pBC, and the after pBC, and get the promoter BC, and return length. 
    pBC_left_lim = find_near_matches(BEFORE_PBC, read1, max_l_dist = 1)
    pBC_right_lim = find_near_matches(AFTER_PBC, read1, max_l_dist = 1)
    rBC_left_lim = find_near_matches(BEFORE_RBC, read1, max_l_dist = 1)
    rBC_right_lim = find_near_matches(AFTER_RBC, read1, max_l_dist = 1)
    if len(pBC_left_lim) !=0 and len(pBC_right_lim) != 0 :
        if pBC_left_lim[0].end < pBC_right_lim[0].start:
            putative_pBC = read1[pBC_left_lim[0].end:pBC_right_lim[0].start]
            if len(rBC_left_lim) !=0 and len(rBC_right_lim)!=0:
                if rBC_left_lim[0].end < rBC_right_lim[0].start:
                    putative_rBC = read1[rBC_left_lim[0].end:rBC_right_lim[0].start]
                else:
                    putative_rBC = []
            else:
                putative_rBC = []
        else: 
            putative_pBC = []
    else:
        putative_pBC = []
    if len(putative_pBC) == 12:
        if len(putative_rBC) == 25:
            # Get the counts
            pop['bc_pair'] = putative_pBC + '\t' + putative_rBC
        else:
            pop['wrong'] += 1
    else:
        pop['wrong'] += 1
    # check
    return pop

    General information: spike-in library checks are done with 2by150 reads, so
    Read1 Alone is enough for giving all the information.
    Sample Read is stored at ./sample_read.dna in the same folder 
    Input: read-in line from read1. 
    Output: parsed promBC and rBC
    
General information: spike-in library checks are done with 2by150 reads, so
Read1 Alone is enough for giving all the information.
Sample Read is stored at ./sample_read.dna in the same folder
Input: read-in line from read1.
Output: parsed promBC and rBC
General information : spike - in library checks are done with 2by150 reads so Read1 Alone is enough for giving all the information . Sample Read is stored at . / sample_read . dna in the same folder Input : read - in line from read1 . Output : parsed promBC and rBC
def check_bulk_plasmid_lib(read1):
    BEFORE_PBC = 'AATCTAGA'
    AFTER_PBC = 'GTCGAGAT'
    BEFORE_RBC = 'AAGTTATG'
    AFTER_RBC = 'GCTTTAAG'
    pop = {}
    pop['wrong'] = 0
    pBC_left_lim = find_near_matches(BEFORE_PBC, read1, max_l_dist = 1)
    pBC_right_lim = find_near_matches(AFTER_PBC, read1, max_l_dist = 1)
    rBC_left_lim = find_near_matches(BEFORE_RBC, read1, max_l_dist = 1)
    rBC_right_lim = find_near_matches(AFTER_RBC, read1, max_l_dist = 1)
    if len(pBC_left_lim) !=0 and len(pBC_right_lim) != 0 :
        if pBC_left_lim[0].end < pBC_right_lim[0].start:
            putative_pBC = read1[pBC_left_lim[0].end:pBC_right_lim[0].start]
            if len(rBC_left_lim) !=0 and len(rBC_right_lim)!=0:
                if rBC_left_lim[0].end < rBC_right_lim[0].start:
                    putative_rBC = read1[rBC_left_lim[0].end:rBC_right_lim[0].start]
                else:
                    putative_rBC = []
            else:
                putative_rBC = []
        else: 
            putative_pBC = []
    else:
        putative_pBC = []
    if len(putative_pBC) == 12:
        if len(putative_rBC) == 25:
            pop['bc_pair'] = putative_pBC + '\t' + putative_rBC
        else:
            pop['wrong'] += 1
    else:
        pop['wrong'] += 1
    return pop
def check_bulk_plasmid_lib ( read1 ) : BEFORE_PBC = 'AATCTAGA' AFTER_PBC = 'GTCGAGAT' BEFORE_RBC = 'AAGTTATG' AFTER_RBC = 'GCTTTAAG' pop = { } pop [ 'wrong' ] = 0 pBC_left_lim = find_near_matches ( BEFORE_PBC , read1 , max_l_dist = 1 ) pBC_right_lim = find_near_matches ( AFTER_PBC , read1 , max_l_dist = 1 ) rBC_left_lim = find_near_matches ( BEFORE_RBC , read1 , max_l_dist = 1 ) rBC_right_lim = find_near_matches ( AFTER_RBC , read1 , max_l_dist = 1 ) if len ( pBC_left_lim ) != 0 and len ( pBC_right_lim ) != 0 : if pBC_left_lim [ 0 ] . end < pBC_right_lim [ 0 ] . start : putative_pBC = read1 [ pBC_left_lim [ 0 ] . end : pBC_right_lim [ 0 ] . start ] if len ( rBC_left_lim ) != 0 and len ( rBC_right_lim ) != 0 : if rBC_left_lim [ 0 ] . end < rBC_right_lim [ 0 ] . start : putative_rBC = read1 [ rBC_left_lim [ 0 ] . end : rBC_right_lim [ 0 ] . start ] else : putative_rBC = [ ] else : putative_rBC = [ ] else : putative_pBC = [ ] else : putative_pBC = [ ] if len ( putative_pBC ) == 12 : if len ( putative_rBC ) == 25 : pop [ 'bc_pair' ] = putative_pBC + '\t' + putative_rBC else : pop [ 'wrong' ] += 1 else : pop [ 'wrong' ] += 1 return pop
General information: spike-in library checks are done with 2by150 reads, so
Read1 Alone is enough for giving all the information.
General information : spike - in library checks are done with 2by150 reads so Read1 Alone is enough for giving all the information .
'''
    General information: spike-in library checks are done with 2by150 reads, so
    Read1 Alone is enough for giving all the information.
    Sample Read is stored at ./sample_read.dna in the same folder 
    Input: read-in line from read1. 
    Output: parsed promBC and rBC
    ''' # Global Variables for extracting the barcodes # They are all 8 pbs, but I can always increase them anytime # Initiate a dictionary to hold results # Initiate zero values for counting  # Find the before pBC, and the after pBC, and get the promoter BC, and return length.  # Get the counts # check
read1